Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.novell.nds.dirxml.driver
Class DelimitedText

    java.lang.Object
      com.novell.nds.dirxml.driver.DelimitedText

    public class DelimitedText

extends Object

Class for representing a delimited text file as XML.

Field Summary
`protected String[]` | `columnNames` Delimited text column names.
`static char` | `FIELD_DELIMITER_COMMA` Standard comma (`','`) delimiter.
`static char` | `FIELD_DELIMITER_DEFAULT` Default field delimiter (`FIELD_DELIMITER_COMMA`).
`static char` | `FIELD_DELIMITER_TAB` Standard tab (`'\t'`) delimiter.
`static String` | `FIELD_ELEMENT` Delimited text XML field-name element.
`static String` | `FIELD_NAME_ATTR` Delimited text XML field element name attribute.
`static String` | `FIELD_NAME_ELEMENT` Delimited text XML field element.
`static char` | `FIELD_QUOTE` Quote character (`'"'`).
`protected char` | `fieldDelimiter` Delimited text field delimiter character.
`protected boolean` | `hasHeaderRow` Delimited text header row indicator.
`static String` | `HEADER_ELEMENT` Delimited text XML header element.
`static String` | `RECORD_ELEMENT` Delimited text XML record element
`static String` | `ROOT_ELEMENT` Delimited text XML root element.

Constructor Summary
`DelimitedText()` Construct a `DelimitedText` instance with defaults.
`DelimitedText(char inFieldDelimiter)` Construct a `DelimitedText` instance with a custom field delimiter character.
`DelimitedText(char inFieldDelimiter, boolean inHasHeaderRow)` Construct a `DelimitedText` instance with a custom field delimiter character.
`DelimitedText(char inFieldDelimiter, String[] inColumnNames)` Construct a `DelimitedText` instance with a custom field delimiter character.

Method Summary
`void` | `convertFromXML(Document doc, BufferedWriter output)` Convert XML to delimited text.
`void` | `convertFromXML(Document doc, OutputStream output)` Convert XML to delimited text.
`void` | `convertFromXML(Document doc, String fileName)` Convert XML to delimited text.
`void` | `convertFromXML(Document doc, Writer output)` Convert XML to delimited text.
`Document` | `convertToXML(BufferedReader input)` Convert delimited text to XML.
`Document` | `convertToXML(InputStream input)` Convert delimited text to XML.
`Document` | `convertToXML(Reader input)` Convert delimited text to XML.
`Document` | `convertToXML(String fileName)` Convert delimited text to XML.
`protected String` | `quoteIfNeeded(String string)` Quote a delimited text field of it contains special characters.
`protected String[]` | `readRecord(BufferedReader input)` Read a delimited text record.
`protected void` | `writeField(Element field, BufferedWriter output)` Write a delimited text field.
`protected void` | `writeRecord(Element record, BufferedWriter output)` Write a delimited text record.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FIELD_DELIMITER_COMMA

    public static final char FIELD_DELIMITER_COMMA

  Standard comma (`','`) delimiter.

  See Also:
    Constant Field Values

### FIELD_DELIMITER_TAB

    public static final char FIELD_DELIMITER_TAB

  Standard tab (`'\t'`) delimiter.

  See Also:
    Constant Field Values

### FIELD_DELIMITER_DEFAULT

    public static final char FIELD_DELIMITER_DEFAULT

  Default field delimiter (`FIELD_DELIMITER_COMMA`).

  See Also:
    Constant Field Values

### FIELD_QUOTE

    public static final char FIELD_QUOTE

  Quote character (`'"'`).

  See Also:
    Constant Field Values

### ROOT_ELEMENT

    public static final String ROOT_ELEMENT

  Delimited text XML root element.

  See Also:
    Constant Field Values

### HEADER_ELEMENT

    public static final String HEADER_ELEMENT

  Delimited text XML header element.

  See Also:
    Constant Field Values

### FIELD_NAME_ELEMENT

    public static final String FIELD_NAME_ELEMENT

  Delimited text XML field element.

  See Also:
    Constant Field Values

### RECORD_ELEMENT

    public static final String RECORD_ELEMENT

  Delimited text XML record element

  See Also:
    Constant Field Values

### FIELD_ELEMENT

    public static final String FIELD_ELEMENT

  Delimited text XML field-name element.

  See Also:
    Constant Field Values

### FIELD_NAME_ATTR

    public static final String FIELD_NAME_ATTR

  Delimited text XML field element name attribute.

  See Also:
    Constant Field Values

### fieldDelimiter

    protected char fieldDelimiter

  Delimited text field delimiter character.

### columnNames

    protected String[] columnNames

  Delimited text column names.

### hasHeaderRow

    protected boolean hasHeaderRow

  Delimited text header row indicator.

Constructor Detail

### DelimitedText

    public DelimitedText()

  Construct a `DelimitedText` instance with defaults.

### DelimitedText

    public DelimitedText(char inFieldDelimiter)

  Construct a `DelimitedText` instance with a custom field delimiter character.

  Parameters:
    `inFieldDelimiter` - the field delimiter character

### DelimitedText

    public DelimitedText(char inFieldDelimiter,
                         boolean inHasHeaderRow)

  Construct a `DelimitedText` instance with a custom field delimiter character.

  Parameters:
    `inFieldDelimiter` - the field delimiter character
    `inHasHeaderRow` - `true` if input/output delimited text file has a header row

### DelimitedText

    public DelimitedText(char inFieldDelimiter,
                         String[] inColumnNames)

  Construct a `DelimitedText` instance with a custom field delimiter character.

  Parameters:
    `inFieldDelimiter` - the field delimiter character
    `inColumnNames` - list of column names to use on input

Method Detail

### convertToXML

    public Document convertToXML(String fileName)
                          throws IOException,
                                 DOMException

  Convert delimited text to XML.

  Parameters:
    `fileName` - name of delimited text file
  Throws:
    `IOException` - thrown if an error reading the file occurs
    `DOMException` - thrown if an error constructing the XML representaton occurs

### convertToXML

    public Document convertToXML(InputStream input)
                          throws IOException,
                                 DOMException

  Convert delimited text to XML.

  Parameters:
    `input` - `InputStream` containing delimited text
  Throws:
    `IOException` - thrown if an error reading the file occurs
    `DOMException` - thrown if an error constructing the XML representaton occurs

### convertToXML

    public Document convertToXML(Reader input)
                          throws IOException,
                                 DOMException

  Convert delimited text to XML.

  Parameters:
    `input` - `Reader` containing delimited text
  Throws:
    `IOException` - thrown if an error reading the file occurs
    `DOMException` - thrown if an error constructing the XML representaton occurs

### convertToXML

    public Document convertToXML(BufferedReader input)
                          throws IOException,
                                 DOMException

  Convert delimited text to XML.

  Parameters:
    `input` - `BufferedReader` containing delimited text
  Throws:
    `IOException` - thrown if an error reading the file occurs
    `DOMException` - thrown if an error constructing the XML representaton occurs

### readRecord

    protected String[] readRecord(BufferedReader input)
                           throws IOException

  Read a delimited text record.

  Parameters:
    `input` - `BufferedReader` positioned at beginning of delimited text record
  Returns:
    list of field values in record
  Throws:
    `IOException` - thrown if an error occurs reading from `input`.

### convertFromXML

    public void convertFromXML(Document doc,
                               String fileName)
                        throws IOException,
                               DOMException

  Convert XML to delimited text.

  Parameters:
    `doc` - DOM document to convert
    `fileName` - name of output delimited text file
  Throws:
    `IOException` - thrown if an error occurs writing to the file
    `DOMException` - thrown if an error occurs accessing the XML

### convertFromXML

    public void convertFromXML(Document doc,
                               OutputStream output)
                        throws IOException,
                               DOMException

  Convert XML to delimited text.

  Parameters:
    `doc` - DOM document to convert
    `output` - delimited text `OutputStream`
  Throws:
    `IOException` - thrown if an error occurs writing to `output`
    `DOMException` - thrown if an error occurs accessing the XML

### convertFromXML

    public void convertFromXML(Document doc,
                               Writer output)
                        throws IOException,
                               DOMException

  Convert XML to delimited text.

  Parameters:
    `doc` - DOM document to convert
    `output` - delimited text Writer
  Throws:
    `IOException` - thrown if an error occurs writing to `output`
    `DOMException` - thrown if an error occurs accessing the XML

### convertFromXML

    public void convertFromXML(Document doc,
                               BufferedWriter output)
                        throws IOException,
                               DOMException

  Convert XML to delimited text.

  Parameters:
    `doc` - DOM document to convert
    `output` - delimited text `BufferedWriter`
  Throws:
    `IOException` - thrown if an error occurs writing to `output`
    `DOMException` - thrown if an error occurs accessing the XML

### writeRecord

    protected void writeRecord(Element record,
                               BufferedWriter output)
                        throws IOException,
                               DOMException

  Write a delimited text record.

  Parameters:
    `record` - DOM record element
    `output` - delimited text `BufferedWriter`
  Throws:
    `IOException` - thrown if an error occurs writing to `output`
    `DOMException` - thrown if an error occurs accessing the XML

### writeField

    protected void writeField(Element field,
                              BufferedWriter output)
                       throws IOException,
                              DOMException

  Write a delimited text field.

  Parameters:
    `field` - DOM field element
    `output` - delimited text `BufferedWriter`
  Throws:
    `IOException` - thrown if an error occurs writing to `output`
    `DOMException` - thrown if an error occurs accessing the XML

### quoteIfNeeded

    protected String quoteIfNeeded(String string)

  Quote a delimited text field of it contains special characters.

  Parameters:
    `string` - value to quote
  Returns:
    quoted string if quoting needed, original string otherwise

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD