Class UriTokenizer
java.lang.Object
org.apache.olingo.server.core.uri.parser.UriTokenizer
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetText()Returns the string value corresponding to the last successfulnext(TokenKind)call.booleannext(UriTokenizer.TokenKind allowedTokenKind) Tries to find a token of the given token kind at the current index.voidReturn to the previously saved state.voidSave the current state.
-
Constructor Details
-
UriTokenizer
-
-
Method Details
-
saveState
public void saveState()Save the current state.- See Also:
-
returnToSavedState
public void returnToSavedState()Return to the previously saved state.- See Also:
-
getText
Returns the string value corresponding to the last successfulnext(TokenKind)call. -
next
Tries to find a token of the given token kind at the current index. The order in which this method is called with different token kinds is important, not only for performance reasons but also if tokens can start with the same characters (e.g., a qualified name starts with an OData identifier). The index is advanced to the end of this token if the token is found.- Parameters:
allowedTokenKind- the kind of token to expect- Returns:
trueif the token is found;falseotherwise- See Also:
-