net.sf.flatpack
Class DefaultDataSet

java.lang.Object
  extended by net.sf.flatpack.DefaultDataSet
All Implemented Interfaces:
DataSet
Direct Known Subclasses:
BuffReaderDataSet

public class DefaultDataSet
extends java.lang.Object
implements DataSet

Author:
Benoit Xhenseval, Paul Zepernick

Constructor Summary
DefaultDataSet(MetaData pzMetaData, Parser pzparser)
           
 
Method Summary
 void absolute(int localPointer)
          Sets the absolute position of the record pointer
 void addError(DataError dataError)
           
 void addRow(Row row)
           
 void clearAll()
          Clears both the errors and rows from memory
 void clearErrors()
          Clears out the parse errors from memory
 void clearRows()
          Clears out the rows in memory from the last parse.
 boolean contains(java.lang.String column)
          Does this DataSet contain a column with the given name?
 java.math.BigDecimal getBigDecimal(java.lang.String column)
          Returns the BigDecimal value of a specified column
 java.lang.String[] getColumns()
          Returns a String array of column names in the DataSet.
 java.lang.String[] getColumns(java.lang.String recordID)
          Returns a String array of column names in the DataSet for a given id
 java.util.Date getDate(java.lang.String column)
          Returns the date value of a specified column.
 java.util.Date getDate(java.lang.String column, java.text.SimpleDateFormat sdf)
          Returns the date value of a specified column.
 double getDouble(java.lang.String column)
          Returns the double value of a specified column
 int getErrorCount()
          Returns total number of records which contained a parse error in the file.
 java.util.List getErrors()
          Returns A Collection Of DataErrors that happened during processing
 int getIndex()
          Returns the index the pointer is on for the array
 int getInt(java.lang.String column)
          Returns the interger value of a specified column
 long getLong(java.lang.String column)
          Returns the long value of a specified column
 MetaData getMetaData()
           
 java.lang.Object getObject(java.lang.String column, java.lang.Class classToConvertTo)
          Returns the value of the column with the type of object specified
 java.lang.String getRawData()
           
 int getRowCount()
          Returns the total number of rows parsed in from the file
 int getRowNo()
          Returns the line number the pointer is on.
 java.lang.String getString(java.lang.String column)
          Returns the string value of a specified column
 void goBottom()
          Goes to the last record in the dataset
 void goTop()
          Goes to the top of the data set.
 boolean isAnError(int lineNo)
          Returns true or false as to whether or not the line number contains an error.
 boolean isRecordID(java.lang.String recordID)
          Checks to see if the row has the given id
 boolean isRowEmpty()
          Checks to see if there was no data on the row which was parsed.
 boolean next()
          Moves to the next record in the set.
 void orderRows(OrderBy ob)
          Orders the data by column(s) specified.
 boolean previous()
          Moves back to the previous record in the set return true if move was a success, false if not
 void remove()
          Removes a row from the dataset.
 void setLowerCase()
          Sets data in the DataSet to lowercase
 void setMetaData(MetaData metaData)
           
protected  void setPointer(int pointer)
           
 void setPZConvertProps(java.util.Properties props)
          Sets the properties from the pzconvert.properties file.
 void setStrictNumericParse(boolean strictNumericParse)
          Setting this to True will parse text as is and throw a NumberFormatException.
 void setUpperCase()
          Sets data in the DataSet to uppercase
 void setValue(java.lang.String column, java.lang.String value)
          Changes the value of the given column only for the given row which the pointer is currently sitting on.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDataSet

public DefaultDataSet(MetaData pzMetaData,
                      Parser pzparser)
Method Detail

addRow

public void addRow(Row row)

addError

public void addError(DataError dataError)

getColumns

public java.lang.String[] getColumns()
Description copied from interface: DataSet
Returns a String array of column names in the DataSet. This will assume 'detail' ID.

Specified by:
getColumns in interface DataSet
Returns:
String[]

getColumns

public java.lang.String[] getColumns(java.lang.String recordID)
Description copied from interface: DataSet
Returns a String array of column names in the DataSet for a given id

Specified by:
getColumns in interface DataSet
Returns:
String[]

getDate

public java.util.Date getDate(java.lang.String column)
                       throws java.text.ParseException
Description copied from interface: DataSet
Returns the date value of a specified column. This assumes the date is in yyyyMMdd. If your date is not in this format, see getDate(String,SimpleDateFormat) Will return "null" on empty Strings

Specified by:
getDate in interface DataSet
Parameters:
column - - Name of the column
Returns:
Date
Throws:
java.text.ParseException

getDate

public java.util.Date getDate(java.lang.String column,
                              java.text.SimpleDateFormat sdf)
                       throws java.text.ParseException
Description copied from interface: DataSet
Returns the date value of a specified column. This should be used if the date is NOT in yyyyMMdd format. The SimpleDateFormat object will specify what kind of format the date is in. Will return "null" on empty Strings

Specified by:
getDate in interface DataSet
Parameters:
column - - Name of the column
sdf - - SimpleDateFormat of the date
Returns:
Date
Throws:
java.text.ParseException
See Also:
SimpleDateFormat

getDouble

public double getDouble(java.lang.String column)
Description copied from interface: DataSet
Returns the double value of a specified column

Specified by:
getDouble in interface DataSet
Parameters:
column - - Name of the column
Returns:
double

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String column)
Description copied from interface: DataSet
Returns the BigDecimal value of a specified column

Specified by:
getBigDecimal in interface DataSet
Parameters:
column - - Name of the column
Returns:
BigDecimal

getObject

public java.lang.Object getObject(java.lang.String column,
                                  java.lang.Class classToConvertTo)
Description copied from interface: DataSet
Returns the value of the column with the type of object specified

Specified by:
getObject in interface DataSet
Parameters:
column - Name of the column
classToConvertTo - Class type to convert to
Returns:
Object Value of the column in the specified object

getErrorCount

public int getErrorCount()
Description copied from interface: DataSet
Returns total number of records which contained a parse error in the file.

Specified by:
getErrorCount in interface DataSet
Returns:
int - Record Error Count

getErrors

public java.util.List getErrors()
Description copied from interface: DataSet
Returns A Collection Of DataErrors that happened during processing

Specified by:
getErrors in interface DataSet
Returns:
Vector

getIndex

public int getIndex()
Description copied from interface: DataSet
Returns the index the pointer is on for the array

Specified by:
getIndex in interface DataSet
Returns:
int

getInt

public int getInt(java.lang.String column)
Description copied from interface: DataSet
Returns the interger value of a specified column

Specified by:
getInt in interface DataSet
Parameters:
column - - Name of the column
Returns:
double

getLong

public long getLong(java.lang.String column)
Description copied from interface: DataSet
Returns the long value of a specified column

Specified by:
getLong in interface DataSet
Parameters:
column - - Name of the column
Returns:
long

getRowCount

public int getRowCount()
Description copied from interface: DataSet
Returns the total number of rows parsed in from the file

Specified by:
getRowCount in interface DataSet
Returns:
int - Row Count

getRowNo

public int getRowNo()
Description copied from interface: DataSet
Returns the line number the pointer is on. These are the actual line numbers from the flat file, before any sorting.

Specified by:
getRowNo in interface DataSet
Returns:
int

getString

public java.lang.String getString(java.lang.String column)
Description copied from interface: DataSet
Returns the string value of a specified column

Specified by:
getString in interface DataSet
Parameters:
column - - Name of the column
Returns:
String

setValue

public void setValue(java.lang.String column,
                     java.lang.String value)
Description copied from interface: DataSet
Changes the value of the given column only for the given row which the pointer is currently sitting on.

Specified by:
setValue in interface DataSet
Parameters:
column - Column name to set the value for
value - Value to change the column to

goBottom

public void goBottom()
Description copied from interface: DataSet
Goes to the last record in the dataset

Specified by:
goBottom in interface DataSet

goTop

public void goTop()
Description copied from interface: DataSet
Goes to the top of the data set. This will put the pointer one record before the first in the set. Next() will have to be called to get the first record after this call.

Specified by:
goTop in interface DataSet

isAnError

public boolean isAnError(int lineNo)
Description copied from interface: DataSet
Returns true or false as to whether or not the line number contains an error. The import will skip the line if it contains an error and it will not be processed

Specified by:
isAnError in interface DataSet
Parameters:
lineNo - - int line number
Returns:
boolean

next

public boolean next()
Description copied from interface: DataSet
Moves to the next record in the set. Returns true if move was a success, false if not

Specified by:
next in interface DataSet
Returns:
boolean

orderRows

public void orderRows(OrderBy ob)
Description copied from interface: DataSet
Orders the data by column(s) specified. This will reposition the cursor to the top of the DataSet when executed. This is currently not supported when specying elements in the mapping. An exception will be thrown if this situation occurs

Specified by:
orderRows in interface DataSet
Parameters:
ob - - OrderBy object
See Also:
OrderBy, OrderColumn

previous

public boolean previous()
Description copied from interface: DataSet
Moves back to the previous record in the set return true if move was a success, false if not

Specified by:
previous in interface DataSet
Returns:
boolean

setLowerCase

public void setLowerCase()
Sets data in the DataSet to lowercase

Specified by:
setLowerCase in interface DataSet

setUpperCase

public void setUpperCase()
Sets data in the DataSet to uppercase

Specified by:
setUpperCase in interface DataSet

isRecordID

public boolean isRecordID(java.lang.String recordID)
Checks to see if the row has the given id

Specified by:
isRecordID in interface DataSet
Parameters:
recordID -
Returns:
boolean

absolute

public void absolute(int localPointer)
Sets the absolute position of the record pointer

Specified by:
absolute in interface DataSet
Parameters:
localPointer - - int
Throws:
java.lang.IndexOutOfBoundsException

setStrictNumericParse

public void setStrictNumericParse(boolean strictNumericParse)
Setting this to True will parse text as is and throw a NumberFormatException. Setting to false, which is the default, will remove any non numeric charcter from the field. The remaining numeric chars's will be returned. If it is an empty string,or there are no numeric chars, 0 will be returned for getInt() and getDouble()

Specified by:
setStrictNumericParse in interface DataSet
Parameters:
strictNumericParse - The strictNumericParse to set.

remove

public void remove()
Description copied from interface: DataSet
Removes a row from the dataset. Once the row is removed the pointer will be sitting on the record previous to the deleted row.

Specified by:
remove in interface DataSet

setPZConvertProps

public void setPZConvertProps(java.util.Properties props)
Description copied from interface: DataSet
Sets the properties from the pzconvert.properties file. This file specifies the PZConverter implementation to use for a particular class

Specified by:
setPZConvertProps in interface DataSet
Parameters:
props - Property mapping for String to Object conversion

setPointer

protected void setPointer(int pointer)
Parameters:
pointer - the pointer to set

clearRows

public void clearRows()
Description copied from interface: DataSet
Clears out the rows in memory from the last parse.

Specified by:
clearRows in interface DataSet

clearAll

public void clearAll()
Description copied from interface: DataSet
Clears both the errors and rows from memory

Specified by:
clearAll in interface DataSet

clearErrors

public void clearErrors()
Description copied from interface: DataSet
Clears out the parse errors from memory

Specified by:
clearErrors in interface DataSet

getMetaData

public MetaData getMetaData()

setMetaData

public void setMetaData(MetaData metaData)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

contains

public boolean contains(java.lang.String column)
Description copied from interface: DataSet
Does this DataSet contain a column with the given name?

Specified by:
contains in interface DataSet
Parameters:
column - Column name to check for
Returns:
boolean

isRowEmpty

public boolean isRowEmpty()
Description copied from interface: DataSet
Checks to see if there was no data on the row which was parsed. This will thrown an exception if Parser.FlagEmptyRows() is not set to true.

Specified by:
isRowEmpty in interface DataSet
Returns:
Throws:
FPInvalidUsageException - Parser.isFlagEmptyRows() must be set to true before using this
FPException - if cursor is on an invalid row

getRawData

public java.lang.String getRawData()
Specified by:
getRawData in interface DataSet
Returns:
the raw data used to create this Row in the DataSet. Parser.setStoreRawDataToDataSet(true) must be specified before calling this method.
Throws:
FPInvalidUsageException
FPException - if cursor is on an invalid row


Copyright © 2006-2011 Appendium - Portfolio Financing Platform. All Rights Reserved.