Class ExpressionTokenizer


  • public class ExpressionTokenizer
    extends java.lang.Object
    Parses an expression string to return the individual tokens. This is patterned similar to the StreamTokenizer in the JDK but customized for SSI conditional expression parsing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int TOKEN_AND
      Token type for the AND operator.
      static int TOKEN_END
      Token type indicating end of expression.
      static int TOKEN_EQ
      Token type for the equality operator.
      static int TOKEN_GE
      Token type for the greater-than-or-equal operator.
      static int TOKEN_GT
      Token type for the greater-than operator.
      static int TOKEN_LBRACE
      Token type for a left brace.
      static int TOKEN_LE
      Token type for the less-than-or-equal operator.
      static int TOKEN_LT
      Token type for the less-than operator.
      static int TOKEN_NOT
      Token type for the NOT operator.
      static int TOKEN_NOT_EQ
      Token type for the not-equal operator.
      static int TOKEN_OR
      Token type for the OR operator.
      static int TOKEN_RBRACE
      Token type for a right brace.
      static int TOKEN_STRING
      Token type for a string literal.
    • Constructor Summary

      Constructors 
      Constructor Description
      ExpressionTokenizer​(java.lang.String expr)
      Creates a new parser for the specified expression.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIndex()
      Returns the current index in the expression.
      java.lang.String getTokenValue()
      Returns the string value of the most recently parsed token.
      boolean hasMoreTokens()
      Checks if there are more tokens available.
      protected boolean isMetaChar​(char c)
      Checks if the given character is a meta character used for tokenization.
      int nextToken()
      Parses the next token from the expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TOKEN_STRING

        public static final int TOKEN_STRING
        Token type for a string literal.
        See Also:
        Constant Field Values
      • TOKEN_AND

        public static final int TOKEN_AND
        Token type for the AND operator.
        See Also:
        Constant Field Values
      • TOKEN_OR

        public static final int TOKEN_OR
        Token type for the OR operator.
        See Also:
        Constant Field Values
      • TOKEN_NOT

        public static final int TOKEN_NOT
        Token type for the NOT operator.
        See Also:
        Constant Field Values
      • TOKEN_EQ

        public static final int TOKEN_EQ
        Token type for the equality operator.
        See Also:
        Constant Field Values
      • TOKEN_NOT_EQ

        public static final int TOKEN_NOT_EQ
        Token type for the not-equal operator.
        See Also:
        Constant Field Values
      • TOKEN_RBRACE

        public static final int TOKEN_RBRACE
        Token type for a right brace.
        See Also:
        Constant Field Values
      • TOKEN_LBRACE

        public static final int TOKEN_LBRACE
        Token type for a left brace.
        See Also:
        Constant Field Values
      • TOKEN_GE

        public static final int TOKEN_GE
        Token type for the greater-than-or-equal operator.
        See Also:
        Constant Field Values
      • TOKEN_LE

        public static final int TOKEN_LE
        Token type for the less-than-or-equal operator.
        See Also:
        Constant Field Values
      • TOKEN_GT

        public static final int TOKEN_GT
        Token type for the greater-than operator.
        See Also:
        Constant Field Values
      • TOKEN_LT

        public static final int TOKEN_LT
        Token type for the less-than operator.
        See Also:
        Constant Field Values
      • TOKEN_END

        public static final int TOKEN_END
        Token type indicating end of expression.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExpressionTokenizer

        public ExpressionTokenizer​(java.lang.String expr)
        Creates a new parser for the specified expression.
        Parameters:
        expr - The expression
    • Method Detail

      • hasMoreTokens

        public boolean hasMoreTokens()
        Checks if there are more tokens available.
        Returns:
        true if there are more tokens
      • getIndex

        public int getIndex()
        Returns the current index in the expression.
        Returns:
        the current index for error reporting purposes
      • isMetaChar

        protected boolean isMetaChar​(char c)
        Checks if the given character is a meta character used for tokenization.
        Parameters:
        c - the character to check
        Returns:
        true if the character is whitespace or an operator character
      • nextToken

        public int nextToken()
        Parses the next token from the expression.
        Returns:
        the next token type constant
      • getTokenValue

        public java.lang.String getTokenValue()
        Returns the string value of the most recently parsed token.
        Returns:
        the string value if the token was of type TOKEN_STRING, otherwise null