public interface BeanReader extends Debuggable
A BeanReader is created using a StreamFactory
and a mapping file.
StreamFactory
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying input stream.
|
int |
getLineNumber()
Returns the starting line number of the first record for the most recent bean
object read from this reader, or -1 when the end of the stream is reached.
|
RecordContext |
getRecordContext(int index)
Returns record information for the most recent bean object read from this reader.
|
int |
getRecordCount()
Returns the number of records read from the underlying input stream for the
most recent bean object read from this reader.
|
String |
getRecordName()
Returns the record or group name of the most recent bean object
read from this reader, or null if the end of the stream was reached.
|
Object |
read()
Reads a single bean from the input stream.
|
void |
setErrorHandler(BeanReaderErrorHandler errorHandler)
Sets the error handler to handle exceptions thrown by
read() . |
int |
skip(int count)
Skips ahead in the input stream.
|
debug, debug
Object read() throws BeanReaderIOException, MalformedRecordException, UnidentifiedRecordException, UnexpectedRecordException, InvalidRecordException
BeanReaderIOException
- if the underlying input stream throws an
IOException
or this reader was closedMalformedRecordException
- if the underlying input stream is malformed
and the record could not be accurately readUnidentifiedRecordException
- if the record type could not be identifiedUnexpectedRecordException
- if the record type is out of sequenceInvalidRecordException
- if the record was identified and failed record
or field level validations (including field type conversion errors)int skip(int count) throws BeanReaderIOException, MalformedRecordException, UnidentifiedRecordException, UnexpectedRecordException
count
- the number of bean objects to skip over that would have been returned
by calling read()
BeanReaderIOException
- if the underlying input stream throws an
IOException
or this reader was closedMalformedRecordException
- if the underlying input stream is malformed
and a record could not be accurately skippedUnidentifiedRecordException
- if a record could not be identifiedUnexpectedRecordException
- if a record is out of sequenceString getRecordName()
int getLineNumber()
int getRecordCount()
RecordContext getRecordContext(int index) throws IndexOutOfBoundsException
getRecordCount()
can be used
to determine how many records were read from the stream.index
- the index of the record, starting at 0RecordContext
IndexOutOfBoundsException
- if there is no record for the given indexgetRecordCount()
void close() throws BeanReaderIOException
BeanReaderIOException
- if the underlying input stream throws an
IOException
or this reader was already closedvoid setErrorHandler(BeanReaderErrorHandler errorHandler)
read()
.errorHandler
- the BeanReaderErrorHandler