org.parboiled.buffers
Interface InputBuffer

All Known Implementing Classes:
DefaultInputBuffer, IndentDedentInputBuffer, MutableInputBuffer

public interface InputBuffer

Abstraction of a simple char[] buffer holding the input text to be parsed.


Nested Class Summary
static class InputBuffer.Position
          Simple container class for a line/column position in the input text.
 
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.
 boolean test(int index, char[] characters)
          Determines whether the characters starting at the given index match the ones from the given array (in order).
 

Method Detail

charAt

char charAt(int index)
Returns the character at the given index. If the index is invalid the method returns Chars.EOI.

Parameters:
index - the index
Returns:
the character at the given index or Chars.EOI.

test

boolean test(int index,
             char[] characters)
Determines whether the characters starting at the given index match the ones from the given array (in order).

Parameters:
index - the index into the input buffer where to start the comparison
characters - the characters to test against the input buffer
Returns:
true if matched

extract

java.lang.String extract(int start,
                         int end)
Constructs a new String from all character between the given indices. Invalid indices are automatically adjusted to their respective boundary.

Parameters:
start - the start index (inclusively)
end - the end index (exclusively)
Returns:
a new String (non-interned)

getPosition

InputBuffer.Position getPosition(int index)
Returns the line and column number of the character with the given index encapsulated in a InputBuffer.Position object. The very first character has the line number 1 and the column number 1.

Parameters:
index - the index of the character to get the line number of
Returns:
the line number

extractLine

java.lang.String extractLine(int lineNumber)
Constructs a new String containing all characters with the given line number except for the trailing newline.

Parameters:
lineNumber - the line number to get
Returns:
the string

getLineCount

int getLineCount()
Returns the number of lines in the input buffer.

Returns:
number of lines in the input buffer.