public class JavascriptTokenBuffer extends Object
jsparser.c. In particular:
| Constructor and Description |
|---|
JavascriptTokenBuffer()
Constructs an empty javascript token buffer.
|
JavascriptTokenBuffer(JavascriptTokenBuffer aJavascriptTokenBuffer)
Constructs a javascript token buffer that is identical to
the one given.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendChar(char input)
Appends a character to the buffer.
|
void |
appendString(String input)
A simple wrapper over
appendChar, it appends a string
to the buffer. |
char |
getChar(int position)
Returns the character at a given index in the buffer or nul ('\0')
if the index is outside the range of the buffer.
|
String |
getLastIdentifier()
Returns the last javascript identifier/keyword in the buffer.
|
char |
popChar()
Returns the last character in the buffer and removes it from the buffer
or the NUL character '\0' if the buffer is empty.
|
boolean |
setChar(int position,
char input)
Sets the given
input at the given position of the buffer. |
String |
slice(int start,
int end)
Returns a slice of the buffer delimited by the given indices.
|
public JavascriptTokenBuffer()
BUFFER_SIZE.public JavascriptTokenBuffer(JavascriptTokenBuffer aJavascriptTokenBuffer)
aJavascriptTokenBuffer - the JavascriptTokenBuffer to copypublic void appendString(String input)
appendChar, it appends a string
to the buffer. Sequences of whitespace and newlines
are folded into one character to save space. Null strings are
not allowed.input - the String to append, cannot be nullpublic void appendChar(char input)
input - the char to appendpublic char popChar()
public char getChar(int position)
Position must be negative where -1 is the index of the last character in the buffer.
position - The index into the bufferpublic boolean setChar(int position,
char input)
input at the given position of the buffer.
Returns true if we succeeded or false if we
failed (i.e. the write was beyond the buffer boundary).
Index positions are negative where -1 is the index of the last character in the buffer.
position - The index at which to set the characterinput - The character to set in the buffertrue if we succeeded, false otherwisepublic String getLastIdentifier()
null if none was foundpublic String slice(int start, int end)
start - The index of the first character the copyend - the index of the last character to copyString between the given indicesCopyright © 2010–2016 Google. All rights reserved.