org.relique.jdbc.csv
Class CsvWriter

java.lang.Object
  |
  +--org.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.

Version:
$Id: CsvReader.java,v 1.9 2002/09/04 17:03:23 mmaraya Exp $
Author:
Jonathan Ackerman
, Sander Brienen , Stuart Mottram (fritto) , Jason Bedell

Field Summary
private  java.lang.String buf
           
private  java.lang.String[] columnNames
           
private  java.lang.String[] columns
           
private  int counter
           
private  long current
           
private  long endLine
           
private  java.lang.String fileName
           
private  java.io.RandomAccessFile input
           
private  java.io.RandomAccessFile output
           
private  char separator
           
private  java.lang.String tableName
           
 
Constructor Summary
CsvWriter(java.lang.String fileName)
          Constructor for the CsvReader object
CsvWriter(java.lang.String fileName, char separator)
          Insert the method's description here.
 
Method Summary
 void close()
          Description of the Method
protected  boolean createTable(java.lang.String[] colNames, java.lang.String table)
           
 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()
          Description of the Method
protected  java.lang.String[] parseCsvLine(java.lang.String line)
           
protected  boolean updateField(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
 

Field Detail

input

private java.io.RandomAccessFile input

output

private java.io.RandomAccessFile output

columnNames

private java.lang.String[] columnNames

columns

private java.lang.String[] columns

buf

private java.lang.String buf

separator

private char separator

tableName

private java.lang.String tableName

fileName

private java.lang.String fileName

counter

private int counter

current

private long current

endLine

private long endLine
Constructor Detail

CsvWriter

public CsvWriter(java.lang.String fileName)
          throws java.lang.Exception
Constructor for the CsvReader object

Parameters:
fileName - Description of Parameter
Throws:
java.lang.Exception - Description of Exception
Since:

CsvWriter

public CsvWriter(java.lang.String fileName,
                 char separator)
          throws java.lang.Exception
Insert the method's description here. Creation date: (6-11-2001 15:02:42)

Parameters:
fileName - java.lang.String
separator - char
Throws:
java.lang.Exception - The exception description.
Since:
Method Detail

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
Description of the Method

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

close

public void close()
Description of the Method

Since:

parseCsvLine

protected java.lang.String[] parseCsvLine(java.lang.String line)
                                   throws java.sql.SQLException
java.sql.SQLException

newLine

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

createTable

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

updateField

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


Check out http://csvjdbc.sourceforge.net for more info.