|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.parboiled.buffers.MutableInputBuffer
public class MutableInputBuffer
An InputBuffer wrapping another InputBuffer and providing for the ability to insert (and undo) characters at certain index positions. Inserted chars do not appear in extracted text and have the same positions as the original chars at their indices. Note that this implementation is optimized for a rather small number of insertions and will perform badly with a large number of insertions.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.parboiled.buffers.InputBuffer |
---|
InputBuffer.Position |
Constructor Summary | |
---|---|
MutableInputBuffer(InputBuffer buffer)
|
Method Summary | |
---|---|
char |
charAt(int index)
Returns the character at the given index. |
java.lang.String |
extract(int start,
int end)
Constructs a new String from all character between the given indices. |
java.lang.String |
extractLine(int lineNumber)
Constructs a new String containing all characters with the given line number except for the trailing
newline. |
int |
getLineCount()
Returns the number of lines in the input buffer. |
InputBuffer.Position |
getPosition(int index)
Returns the line and column number of the character with the given index encapsulated in a InputBuffer.Position
object. |
void |
insertChar(int index,
char c)
|
boolean |
test(int index,
char[] characters)
Determines whether the characters starting at the given index match the ones from the given array (in order). |
char |
undoCharInsertion(int index)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MutableInputBuffer(InputBuffer buffer)
Method Detail |
---|
public char charAt(int index)
InputBuffer
Chars.EOI
.
charAt
in interface InputBuffer
index
- the index
public boolean test(int index, char[] characters)
InputBuffer
test
in interface InputBuffer
index
- the index into the input buffer where to start the comparisoncharacters
- the characters to test against the input buffer
public InputBuffer.Position getPosition(int index)
InputBuffer
InputBuffer.Position
object. The very first character has the line number 1 and the column number 1.
getPosition
in interface InputBuffer
index
- the index of the character to get the line number of
public java.lang.String extractLine(int lineNumber)
InputBuffer
String
containing all characters with the given line number except for the trailing
newline.
extractLine
in interface InputBuffer
lineNumber
- the line number to get
public java.lang.String extract(int start, int end)
InputBuffer
String
from all character between the given indices.
Invalid indices are automatically adjusted to their respective boundary.
extract
in interface InputBuffer
start
- the start index (inclusively)end
- the end index (exclusively)
public int getLineCount()
InputBuffer
getLineCount
in interface InputBuffer
public void insertChar(int index, char c)
public char undoCharInsertion(int index)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |