BeanIO 1.2.3

org.beanio
Interface BeanReader


public interface BeanReader

Interface for readers capable of reading bean objects from an input stream.

A BeanReader is created using a StreamFactory and a mapping file.

Since:
1.0
Author:
Kevin Seim
See Also:
StreamFactory

Method Summary
 void close()
          Closes the underlying input stream.
 int getLineNumber()
          The beginning line number of the last record read.
 String getRecordName()
          Returns the name of the last record read.
 Object read()
          Reads a single bean from the input stream.
 void setErrorHandler(BeanReaderErrorHandler errorHandler)
          Sets the error handler to delegate bean reader exceptions to.
 int skip(int count)
          Skips ahead in the input stream.
 

Method Detail

read

Object read()
            throws BeanReaderIOException,
                   MalformedRecordException,
                   UnidentifiedRecordException,
                   UnexpectedRecordException,
                   InvalidRecordException
Reads a single bean from the input stream. If the end of the stream is reached, null is returned.

Returns:
the Java bean read, or null if the end of the stream was reached
Throws:
BeanReaderIOException - if an IOException or other fatal error is caught
MalformedRecordException - if the underlying input stream is malformed and the record could not be accurately read
UnidentifiedRecordException - if the record type could not be identified
UnexpectedRecordException - if the record type is out of sequence
InvalidRecordException - if the record was identified and failed record or field level validations (including field type conversion errors)

skip

int skip(int count)
         throws BeanReaderIOException,
                MalformedRecordException,
                UnidentifiedRecordException,
                UnexpectedRecordException
Skips ahead in the input stream. Record validation errors are ignored, but a malformed input stream, unidentified record, or record out of sequence, will cause an exception that halts stream reading. Exceptions thrown by this method are not passed to the error handler.

Parameters:
count - the number of bean objects to skip over that would have been returned by calling read()
Returns:
the number of skipped bean objects, which may be less than count if the end of the stream was reached
Throws:
BeanReaderIOException - if an IOException or other fatal error is caught
MalformedRecordException - if the underlying input stream is malformed and a record could not be accurately skipped
UnidentifiedRecordException - if a record could not be identified
UnexpectedRecordException - if a record is out of sequence
Since:
1.2

getRecordName

String getRecordName()
Returns the name of the last record read.

Returns:
the name of the last record read

getLineNumber

int getLineNumber()
The beginning line number of the last record read.

Returns:
the line number

close

void close()
           throws BeanReaderIOException
Closes the underlying input stream.

Throws:
BeanReaderIOException - if an IOException is thrown when closing the stream

setErrorHandler

void setErrorHandler(BeanReaderErrorHandler errorHandler)
Sets the error handler to delegate bean reader exceptions to.

Parameters:
errorHandler - the error handler to delegate exceptions to

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim