Class ParserIterator<T>

java.lang.Object
com.univocity.parsers.common.iterators.ParserIterator<T>
All Implemented Interfaces:
IterableResult<T,ParsingContext>, Iterable<T>
Direct Known Subclasses:
RecordIterator, RowIterator

abstract class ParserIterator<T> extends Object implements IterableResult<T,ParsingContext>
An Iterator over the parser enabling easy iteration against rows and records Multiple iterations are possible if Files are being fed into the parser, but other forms of input (such as InputStreams and Readers) can not be iterated over more than once.
  • Field Details

  • Constructor Details

    • ParserIterator

      protected ParserIterator(AbstractParser parser)
      Creates a ParserIterator using the provided parser
      Parameters:
      parser - the parser to iterate over
  • Method Details

    • getContext

      public final ParsingContext getContext()
      Description copied from interface: IterableResult
      Returns the current parsing Context, if available
      Specified by:
      getContext in interface IterableResult<T,ParsingContext>
      Returns:
      the contextual object with information about an ongoing parsing process
    • beginParsing

      protected abstract void beginParsing()
      This method is called whenever the iterator is starting to iterate over the results. an example implementation of this is:
           
           &#064;Override
           public void beginParsing(){
               parser.beginParsing(input);
           }
       

      This is to allow for different input types such as Reader, File, or InputStream without large code reuse.
    • iterator

      public final ResultIterator<T,ParsingContext> iterator()
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface IterableResult<T,ParsingContext>
    • nextResult

      protected abstract T nextResult()
      Returns the next record (either a String[] or a Record)
      Returns:
      the next record if available.