public class TokenQueue extends Object
Modifier and Type | Field and Description |
---|---|
private static char |
ESC |
private int |
pos |
private String |
queue |
Constructor and Description |
---|
TokenQueue(String data)
Create a new TokenQueue.
|
Modifier and Type | Method and Description |
---|---|
void |
addFirst(Character c)
Add a character to the start of the queue (will be the next character retrieved).
|
void |
addFirst(String seq)
Add a string to the start of the queue.
|
void |
advance()
Drops the next character off the queue.
|
String |
chompBalanced(char open,
char close)
Pulls a balanced string off the queue.
|
String |
chompTo(String seq)
Pulls a string off the queue (like consumeTo), and then pulls off the matched string (but does not return it).
|
String |
chompToIgnoreCase(String seq) |
char |
consume()
Consume one character off queue.
|
void |
consume(String seq)
Consumes the supplied sequence of the queue.
|
String |
consumeAttributeKey()
Consume an attribute key off the queue (letter, digit, -, _, :")
|
String |
consumeCssIdentifier()
Consume a CSS identifier (ID or class) off the queue (letter, digit, -, _)
http://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
|
String |
consumeElementSelector()
Consume a CSS element selector (tag name, but | instead of : for namespaces (or *| for wildcard namespace), to not conflict with :pseudo selects).
|
String |
consumeTagName()
Consume an tag name off the queue (word or :, _, -)
|
String |
consumeTo(String seq)
Pulls a string off the queue, up to but exclusive of the match sequence, or to the queue running out.
|
String |
consumeToAny(String... seq)
Consumes to the first sequence provided, or to the end of the queue.
|
String |
consumeToIgnoreCase(String seq) |
boolean |
consumeWhitespace()
Pulls the next run of whitespace characters of the queue.
|
String |
consumeWord()
Retrieves the next run of word type (letter or digit) off the queue.
|
boolean |
isEmpty()
Is the queue empty?
|
boolean |
matchChomp(String seq)
Tests if the queue matches the sequence (as with match), and if they do, removes the matched string from the
queue.
|
boolean |
matches(String seq)
Tests if the next characters on the queue match the sequence.
|
boolean |
matchesAny(char... seq) |
boolean |
matchesAny(String... seq)
Tests if the next characters match any of the sequences.
|
boolean |
matchesCS(String seq)
Case sensitive match test.
|
boolean |
matchesStartTag() |
boolean |
matchesWhitespace()
Tests if queue starts with a whitespace character.
|
boolean |
matchesWord()
Test if the queue matches a word character (letter or digit).
|
char |
peek()
Retrieves but does not remove the first character from the queue.
|
String |
remainder()
Consume and return whatever is left on the queue.
|
private int |
remainingLength() |
String |
toString() |
static String |
unescape(String in)
Unescape a \ escaped string.
|
private int pos
private static final char ESC
public TokenQueue(String data)
data
- string of data to back queue.public boolean isEmpty()
private int remainingLength()
public char peek()
public void addFirst(Character c)
c
- character to addpublic void addFirst(String seq)
seq
- string to add.public boolean matches(String seq)
seq
- String to check queue for.public boolean matchesCS(String seq)
seq
- string to case sensitively check forpublic boolean matchesAny(String... seq)
seq
- list of strings to case insensitively check forpublic boolean matchesAny(char... seq)
public boolean matchesStartTag()
public boolean matchChomp(String seq)
seq
- String to search for, and if found, remove from queue.public boolean matchesWhitespace()
public boolean matchesWord()
public void advance()
public char consume()
public void consume(String seq)
Case insensitive.
seq
- sequence to remove from head of queue.public String consumeTo(String seq)
seq
- String to end on (and not include in return, but leave on queue). Case sensitive.public String consumeToIgnoreCase(String seq)
public String consumeToAny(String... seq)
seq
- any number of terminators to consume to. Case insensitive.public String chompTo(String seq)
If the queue runs out of characters before finding the seq, will return as much as it can (and queue will go isEmpty() == true).
seq
- String to match up to, and not include in return, and to pull off queue. Case sensitive.public String chompToIgnoreCase(String seq)
public String chompBalanced(char open, char close)
open
- openerclose
- closerpublic static String unescape(String in)
in
- backslash escaped stringpublic boolean consumeWhitespace()
public String consumeWord()
public String consumeTagName()
public String consumeElementSelector()
public String consumeCssIdentifier()
public String consumeAttributeKey()
public String remainder()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses