QJCC homepage

biz.chitec.quarterback.util
Class CSVHandler

java.lang.Object
  extended bybiz.chitec.quarterback.util.CSVHandler
Direct Known Subclasses:
CSVReader, CSVWriter

public abstract class CSVHandler
extends java.lang.Object

Base for CSV reading and writing. This class encapsulates data structures which are needed for reading and writing CSV files. This includes

This class keeps these information only container-like. The readl reading and writing subclasses have to handle the data appropriately.

Version:
$Id: d61b0a44c53623b10ef0993a24969a656ace8fa6 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000-2003, cantamen/Dirk Hillbrecht 2003-2005. Distributed under the terms of the GNU LGPL .
See Also:
CSVReader, CSVWriter

Field Summary
static java.lang.Integer BOOL
           
protected  int coding
           
protected  char columnseparator
           
static java.lang.Integer DATE
           
protected  char decimalseparator
           
static java.lang.Integer FLOAT
           
protected static int iBOOL
           
protected static int iDATE
           
protected static int iFLOAT
           
protected static int iINT
           
protected static int iMEMSTRINT
           
static java.lang.Integer INT
           
protected static int iSTRING
           
protected static int iSTRINT
           
static java.lang.Integer MEMSTRINT
           
protected  boolean saveescaping
           
static java.lang.Integer STRING
           
static java.lang.Integer STRINT
           
 
Constructor Summary
CSVHandler()
          public constructor
 
Method Summary
 char getColumnSeparator()
           
 char getDecimalSeparator()
           
 boolean isSaveEscaping()
           
protected abstract  void putInValueType(java.lang.String key, java.util.Map h)
           
 void removeKeyValue(java.lang.String key)
          remove one key definition
abstract  void removeKeyValues()
          removes all key definitions (e.g. to reuse the CSVReader for a new table)
protected abstract  void removeValueType(java.lang.String key)
           
 void setCoding(int cdx)
          set a character conversion coding
 void setColumnSeparator(char columnseparatorx)
           
 void setDecimalSeparator(char decimalseparatorx)
           
 void setKeyValues(java.lang.String key, java.lang.Integer type)
          convenience method that sets forcetonull to false and defaultvalue to null
 void setKeyValues(java.lang.String key, java.lang.Integer type, java.lang.Object defaultvalue)
          convenience method that sets the forcetonull-flag to false
 void setKeyValues(java.lang.String key, java.lang.Integer type, java.lang.Object defaultvalue, boolean forcetonull)
          sets values for a column.
 void setSaveEscaping(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iINT

protected static final int iINT
See Also:
Constant Field Values

iFLOAT

protected static final int iFLOAT
See Also:
Constant Field Values

iSTRING

protected static final int iSTRING
See Also:
Constant Field Values

iDATE

protected static final int iDATE
See Also:
Constant Field Values

iSTRINT

protected static final int iSTRINT
See Also:
Constant Field Values

iBOOL

protected static final int iBOOL
See Also:
Constant Field Values

iMEMSTRINT

protected static final int iMEMSTRINT
See Also:
Constant Field Values

INT

public static final java.lang.Integer INT

FLOAT

public static final java.lang.Integer FLOAT

STRING

public static final java.lang.Integer STRING

DATE

public static final java.lang.Integer DATE

STRINT

public static final java.lang.Integer STRINT

BOOL

public static final java.lang.Integer BOOL

MEMSTRINT

public static final java.lang.Integer MEMSTRINT

columnseparator

protected char columnseparator

decimalseparator

protected char decimalseparator

coding

protected int coding

saveescaping

protected boolean saveescaping
Constructor Detail

CSVHandler

public CSVHandler()
public constructor

Method Detail

putInValueType

protected abstract void putInValueType(java.lang.String key,
                                       java.util.Map h)

removeValueType

protected abstract void removeValueType(java.lang.String key)

setKeyValues

public void setKeyValues(java.lang.String key,
                         java.lang.Integer type,
                         java.lang.Object defaultvalue,
                         boolean forcetonull)
sets values for a column. For each column of the table that should be put into the output, this routine must be called once before the table is actually opened and parsed.

Parameters:
key - The name of the column as in Map and original table
type - The type of this column. One of the type specifiers as of the constants of this class.
defaultvalue - A default value for this columm in case that no value is given in the CSV table. The default value is taken if the column does not occur in the CSV table or the column is empty.
forcetonull - Flag for indication of handling of rows where this column is empty. When set to false (default) this column is not put into the created Map. When set to true, the key is put into the new Map, and is bound to a Null object.

setKeyValues

public void setKeyValues(java.lang.String key,
                         java.lang.Integer type,
                         java.lang.Object defaultvalue)
convenience method that sets the forcetonull-flag to false


setKeyValues

public void setKeyValues(java.lang.String key,
                         java.lang.Integer type)
convenience method that sets forcetonull to false and defaultvalue to null


removeKeyValue

public void removeKeyValue(java.lang.String key)
remove one key definition


removeKeyValues

public abstract void removeKeyValues()
removes all key definitions (e.g. to reuse the CSVReader for a new table)


setCoding

public void setCoding(int cdx)
set a character conversion coding


setColumnSeparator

public void setColumnSeparator(char columnseparatorx)

getColumnSeparator

public char getColumnSeparator()

setDecimalSeparator

public void setDecimalSeparator(char decimalseparatorx)

getDecimalSeparator

public char getDecimalSeparator()

setSaveEscaping

public void setSaveEscaping(boolean b)

isSaveEscaping

public boolean isSaveEscaping()

QJCC homepage