Class ExpressionTokenizer
java.lang.Object
org.apache.catalina.ssi.ExpressionTokenizer
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
FieldsModifier and TypeFieldDescriptionstatic final intToken type for the AND operator.static final intToken type indicating end of expression.static final intToken type for the equality operator.static final intToken type for the greater-than-or-equal operator.static final intToken type for the greater-than operator.static final intToken type for a left brace.static final intToken type for the less-than-or-equal operator.static final intToken type for the less-than operator.static final intToken type for the NOT operator.static final intToken type for the not-equal operator.static final intToken type for the OR operator.static final intToken type for a right brace.static final intToken type for a string literal. -
Constructor Summary
ConstructorsConstructorDescriptionExpressionTokenizer(String expr) Creates a new parser for the specified expression. -
Method Summary
Modifier and TypeMethodDescriptionintgetIndex()Returns the current index in the expression.Returns the string value of the most recently parsed token.booleanChecks if there are more tokens available.protected booleanisMetaChar(char c) Checks if the given character is a meta character used for tokenization.intParses the next token from the expression.
-
Field Details
-
TOKEN_STRING
public static final int TOKEN_STRINGToken type for a string literal.- See Also:
-
TOKEN_AND
public static final int TOKEN_ANDToken type for the AND operator.- See Also:
-
TOKEN_OR
public static final int TOKEN_ORToken type for the OR operator.- See Also:
-
TOKEN_NOT
public static final int TOKEN_NOTToken type for the NOT operator.- See Also:
-
TOKEN_EQ
public static final int TOKEN_EQToken type for the equality operator.- See Also:
-
TOKEN_NOT_EQ
public static final int TOKEN_NOT_EQToken type for the not-equal operator.- See Also:
-
TOKEN_RBRACE
public static final int TOKEN_RBRACEToken type for a right brace.- See Also:
-
TOKEN_LBRACE
public static final int TOKEN_LBRACEToken type for a left brace.- See Also:
-
TOKEN_GE
public static final int TOKEN_GEToken type for the greater-than-or-equal operator.- See Also:
-
TOKEN_LE
public static final int TOKEN_LEToken type for the less-than-or-equal operator.- See Also:
-
TOKEN_GT
public static final int TOKEN_GTToken type for the greater-than operator.- See Also:
-
TOKEN_LT
public static final int TOKEN_LTToken type for the less-than operator.- See Also:
-
TOKEN_END
public static final int TOKEN_ENDToken type indicating end of expression.- See Also:
-
-
Constructor Details
-
ExpressionTokenizer
Creates a new parser for the specified expression.- Parameters:
expr- The expression
-
-
Method Details
-
hasMoreTokens
public boolean hasMoreTokens()Checks if there are more tokens available.- Returns:
trueif 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:
trueif 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
Returns the string value of the most recently parsed token.- Returns:
- the string value if the token was of type TOKEN_STRING, otherwise
null
-