Class ParserIterator<T>
- java.lang.Object
-
- com.univocity.parsers.common.iterators.ParserIterator<T>
-
- All Implemented Interfaces:
IterableResult<T,ParsingContext>
,java.lang.Iterable<T>
- Direct Known Subclasses:
RecordIterator
,RowIterator
abstract class ParserIterator<T> extends java.lang.Object implements IterableResult<T,ParsingContext>
AnIterator
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 asInputStream
s andReader
s) can not be iterated over more than once.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractParser
parser
-
Constructor Summary
Constructors Modifier Constructor Description protected
ParserIterator(AbstractParser parser)
Creates aParserIterator
using the providedparser
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
beginParsing()
This method is called whenever theiterator
is starting to iterate over the results.ParsingContext
getContext()
Returns the current parsingContext
, if availableResultIterator<T,ParsingContext>
iterator()
protected abstract T
nextResult()
Returns the next record (either a String[] or aRecord
)
-
-
-
Field Detail
-
parser
protected final AbstractParser parser
-
-
Constructor Detail
-
ParserIterator
protected ParserIterator(AbstractParser parser)
Creates aParserIterator
using the providedparser
- Parameters:
parser
- theparser
to iterate over
-
-
Method Detail
-
getContext
public final ParsingContext getContext()
Description copied from interface:IterableResult
Returns the current parsingContext
, if available- Specified by:
getContext
in interfaceIterableResult<T,ParsingContext>
- Returns:
- the contextual object with information about an ongoing parsing process
-
beginParsing
protected abstract void beginParsing()
This method is called whenever theiterator
is starting to iterate over the results. an example implementation of this is:
@Override public void beginParsing(){ parser.beginParsing(input); }
This is to allow for different input types such asReader, File, or InputStream
without large code reuse.
-
iterator
public final ResultIterator<T,ParsingContext> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Specified by:
iterator
in interfaceIterableResult<T,ParsingContext>
-
-