|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.melati.poem.csv.CSVTable
public class CSVTable
A representation of a CSV file as a POEM Table.
Field Summary | |
---|---|
protected Hashtable |
columns
|
protected Vector |
columnsInUploadOrder
|
protected File |
data
|
protected CSVFileParser |
parser
|
protected CSVColumn |
primaryKey
|
protected BufferedReader |
reader
|
protected Vector |
records
|
protected Table |
table
|
Constructor Summary | |
---|---|
CSVTable(Table table,
File data)
Constructor. |
Method Summary | |
---|---|
void |
addColumn(String csvName,
String poemName)
Add column definitions to this table. |
void |
addColumn(String csvName,
String poemName,
boolean isPrimaryKey)
Add column definitions, perhaps Primary Keys, to this table. |
void |
addColumn(String csvName,
String foreignPoemName,
CSVTable foreignTable)
Add column definitions for foreign keys to this table. |
void |
define()
Process the first line to define columns. |
void |
emptyTable()
Delete all Persistents from the Poem table. |
String |
getName()
Used in debugging to display name of table being emptied. |
protected Persistent |
getRecordWithID(String csvValue)
Lookup the Persistent corresponding to the CSV record with the given value for the CSV table's primary key. |
void |
load(boolean writeOnFly)
Parse the CSV data file and store the data for saving later. |
CSVRecord |
parseRecord()
Reads the file until is has seen an object's-worth of field values (ie until it sees an EOF or a line starting with '$') which it returns in a hashtable (null if there are no field values). |
void |
report(boolean recordDetails,
boolean fieldDetails,
Writer output)
Return a string reporting on the data added to this table. |
void |
writeRecords()
Write the records to the database, called if we are not writing each record to db as we go. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Table table
protected File data
protected Hashtable columns
protected Vector columnsInUploadOrder
protected CSVColumn primaryKey
protected Vector records
protected BufferedReader reader
protected CSVFileParser parser
Constructor Detail |
---|
public CSVTable(Table table, File data)
table
- POEM table to load data intodata
- CSV file to read fromMethod Detail |
---|
public void define() throws IOException
IOException
public void addColumn(String csvName, String poemName)
public void addColumn(String csvName, String poemName, boolean isPrimaryKey) throws CSVPrimaryKeyColumnAlreadySetException
CSVPrimaryKeyColumnAlreadySetException
public void addColumn(String csvName, String foreignPoemName, CSVTable foreignTable)
public void load(boolean writeOnFly) throws IOException, CSVParseException, NoPrimaryKeyInCSVTableException, CSVWriteDownException
writeOnFly
- whether to commit each line to db as we go
IOException
- if there is a file system problem
CSVParseException
- if the is a malformed field in the CSV
CSVWriteDownException
NoPrimaryKeyInCSVTableException
public CSVRecord parseRecord() throws IOException, CSVParseException
IOException
- if there is a problem with the file system
CSVParseException
- if there is a problem parsing the inputpublic void emptyTable()
public void writeRecords() throws NoPrimaryKeyInCSVTableException, CSVWriteDownException
NoPrimaryKeyInCSVTableException
CSVWriteDownException
protected Persistent getRecordWithID(String csvValue) throws NoPrimaryKeyInCSVTableException, CSVWriteDownException
NoPrimaryKeyInCSVTableException
CSVWriteDownException
public void report(boolean recordDetails, boolean fieldDetails, Writer output) throws IOException
IOException
public String getName()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |