|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.parse.RecordReader
Field Summary | |
static String |
DATA_TYPE_DATE
|
static String |
DATA_TYPE_NUMBER
|
static String |
DATA_TYPE_TEXT
|
protected ReadOnlyProperty |
format
property tree, specific to each record reader subclass. |
Constructor Summary | |
RecordReader()
|
Method Summary | |
protected Object |
convertType(String textValue,
String type,
String dateFormat)
convert a text value to a given type. |
protected abstract RecordData |
createRecord(String[] rawBuffer)
create an RecordData object from a raw data buffer, based on the format
properties. |
protected abstract String[] |
getRawRecord(BufferedReader reader,
String[] rawBuffer)
get the next set of raw data from the input stream, or return null if at the end of the stream. |
protected abstract void |
initFormatData()
|
void |
read(InputStream input,
OutputStream reject,
InputRecordHandler handler)
read raw data records from an input stream, convert them to RecordData objects
using the format properties, and notify the handler provided. |
protected void |
rejectRecord(String[] rawData,
String rejectMessage,
BufferedWriter rejectWriter)
send a rejected record to the reject stream |
protected String |
removeQuotes(String qStr)
|
void |
setFormat(ReadOnlyProperty formatProps)
provide the readed with the property tree that defines the format of the files it must read. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String DATA_TYPE_TEXT
public static final String DATA_TYPE_DATE
public static final String DATA_TYPE_NUMBER
protected ReadOnlyProperty format
Constructor Detail |
public RecordReader()
Method Detail |
public void setFormat(ReadOnlyProperty formatProps) throws FormatException
formatProps
- property tree defining file format. See subclass implementations.
FormatException
public void read(InputStream input, OutputStream reject, InputRecordHandler handler) throws IOException, FormatException
RecordData
objects
using the format properties, and notify the handler provided. Send any edit/reject
reject records to the specified reject stream.
input
- source of raw record datareject
- desitination for raw data of rejected recordshandler
- object to be notified with results of each record read
IOException
FormatException
protected void rejectRecord(String[] rawData, String rejectMessage, BufferedWriter rejectWriter) throws IOException
rawData
- raw character data of rejected recordrejectWriter
- a writer servicing the reject output stream
IOException
protected Object convertType(String textValue, String type, String dateFormat) throws RecordDataInputException, FormatException
String
objects, Date values are
returned as Date
objects, and Number values are returned as
BigDecimal
objects.
textValue
- text representation of the desired valuetype
- string giving the type to convert to - Text, Date, NumberdateFormat
- format in the form that SimpleDateFormat
expects. For
example "yyyyMMdd" or "MM/dd/yy".
RecordDataInputException
FormatException
protected String removeQuotes(String qStr)
protected abstract String[] getRawRecord(BufferedReader reader, String[] rawBuffer) throws RecordDataInputException, IOException
reader
- buffered reader servicing the raw data input stream.rawBuffer
- raw data buffer to reuse for this record if possible. Could be null.
RecordDataInputExceptoin
- if the necessary data cannot be retreived
RecordDataInputException
IOException
protected abstract RecordData createRecord(String[] rawBuffer) throws FormatException, RecordDataInputException
RecordData
object from a raw data buffer, based on the format
properties.
rawBuffer
- raw record data
FormatException
- when there is a fundamental problem with the record format
definition and all processing should cease.
RecordDataInputException
- when there is a problem retreiving data from this
record, but processing of further records can continue.protected abstract void initFormatData() throws FormatException
FormatException
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |