|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.novell.nds.dirxml.driver.DelimitedText
public class DelimitedText
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 |
|---|
public static final char FIELD_DELIMITER_COMMA
',') delimiter.
public static final char FIELD_DELIMITER_TAB
'\t') delimiter.
public static final char FIELD_DELIMITER_DEFAULT
FIELD_DELIMITER_COMMA).
public static final char FIELD_QUOTE
'"').
public static final String ROOT_ELEMENT
public static final String HEADER_ELEMENT
public static final String FIELD_NAME_ELEMENT
public static final String RECORD_ELEMENT
public static final String FIELD_ELEMENT
public static final String FIELD_NAME_ATTR
protected char fieldDelimiter
protected String[] columnNames
protected boolean hasHeaderRow
| Constructor Detail |
|---|
public DelimitedText()
DelimitedText instance with defaults.
public DelimitedText(char inFieldDelimiter)
DelimitedText instance with a custom field delimiter character.
inFieldDelimiter - the field delimiter character
public DelimitedText(char inFieldDelimiter,
boolean inHasHeaderRow)
DelimitedText instance with a custom field delimiter character.
inFieldDelimiter - the field delimiter characterinHasHeaderRow - true if input/output delimited text file has a header row
public DelimitedText(char inFieldDelimiter,
String[] inColumnNames)
DelimitedText instance with a custom field delimiter character.
inFieldDelimiter - the field delimiter characterinColumnNames - list of column names to use on input| Method Detail |
|---|
public Document convertToXML(String fileName)
throws IOException,
DOMException
fileName - name of delimited text file
IOException - thrown if an error reading the file occurs
DOMException - thrown if an error constructing the XML representaton occurs
public Document convertToXML(InputStream input)
throws IOException,
DOMException
input - InputStream containing delimited text
IOException - thrown if an error reading the file occurs
DOMException - thrown if an error constructing the XML representaton occurs
public Document convertToXML(Reader input)
throws IOException,
DOMException
input - Reader containing delimited text
IOException - thrown if an error reading the file occurs
DOMException - thrown if an error constructing the XML representaton occurs
public Document convertToXML(BufferedReader input)
throws IOException,
DOMException
input - BufferedReader containing delimited text
IOException - thrown if an error reading the file occurs
DOMException - thrown if an error constructing the XML representaton occurs
protected String[] readRecord(BufferedReader input)
throws IOException
input - BufferedReader positioned at beginning of delimited text record
IOException - thrown if an error occurs reading from input.
public void convertFromXML(Document doc,
String fileName)
throws IOException,
DOMException
doc - DOM document to convertfileName - name of output delimited text file
IOException - thrown if an error occurs writing to the file
DOMException - thrown if an error occurs accessing the XML
public void convertFromXML(Document doc,
OutputStream output)
throws IOException,
DOMException
doc - DOM document to convertoutput - delimited text OutputStream
IOException - thrown if an error occurs writing to output
DOMException - thrown if an error occurs accessing the XML
public void convertFromXML(Document doc,
Writer output)
throws IOException,
DOMException
doc - DOM document to convertoutput - delimited text Writer
IOException - thrown if an error occurs writing to output
DOMException - thrown if an error occurs accessing the XML
public void convertFromXML(Document doc,
BufferedWriter output)
throws IOException,
DOMException
doc - DOM document to convertoutput - delimited text BufferedWriter
IOException - thrown if an error occurs writing to output
DOMException - thrown if an error occurs accessing the XML
protected void writeRecord(Element record,
BufferedWriter output)
throws IOException,
DOMException
record - DOM record elementoutput - delimited text BufferedWriter
IOException - thrown if an error occurs writing to output
DOMException - thrown if an error occurs accessing the XML
protected void writeField(Element field,
BufferedWriter output)
throws IOException,
DOMException
field - DOM field elementoutput - delimited text BufferedWriter
IOException - thrown if an error occurs writing to output
DOMException - thrown if an error occurs accessing the XMLprotected String quoteIfNeeded(String string)
string - value to quote
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||