|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.streamhtmlparser.util.JavascriptTokenBuffer
public class JavascriptTokenBuffer
Implements a circular (ring) buffer of characters with specialized
application logic in order to determine the context of some
Javascript content that is being parsed.
This is a specialized class - of no use to external code -
which aims to be 100% compatible with the corresponding logic
in the C-version of the HtmlParser, specifically
jsparser.c
. In particular:
Constructor Summary | |
---|---|
JavascriptTokenBuffer()
Constructs an empty javascript token buffer. |
|
JavascriptTokenBuffer(JavascriptTokenBuffer aJavascriptTokenBuffer)
Constructs a javascript token buffer that is identical to the one given. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavascriptTokenBuffer()
BUFFER_SIZE
.
public JavascriptTokenBuffer(JavascriptTokenBuffer aJavascriptTokenBuffer)
aJavascriptTokenBuffer
- the JavascriptTokenBuffer
to copyMethod Detail |
---|
public 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 null
public 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 buffer
public 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 buffer
true
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 copy
String
between the given indices
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |