org.relique.jdbc.csv
Class CsvReader

java.lang.Object
  extended by org.relique.jdbc.csv.CsvReader

public class CsvReader
extends java.lang.Object

This class is a helper class that handles the reading and parsing of data from a .csv file.

Author:
Zoran Milakovic

Constructor Summary
CsvReader(java.lang.String fileName, char separator, boolean suppressHeaders, java.lang.String charset, java.lang.String extension, java.lang.String lineBreakEscape, java.lang.String carriageReturnEscape, boolean trimString)
           
 
Method Summary
 void close()
          Description of the Method
 java.lang.String getColumn(int columnIndex)
          Get the value of the column at the specified index.
 java.lang.String getColumn(java.lang.String columnName)
          Get value from column at specified name.
 java.lang.String[] getColumnNames()
          Gets the columnNames attribute of the CsvReader object
 java.util.Map getColumnTypes()
           
 java.lang.String getTableName()
           
 boolean next()
          Description of the Method
protected  java.lang.String[] parseCsvLine(java.lang.String line)
          Parse csv line with columnTypes.
protected  java.lang.String[] parseCsvLineAsHeader(java.lang.String line)
          Parse csv line, whithout columnTypes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvReader

public CsvReader(java.lang.String fileName,
                 char separator,
                 boolean suppressHeaders,
                 java.lang.String charset,
                 java.lang.String extension,
                 java.lang.String lineBreakEscape,
                 java.lang.String carriageReturnEscape,
                 boolean trimString)
          throws java.lang.Exception
Parameters:
fileName -
separator -
suppressHeaders -
charset -
extension -
Throws:
java.lang.Exception
Method Detail

getColumnNames

public java.lang.String[] getColumnNames()
Gets the columnNames attribute of the CsvReader object

Returns:
The columnNames value

getColumnTypes

public java.util.Map getColumnTypes()
Returns:
array with column types

getTableName

public java.lang.String getTableName()

getColumn

public java.lang.String getColumn(int columnIndex)
                           throws java.sql.SQLException
Get the value of the column at the specified index.

Parameters:
columnIndex - Description of Parameter
Returns:
The column value
Throws:
java.sql.SQLException
Since:

getColumn

public java.lang.String getColumn(java.lang.String columnName)
                           throws java.sql.SQLException
Get value from column at specified name. If the column name is not found, throw an error.

Parameters:
columnName - Description of Parameter
Returns:
The column value
Throws:
java.sql.SQLException - Description of Exception
Since:

next

public boolean next()
             throws java.sql.SQLException
Description of the Method

Returns:
Description of the Returned Value
Throws:
java.sql.SQLException - Description of Exception
Since:

close

public void close()
Description of the Method

Since:

parseCsvLine

protected java.lang.String[] parseCsvLine(java.lang.String line)
                                   throws java.sql.SQLException
Parse csv line with columnTypes.

Parameters:
line -
Returns:
array with values or column names.
Throws:
java.sql.SQLException

parseCsvLineAsHeader

protected java.lang.String[] parseCsvLineAsHeader(java.lang.String line)
                                           throws java.sql.SQLException
Parse csv line, whithout columnTypes.

Parameters:
line -
Returns:
array with values or column names.
Throws:
java.sql.SQLException


Copyright © 2002-2007 Together - the Workgroup. All Rights Reserved.