A JSCSVDocument class to hold a CSV delimited document for use.
Each "cell" in the record will be a double-quoted String, escaped if necessary.
elementAt
protected JSCSVCell elementAt(int row,
int col)
throws ArrayIndexOutOfBoundsExceptionGet a JSCSVCell object at the row,col given.
row - Row number (index starts at 0) to insert the cell.col - Column number (index starts at 0) to insert the cell.
- cell JSCSVCell type value to insert into the document.
escape
public String escape(String in)
Escapes any html characters in the input string.
in - String value to replace escape values for.
- String value of escaped input string
escape
public String escape(byte in)
Escapes any html characters in the input byte.
in - byte value to replace escape values for.
- String value of escaped input byte.
escape
public String escape(char in)
Escapes any html characters in the input char.
in - char value to replace escape values for.
- String value of escaped input char array
escape
public String escape(double in)
Escapes any html characters in the input double value.
in - double value to replace escape values for.
- String value of escaped input double value.
escape
public String escape(float in)
Escapes any html characters in the input float value.
in - float value to replace escape values for.
- String value of escaped input float value.
escape
public String[] escape(in[] )
Escapes any html characters in the input byte array.
- String[] Array value of escaped input byte array
escape
public String[] escape(in[] )
Escapes any html characters in the input char array.
- String[] Array value of escaped input char array
escape
public String[] escape(in[] )
Escapes any html characters in the input int array.
- String[] Array value of escaped input int array
escape
public String[] escape(in[] )
Escapes any html characters in the input long array.
- String[] Array value of escaped input long array
escape
public String[] escape(in[] )
Escapes any html characters in the input float array value.
- String[] value of escaped input float array value.
escape
public String[] escape(in[] )
Escapes any html characters in the input double array value.
- String[] Array value of escaped input double array value.
escape
public String escape(int in)
Escapes any html characters in the input int.
in - int value to replace escape values for.
- String value of escaped input int.
escape
public String escape(long in)
Escapes any html characters in the input long value.
in - long value to replace escape values for.
- String value of escaped input long value.
getCell
public JSCSVCell getCell(int row,
int col)Retrieve the JSCSVCell object from the given row and column.
row - Row number of the desired cell.col - Column number of the desired cell.
- JSCSVCell JSCSVCell object at the given row and column.
getDocument
public Vector getDocument()
Getter for property document.
- Vector value of property document.
getHeaderrows
public int getHeaderrows()
Getter for property headerrows.
- Number of header rows included.
getReader
public java.io.BufferedReader getReader()
Getter for property reader.
- Value of property reader.
getRowNo
public int getRowNo(int recordno)
Get current internal Row number taken from given record number plus the number of header rows.
- Number of the given record's row in the document.
getSeparator
public java.lang.String getSeparator()
Getter for property separator which separates the columns in each row in the document.
- Value of property separator.
getValue
public String getValue(int row,
int col)Retrieve the String value from the JSCSVCell at the given row and column.
row - Row number of the desired cell.col - Column number of the desired cell.
- String String value of the contents of the JSCSVCell object at the given row and column.
isShowtitles
public boolean isShowtitles()
Get boolean value showing whether the titles should be shown in the output document or not.
- Value of property showtitles.
parse
protected void parse()
throws java.io.IOExceptionParse the document and insert elements as needed.
parse
public void parse(BufferedReader input)
throws java.io.IOExceptionParse the document from the input BufferedReader stream and insert elements as needed.
input - BufferedReader stream to be parsed.
parse
public void parse(File input)
throws java.io.FileNotFoundException,
java.io.IOExceptionParse the document from the input java.io.File and insert elements as needed.
input - File object to be parsed.
parse
public void parse(InputStreamReader input)
throws java.io.IOExceptionParse a CSV style document from the input InputStreamReader stream and insert elements as needed.
input - InputStreamReader stream to be parsed.
parseRow
protected void parseRow(String line)
Parse the data values for the next row. This gives the values of the
various columns.
line - String value of the row values separated by commas.
parseTitleRow
protected void parseTitleRow(String line)
Parse the titles for the TITLE_ROW row of the document. This gives the titles of the
various columns for the document.
line - String value of the TITLE_ROW.
parseTypeRow
protected void parseTypeRow(String line)
Parse the data types from the DATATYPE_ROW row String given. This gives the types of the
various columns (assuming the columns' values are the same type) and allows
proper parsing of the cell values.
line - String value of the DATATYPE_ROW.
readBooleanCell
public boolean readBooleanCell(JSCSVCell node)
Get boolean value of node JSCSVCell object.
node - JSCSVCell to get value from.
readByteArrayCell
public byte[] readByteArrayCell(JSCSVCell node)
Get byte array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readByteCell
public byte readByteCell(JSCSVCell node)
Get byte value of node JSCSVCell object.
node - JSCSVCell to get value from.
readCalendarCell
public GregorianCalendar readCalendarCell(JSCSVCell node)
throws java.text.ParseExceptionGet GregorianCalendar value of node JSCSVCell object.
node - JSCSVCell to get value from.
readCharArrayCell
public char[] readCharArrayCell(JSCSVCell node)
Get char array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readCharCell
public char readCharCell(JSCSVCell node)
Get char value of node JSCSVCell object.
node - JSCSVCell to get value from.
readDocument
public void readDocument(InputStreamReader inputfile)
throws java.io.IOExceptionRead and parse the contents from an InputStreamReader stream.
inputfile - InputStreamReader stream to parse the document contents from.
readDoubleArrayCell
public double[] readDoubleArrayCell(JSCSVCell node)
Get double array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readDoubleCell
public double readDoubleCell(JSCSVCell node)
Get double value of node JSCSVCell object.
node - JSCSVCell to get value from.
readFloatArrayCell
public float[] readFloatArrayCell(JSCSVCell node)
Get float array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readFloatCell
public float readFloatCell(JSCSVCell node)
Get float value of node JSCSVCell object.
node - JSCSVCell to get value from.
readIntArrayCell
public int[] readIntArrayCell(JSCSVCell node)
Get int array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readIntCell
public int readIntCell(JSCSVCell node)
Get int value of node JSCSVCell object.
node - JSCSVCell to get value from.
readLongArrayCell
public long[] readLongArrayCell(JSCSVCell node)
Get long array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readLongCell
public long readLongCell(JSCSVCell node)
Get long value of node JSCSVCell object.
node - JSCSVCell to get value from.
readStringArrayCell
public String[] readStringArrayCell(JSCSVCell node)
Get String array value of node JSCSVCell object.
node - JSCSVCell to get value from.
readStringCell
public String readStringCell(JSCSVCell node)
Get String value of node JSCSVCell object.
node - JSCSVCell to get value from.
setDocument
public void setDocument(Vector document)
Setter for property document.
document - New Vector value of property document contents.
setElementAt
protected void setElementAt(JSCSVCell cell,
String title,
int row,
int col)Set a JSCSVCell object at the row,col given with the given title String.
cell - JSCSVCell type value to insert into the document.title - String value of title row for this column.row - Row number (index starts at 0) to insert the cell.col - Column number (index starts at 0) to insert the cell.
setElementAt
protected void setElementAt(JSCSVCell cell,
int row,
int col)Set a JSCSVCell object at the row,col given.
cell - JSCSVCell type value to insert into the document.row - Row number (index starts at 0) to insert the cell.col - Column number (index starts at 0) to insert the cell.
setHeaderrows
public void setHeaderrows()
Setter for property headerrows.
setReader
public void setReader(java.io.BufferedReader reader)
Setter for property reader.
reader - New value of property reader.
setReader
public void setReader(java.io.File file)
throws java.io.FileNotFoundExceptionSetter for property reader from java.io.File instance.
file - New value of property reader.
setReader
public void setReader(java.io.InputStreamReader reader)
Setter for property reader.
reader - New value of property reader.
setSeparator
public void setSeparator(java.lang.String separator)
Setter for property separator which separates the columns in each row in the document.
separator - New value of property separator.
setShowtitles
public void setShowtitles(boolean showtitles)
Setter for property showtitles with boolean value showing whether the
titles should be shown in the output document or not.
showtitles - New value of property showtitles.
writeDataRow
public void writeDataRow(BufferedWriter outputfile,
int row)
throws java.io.IOExceptionWrite the document row at the given index row to the given BufferedWriter stream.
outputfile - BufferedWriter to output the document to.
writeDocument
public void writeDocument(BufferedWriter outputfile)
throws java.io.IOExceptionWrite the current document to the given BufferedWriter stream.
outputfile - BufferedWriter to output the document to.
writeDocument
public void writeDocument(OutputStreamWriter outputfile)
throws java.io.IOExceptionWrite the current document to the given OutputStreamWriter stream.
outputfile - OutputStreamWriter to output the document to.