public class UriTokenizer extends Object
Simple OData URI tokenizer that works on a given string by keeping an index.
As far as feasible, it tries to work on character basis, assuming this to be faster than string operations. Since only the index is "moved", backing out while parsing a token is easy and used throughout. There is intentionally no method to push back tokens (although it would be easy to add such a method) because this tokenizer should behave like a classical token-consuming tokenizer. There is, however, the possibility to save the current state and return to it later.
Whitespace is not an extra token but consumed with the tokens that require whitespace. Optional whitespace is not supported.
| Modifier and Type | Class and Description |
|---|---|
static class |
UriTokenizer.TokenKind |
| Constructor and Description |
|---|
UriTokenizer(String parseString) |
| Modifier and Type | Method and Description |
|---|---|
String |
getText()
Returns the string value corresponding to the last successful
next(TokenKind) call. |
boolean |
next(UriTokenizer.TokenKind allowedTokenKind)
Tries to find a token of the given token kind at the current index.
|
void |
returnToSavedState()
Return to the previously saved state.
|
void |
saveState()
Save the current state.
|
public UriTokenizer(String parseString)
public void saveState()
returnToSavedState()public void returnToSavedState()
saveState()public String getText()
next(TokenKind) call.public boolean next(UriTokenizer.TokenKind allowedTokenKind)
allowedTokenKind - the kind of token to expecttrue if the token is found; false otherwisegetText()Copyright © 2023. All rights reserved.