org.relique.jdbc.csv
Class CsvWriter

java.lang.Object
  extended byorg.relique.jdbc.csv.CsvWriter

public class CsvWriter
extends java.lang.Object

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

Author:
Sinisa Milosevic, Zoran Milakovic

Constructor Summary
CsvWriter(java.lang.String fileName, char separator, java.lang.String extension, long maxFileSize, java.lang.String charset, boolean useQuotes, boolean useQuotesEscape)
          Used with statement.
 
Method Summary
 void close()
          Description of the Method
protected  boolean createExtTable(java.lang.String[] colNames, java.lang.String[] colTypes, java.lang.String table)
           
protected  boolean createTable(java.lang.String[] colNames, java.lang.String table)
           
 void fillTableColumnNames()
           
 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.lang.String getTableName()
           
protected  boolean newLine(java.lang.String[] colNames, java.lang.String[] colValues)
           
 boolean next()
           
protected  java.lang.String[] parseCsvLine(java.lang.String line)
           
protected  java.lang.String[] parseCsvLineAsHeader(java.lang.String line)
           
 void setFileName(java.lang.String name)
          When use split files, this is used when file name is changed.
protected  boolean updateFields(java.lang.String[] colNames, java.lang.String[] colValues, java.lang.String[] colWhereNames, java.lang.String[] colWhereValues)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvWriter

public CsvWriter(java.lang.String fileName,
                 char separator,
                 java.lang.String extension,
                 long maxFileSize,
                 java.lang.String charset,
                 boolean useQuotes,
                 boolean useQuotesEscape)
          throws java.lang.Exception
Used with statement.

Parameters:
fileName -
separator -
extension -
maxFileSize -
Throws:
java.lang.Exception
Method Detail

setFileName

public void setFileName(java.lang.String name)
                 throws java.lang.Exception
When use split files, this is used when file name is changed.

Parameters:
name -
Throws:
java.lang.Exception

fillTableColumnNames

public void fillTableColumnNames()
                          throws java.lang.Exception
Throws:
java.lang.Exception

getColumnNames

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

Returns:
The columnNames value
Since:

getTableName

public java.lang.String getTableName()

getColumn

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

Parameters:
columnIndex - Description of Parameter
Returns:
The column value
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,
                    java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

close

public void close()
Description of the Method

Since:

parseCsvLine

protected java.lang.String[] parseCsvLine(java.lang.String line)
                                   throws java.sql.SQLException
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
Parameters:
line -
Returns:
array with values or column names.
Throws:
java.sql.SQLException

newLine

protected boolean newLine(java.lang.String[] colNames,
                          java.lang.String[] colValues)
                   throws java.io.IOException
Throws:
java.io.IOException

createTable

protected boolean createTable(java.lang.String[] colNames,
                              java.lang.String table)
                       throws java.io.IOException
Throws:
java.io.IOException

createExtTable

protected boolean createExtTable(java.lang.String[] colNames,
                                 java.lang.String[] colTypes,
                                 java.lang.String table)
                          throws java.io.IOException
Throws:
java.io.IOException

updateFields

protected boolean updateFields(java.lang.String[] colNames,
                               java.lang.String[] colValues,
                               java.lang.String[] colWhereNames,
                               java.lang.String[] colWhereValues)
                        throws java.io.IOException,
                               java.sql.SQLException
Throws:
java.io.IOException
java.sql.SQLException


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