Package org.exolab.adaptx.xpath.engine
Class Lexer
- java.lang.Object
-
- org.exolab.adaptx.xpath.engine.Lexer
-
public class Lexer extends java.lang.Object
A Lexical Analizer of XPath patterns and expressions- Version:
- $Revision: 4047 $ $Date: 2004-01-10 00:04:23 +0100 (Sat, 10 Jan 2004) $
- Author:
- Keith Visco
-
-
Field Summary
Fields Modifier and Type Field Description static char
ADDITION_OP
static char
AT_SYMBOL
static char
COLON
static char
COMMA
static char
CR
static char
D_QUOTE
static char
DOLLAR_SYMBOL
static char
EQUALS_OP
static char
FORWARD_SLASH
static char
GREATER_THAN_OP
static char
L_BRACKET
static char
L_PAREN
static char
LESS_THAN_OP
static char
LF
static char
MULTIPLY_OP
static char
NEGATION_OP
static char
PERIOD
static char
R_BRACKET
static char
R_PAREN
static char
S_QUOTE
static char
SPACE
static char
SUBTRACTION_OP
static char
TAB
static Token[]
tokenSet
the delimiter set of an ExprLexerstatic char
VERT_BAR
-
Constructor Summary
Constructors Constructor Description Lexer(java.lang.String pattern)
Creates a new ExprLexer using the given String
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countTokens()
Counts the number of times nextToken can be called without returning nullboolean
hasMoreTokens()
Determines if there are any tokens availablestatic boolean
isAdditiveOp(Token token)
static boolean
isAxisIdentifier(Token token)
static boolean
isBinaryOp(Token token)
boolean
isDelimiter(char ch)
Determines if the specified char is a delimiterstatic boolean
isDigit(char ch)
Returns true if the char argument is a digitstatic boolean
isEqualityOp(Token token)
static boolean
isLetter(char ch)
Returns true if the char argument is a letterstatic boolean
isMultiplicativeOp(Token token)
static boolean
isNCNameChar(char ch)
Returns true if the char argument is an NCNameChar, as defined by the XML Namespaces recommendation http://www.w3c.org/TR/1999/REC-xml-names-199904114boolean
isOperator(Token token)
static boolean
isQNameChar(char ch)
Returns true if the char argument is an QName character, as defined by the XML Namespaces recommendation http://www.w3c.org/TR/1999/REC-xml-names-199904114static boolean
isRelationalOp(Token token)
static boolean
isWhitespace(char ch)
Token
lookAhead(int offset)
Allows looking ahead for tokens without affecting the token sequence as called by nextToken or previousToken.Token
nextToken()
Retrieves the next available tokenvoid
pushBack()
Moves the position of this Lexer back onevoid
resetPosition()
Resets the position of the token pointer to the beginningjava.lang.String
toString()
java.lang.String
toStringPrevious()
java.lang.String
toStringRemainder()
-
-
-
Field Detail
-
FORWARD_SLASH
public static final char FORWARD_SLASH
- See Also:
- Constant Field Values
-
L_PAREN
public static final char L_PAREN
- See Also:
- Constant Field Values
-
R_PAREN
public static final char R_PAREN
- See Also:
- Constant Field Values
-
L_BRACKET
public static final char L_BRACKET
- See Also:
- Constant Field Values
-
R_BRACKET
public static final char R_BRACKET
- See Also:
- Constant Field Values
-
PERIOD
public static final char PERIOD
- See Also:
- Constant Field Values
-
COMMA
public static final char COMMA
- See Also:
- Constant Field Values
-
AT_SYMBOL
public static final char AT_SYMBOL
- See Also:
- Constant Field Values
-
DOLLAR_SYMBOL
public static final char DOLLAR_SYMBOL
- See Also:
- Constant Field Values
-
S_QUOTE
public static final char S_QUOTE
- See Also:
- Constant Field Values
-
D_QUOTE
public static final char D_QUOTE
- See Also:
- Constant Field Values
-
VERT_BAR
public static final char VERT_BAR
- See Also:
- Constant Field Values
-
COLON
public static final char COLON
- See Also:
- Constant Field Values
-
SPACE
public static final char SPACE
- See Also:
- Constant Field Values
-
TAB
public static final char TAB
- See Also:
- Constant Field Values
-
LF
public static final char LF
- See Also:
- Constant Field Values
-
CR
public static final char CR
- See Also:
- Constant Field Values
-
NEGATION_OP
public static final char NEGATION_OP
- See Also:
- Constant Field Values
-
EQUALS_OP
public static final char EQUALS_OP
- See Also:
- Constant Field Values
-
ADDITION_OP
public static final char ADDITION_OP
- See Also:
- Constant Field Values
-
SUBTRACTION_OP
public static final char SUBTRACTION_OP
- See Also:
- Constant Field Values
-
LESS_THAN_OP
public static final char LESS_THAN_OP
- See Also:
- Constant Field Values
-
GREATER_THAN_OP
public static final char GREATER_THAN_OP
- See Also:
- Constant Field Values
-
MULTIPLY_OP
public static final char MULTIPLY_OP
- See Also:
- Constant Field Values
-
tokenSet
public static final Token[] tokenSet
the delimiter set of an ExprLexer
-
-
Constructor Detail
-
Lexer
public Lexer(java.lang.String pattern) throws ParseException
Creates a new ExprLexer using the given String- Throws:
ParseException
-
-
Method Detail
-
countTokens
public int countTokens()
Counts the number of times nextToken can be called without returning null
-
hasMoreTokens
public boolean hasMoreTokens()
Determines if there are any tokens available- Returns:
- true if there are tokens available, otherwise false
-
isDelimiter
public boolean isDelimiter(char ch)
Determines if the specified char is a delimiter- Parameters:
ch
- the char to compare to the delimiters- Returns:
- true if the String argument is a delimiter
-
isOperator
public boolean isOperator(Token token)
-
isAdditiveOp
public static boolean isAdditiveOp(Token token)
-
isAxisIdentifier
public static boolean isAxisIdentifier(Token token)
-
isBinaryOp
public static boolean isBinaryOp(Token token)
-
isEqualityOp
public static boolean isEqualityOp(Token token)
-
isRelationalOp
public static boolean isRelationalOp(Token token)
-
isMultiplicativeOp
public static boolean isMultiplicativeOp(Token token)
-
isDigit
public static boolean isDigit(char ch)
Returns true if the char argument is a digit- Returns:
- true if the char argument is a digit
-
isLetter
public static boolean isLetter(char ch)
Returns true if the char argument is a letter- Returns:
- true if the char argument is a letter
-
isNCNameChar
public static boolean isNCNameChar(char ch)
Returns true if the char argument is an NCNameChar, as defined by the XML Namespaces recommendation http://www.w3c.org/TR/1999/REC-xml-names-199904114- Returns:
- true if the char argument is an NCNameChar
-
isQNameChar
public static boolean isQNameChar(char ch)
Returns true if the char argument is an QName character, as defined by the XML Namespaces recommendation http://www.w3c.org/TR/1999/REC-xml-names-199904114- Returns:
- true if the char argument is an QName character
-
isWhitespace
public static boolean isWhitespace(char ch)
-
lookAhead
public Token lookAhead(int offset) throws java.lang.IllegalArgumentException
Allows looking ahead for tokens without affecting the token sequence as called by nextToken or previousToken. If offset based on the next token, so an offset of 0 will- Parameters:
offset
- the number of tokens to lookAhead- Returns:
- the next token
- Throws:
java.lang.IllegalArgumentException
- if offset is less than 0.
-
nextToken
public Token nextToken()
Retrieves the next available token- Returns:
- the next available token or null if there are none
-
pushBack
public void pushBack()
Moves the position of this Lexer back one
-
resetPosition
public void resetPosition()
Resets the position of the token pointer to the beginning
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringPrevious
public java.lang.String toStringPrevious()
-
toStringRemainder
public java.lang.String toStringRemainder()
-
-