Class BeanReaderImpl

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, BeanReader, Debuggable

    public class BeanReaderImpl
    extends java.lang.Object
    implements BeanReader
    A BeanReader implementation.
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying input stream.
      void debug()
      Prints the internal view of the stream configuration to System.out
      void debug​(java.io.PrintStream out)
      Prints the internal view of the stream configuration.
      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.
      java.lang.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.
      java.lang.Object read()
      Reads a single bean from the input stream.
      void setErrorHandler​(BeanReaderErrorHandler errorHandler)
      Sets the error handler to handle exceptions thrown by BeanReader.read().
      void setIgnoreUnidentifiedRecords​(boolean ignoreUnidentifiedRecords)
      Sets whether to ignore unidentified records.
      int skip​(int count)
      Skips ahead in the input stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • read

        public java.lang.Object read()
        Description copied from interface: BeanReader
        Reads a single bean from the input stream. If the end of the stream is reached, null is returned.
        Specified by:
        read in interface BeanReader
        Returns:
        the Java bean read, or null if the end of the stream was reached
      • close

        public void close()
                   throws BeanReaderIOException
        Description copied from interface: BeanReader
        Closes the underlying input stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface BeanReader
        Specified by:
        close in interface java.io.Closeable
        Throws:
        BeanReaderIOException - if the underlying input stream throws an IOException or this reader was already closed
      • getRecordName

        public java.lang.String getRecordName()
        Description copied from interface: BeanReader
        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.
        Specified by:
        getRecordName in interface BeanReader
        Returns:
        the record or group name
      • getLineNumber

        public int getLineNumber()
        Description copied from interface: BeanReader
        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. The line number may be zero if new lines are not used to separate characters.
        Specified by:
        getLineNumber in interface BeanReader
        Returns:
        the line number
      • getRecordCount

        public int getRecordCount()
        Description copied from interface: BeanReader
        Returns the number of records read from the underlying input stream for the most recent bean object read from this reader. This typically returns 1 unless a bean object was mapped to a record group which may span multiple records.
        Specified by:
        getRecordCount in interface BeanReader
        Returns:
        the record count
      • setIgnoreUnidentifiedRecords

        public void setIgnoreUnidentifiedRecords​(boolean ignoreUnidentifiedRecords)
        Sets whether to ignore unidentified records. Defaults to false.
        Parameters:
        ignoreUnidentifiedRecords - true to ignore unidentified records, false otherwise
      • debug

        public void debug()
        Description copied from interface: Debuggable
        Prints the internal view of the stream configuration to System.out
        Specified by:
        debug in interface Debuggable
      • debug

        public void debug​(java.io.PrintStream out)
        Description copied from interface: Debuggable
        Prints the internal view of the stream configuration.
        Specified by:
        debug in interface Debuggable
        Parameters:
        out - the PrintStream to write to