|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
oracle.javatools.parser.java.v2.scanner.TokenArray
public final class TokenArray
A precalculated array of tokens. Pay the cost of lexing the first time in order to calculate the array of tokens. All subsequent lexing is a matter of array accesses.
| Field Summary | |
|---|---|
int |
tokenCountThe number of tokens. |
int[] |
tokenEndsThe (dense) array of token end offsets. |
int[] |
tokenStartsThe (dense) array of token start offsets. |
short[] |
tokenValuesThe (dense) array of token values. |
| Constructor Summary | |
|---|---|
TokenArray(FastLexer lexer) |
|
| Method Summary | |
|---|---|
void |
adjust(int offset)Adjusts every offset in the token array by the given parameter. |
int |
offset2index(int query, boolean biasAfter)Translates a TextBuffer offset into a TokenArray index with the given bias. |
int |
search(int query) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final int tokenCount
public final short[] tokenValues
public final int[] tokenStarts
public final int[] tokenEnds
| Constructor Detail |
|---|
public TokenArray(FastLexer lexer)
| Method Detail |
|---|
public void adjust(int offset)
public int search(int query)
query - The start offset to be searched for.java.lang.ArrayIndexOutOfBoundsException - Only if Arrays.binarySearch is wrong or if my array data got corrupted.
public int offset2index(int query,
boolean biasAfter)
Assumes that all tokens are non-empty (except for the special EOF token). If there are empty tokens (besides the special EOF token), then no guarantee is made regarding the return value.
query - The offset to be searched for.biasAfter - True means use an after-bias. Otherwise, use a before-bias. After-bias means choose the next token. Before-bias means choose the previous.Note that whereas EOF is a proper token (the index of EOF is tokenCount-1), start-of-file is not. So, for clarity, if the offset is 0 and the first token is at 0, then 0 is returned, regardless of bias.
If the query is in whitespace, then supposing the query lies between tokens i-1 and i, this will return -(i+1). (This matches the behavior of the Arrays.binarySearch() methods).
To do the math for you, that means that: If the query is before the first token (assuming the first token is not at start-of-file), -1 is returned. If the query is between the last non-EOF token and EOF itself (that is, the file's trailing whitespace), then -tokenCount is returned.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||