com.atlassian.renderer.v2.components.block
Class LineWalker
java.lang.Object
com.atlassian.renderer.v2.components.block.LineWalker
public class LineWalker
- extends java.lang.Object
Iterates over a String line by line. Acts somewhat like an iterator, but with extra methods. It provides a
"peek()" function so that following lines can be checked without modifying the state of the walker,
and a "pushBack(String)" function so that the state can be rolled back (or even falsified) when
required.
This class is not thread-safe.
|
Constructor Summary |
LineWalker(java.lang.String text)
|
|
Method Summary |
boolean |
hasNext()
|
java.lang.String |
next()
Walks the next line, returning the line and advancing the state of the walker past that line. |
java.lang.String |
peek()
Returns the next line to be walked without actually walking it. |
void |
pushBack(java.lang.String line)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LineWalker
public LineWalker(java.lang.String text)
hasNext
public boolean hasNext()
- Returns:
- true if there are more lines to be walked
peek
public java.lang.String peek()
- Returns the next line to be walked without actually walking it. Throws an
exception if there are no lines, so call
hasNext() first.
- Returns:
- the next line to be walked.
- Throws:
java.lang.IllegalStateException - if there are no more lines to be walked.
next
public java.lang.String next()
- Walks the next line, returning the line and advancing the state of the walker past that line. Throws an
exception if there are no lines, so call
hasNext() first.
- Returns:
- the next line.
- Throws:
java.lang.IllegalStateException - if there are no more lines to be walked.
pushBack
public void pushBack(java.lang.String line)
Copyright © 2013 Atlassian. All Rights Reserved.