|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.util.CSVHandler biz.chitec.quarterback.util.CSVReader
Reads CSV data in and transforms them into a vector of hashtables After instantiation, a CSVReader should be given all fields of the table that have to be recognized. Then, the data stream should be opened. This could happen in two ways:
CSVHandler
,
CSVWriter
Field Summary | |
private java.io.BufferedReader |
br
|
protected java.lang.String[] |
column
|
private int |
defaulttype
|
private java.lang.String |
nextline
|
protected java.util.Map |
valuetype
|
Fields inherited from class biz.chitec.quarterback.util.CSVHandler |
BOOL, coding, columnseparator, DATE, decimalseparator, FLOAT, iBOOL, iDATE, iFLOAT, iINT, iMEMSTRINT, INT, iSTRING, iSTRINT, MEMSTRINT, saveescaping, STRING, STRINT |
Constructor Summary | |
CSVReader()
Initializes the reader with a column separator char of ';' |
|
CSVReader(char xsep)
Initializes the reader. |
Method Summary | |
private java.lang.String |
cropQuotes(java.lang.String s)
|
java.util.List |
getColumnList()
Returns the recognized columns as list preserving their order in the CSV file |
java.util.Map |
getNextLine()
returns the next line of the table as a hashtable. |
boolean |
hasMoreLines()
returns whether there are more lines in the table |
java.util.Map |
interpret(java.lang.String nextline)
Interpret one line of the CSV table |
private void |
interpretHeader(java.lang.String headerx)
|
private boolean |
lineHasOnlySeparators()
|
private boolean |
lineIsContinuing(java.lang.String theline)
|
static java.lang.Boolean |
makeBool(java.lang.String elem)
|
static EDate |
makeDate(java.lang.String elem)
|
static java.lang.Double |
makeFloat(java.lang.String elem)
|
static java.lang.Integer |
makeInteger(java.lang.String elem)
makes an Integer object out of a line portion which represents an Integer |
static java.lang.String |
makeString(java.lang.String elem,
boolean saveescaping)
makes a string object out of a line portion which represents a string |
static java.lang.Object |
makeStrint(java.lang.String elem)
|
protected void |
putInValueType(java.lang.String key,
java.util.Map h)
|
private java.lang.String |
readLine()
reads a line internally. |
private void |
readNextLine()
|
void |
removeKeyValues()
removes all key definitions (e.g. to reuse the CSVReader for a new table) |
protected void |
removeValueType(java.lang.String key)
|
void |
setDefaultType(java.lang.Integer typex)
|
void |
setHeader(java.lang.String headerx)
Sets and initializes the CSV header line for interpretation of strings. |
void |
setInputStream(java.io.InputStream is)
Sets and initializes the input stream which contains the CSV header in the first line. |
void |
setInputStream(java.io.InputStream is,
boolean interpretheader)
Sets and initializes the given input stream. |
protected java.util.List |
splitLine(java.lang.String line)
splits a line at its semicolons. |
Methods inherited from class biz.chitec.quarterback.util.CSVHandler |
getColumnSeparator, getDecimalSeparator, isSaveEscaping, removeKeyValue, setCoding, setColumnSeparator, setDecimalSeparator, setKeyValues, setKeyValues, setKeyValues, setSaveEscaping |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Map valuetype
private java.io.BufferedReader br
protected java.lang.String[] column
private java.lang.String nextline
private int defaulttype
Constructor Detail |
public CSVReader(char xsep)
xsep
- column separator char.public CSVReader()
Method Detail |
public void setDefaultType(java.lang.Integer typex)
protected void putInValueType(java.lang.String key, java.util.Map h)
putInValueType
in class CSVHandler
protected void removeValueType(java.lang.String key)
removeValueType
in class CSVHandler
public void removeKeyValues()
CSVHandler
removeKeyValues
in class CSVHandler
public void setInputStream(java.io.InputStream is, boolean interpretheader) throws java.io.IOException
setHeader(String)
must have
been called before with the header definition and false has to be passed as
interpretheader parameter. After the header, every line contains exactly
one row of the table. The CSVReader reads always one line ahead its
currently computed and delivered line.
is
- InputStream to read the CSV table frominterpretheader
- Flag whether the first line really contains the header of the CSV
table. If false, setHeader(String)
must have been called
explicitly.
java.io.IOException
public void setInputStream(java.io.InputStream is) throws java.io.IOException
is
- Stream to read the CSV file from.
java.io.IOException
public void setHeader(java.lang.String headerx)
private void interpretHeader(java.lang.String headerx)
public java.util.List getColumnList()
public boolean hasMoreLines()
private boolean lineHasOnlySeparators()
private void readNextLine() throws java.io.IOException
java.io.IOException
public java.util.Map getNextLine() throws java.io.IOException
In case that there are no more lines in the table, null is delivered.
java.io.IOException
public java.util.Map interpret(java.lang.String nextline)
private boolean lineIsContinuing(java.lang.String theline)
private java.lang.String readLine() throws java.io.IOException
java.io.IOException
protected java.util.List splitLine(java.lang.String line)
private java.lang.String cropQuotes(java.lang.String s)
public static java.lang.String makeString(java.lang.String elem, boolean saveescaping)
public static java.lang.Integer makeInteger(java.lang.String elem)
public static java.lang.Double makeFloat(java.lang.String elem)
public static java.lang.Object makeStrint(java.lang.String elem)
public static java.lang.Boolean makeBool(java.lang.String elem)
public static EDate makeDate(java.lang.String elem)
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |