Class UriTokenizer

java.lang.Object
org.apache.olingo.server.core.uri.parser.UriTokenizer

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.

  • Constructor Details

    • UriTokenizer

      public UriTokenizer(String parseString)
  • 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

      public String getText()
      Returns the string value corresponding to the last successful next(TokenKind) call.
    • next

      public boolean next(UriTokenizer.TokenKind allowedTokenKind)
      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:
      true if the token is found; false otherwise
      See Also: