com.atlassian.renderer.v2.components.block
Class LineWalker
java.lang.Object
com.atlassian.renderer.v2.components.block.LineWalker
public class LineWalker
- extends 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.
|
Method Summary |
boolean |
hasNext()
|
String |
next()
Walks the next line, returning the line and advancing the state of the walker past that line. |
String |
peek()
Returns the next line to be walked without actually walking it. |
void |
pushBack(String line)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LineWalker
public LineWalker(String text)
hasNext
public boolean hasNext()
- Returns:
- true if there are more lines to be walked
peek
public 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:
IllegalStateException - if there are no more lines to be walked.
next
public 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:
IllegalStateException - if there are no more lines to be walked.
pushBack
public void pushBack(String line)
Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.