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
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 InputStream
s and Reader
s) can not be iterated over more than once.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ParserIterator
(AbstractParser parser) Creates aParserIterator
using the providedparser
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
This method is called whenever theiterator
is starting to iterate over the results.final ParsingContext
Returns the current parsingContext
, if availablefinal ResultIterator<T,
ParsingContext> iterator()
protected abstract T
Returns the next record (either a String[] or aRecord
)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
parser
-
-
Constructor Details
-
ParserIterator
Creates aParserIterator
using the providedparser
- Parameters:
parser
- theparser
to iterate over
-
-
Method Details
-
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
- Specified by:
iterator
in interfaceIterable<T>
- Specified by:
iterator
in interfaceIterableResult<T,
ParsingContext>
-
nextResult
Returns the next record (either a String[] or aRecord
)- Returns:
- the next record if available.
-