Package scriptella.expression
Class LineIterator
java.lang.Object
scriptella.expression.LineIterator
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterator<String>
- Direct Known Subclasses:
TrackingLineIterator
An Iterator over the lines in a Reader, additionally properties substitution is performed.
This class change the contract of hasNext() method by
throwing RuntimeIOException on IOException.
Decorators should override format(String) method.
This class is not threadsafe.
- Version:
- 1.0
- Author:
- Fyodor Kupolov
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLineIterator(Reader reader) LineIterator(Reader reader, PropertiesSubstitutor substitutor) LineIterator(Reader reader, PropertiesSubstitutor substitutor, boolean trimLines) Constructs iterator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
LineIterator
-
LineIterator
-
LineIterator
Constructs iterator.- Parameters:
reader- reader to iterate.substitutor- substitutor to use to expand properties or null to disable substitution.trimLines- true if the returned lines should be trimmed.
-
-
Method Details
-
hasNext
- Specified by:
hasNextin interfaceIterator<String>- Returns:
- true if a line is available for reading by
next() - Throws:
RuntimeIOException- if IO error occurs.
-
format
Applies additional formatting to the line read.May be overriden by decorators.
- Parameters:
line- line of text, nulls allowed.- Returns:
- formatted line.
-
next
Returns the next avalable line in a reader.- Specified by:
nextin interfaceIterator<String>- Returns:
- the next avalable line in a reader.
- Throws:
RuntimeIOException- if IO error occurs.NoSuchElementException- if has no more elements.
-
skip
public int skip(int n) Skips N lines.- Parameters:
n- number of lines to skip.- Returns:
- the actual number of lines skipped.
-
getLineAt
Returns specified line or null if EOF occured.- Parameters:
n- line number relative to the current line in the input. n>=0- Returns:
- line n.
-
remove
- Specified by:
removein interfaceIterator<String>- Throws:
UnsupportedOperationException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-