org.exolab.adaptx.xpath.engine

Class Lexer

public class Lexer extends Object

A Lexical Analizer of XPath patterns and expressions

Version: $Revision: 4047 $ $Date: 2004-01-09 18:04:23 -0500 (Fri, 09 Jan 2004) $

Author: Keith Visco

Field Summary
static charADDITION_OP
static charAT_SYMBOL
static charCOLON
static charCOMMA
static charCR
static charDOLLAR_SYMBOL
static charD_QUOTE
static charEQUALS_OP
static charFORWARD_SLASH
static charGREATER_THAN_OP
static charLESS_THAN_OP
static charLF
static charL_BRACKET
static charL_PAREN
static charMULTIPLY_OP
static charNEGATION_OP
static charPERIOD
static charR_BRACKET
static charR_PAREN
static charSPACE
static charSUBTRACTION_OP
static charS_QUOTE
static Token[]tokenSet
the delimiter set of an ExprLexer
static charTAB
static charVERT_BAR
Constructor Summary
Lexer(String pattern)
Creates a new ExprLexer using the given String
Method Summary
intcountTokens()
Counts the number of times nextToken can be called without returning null
booleanhasMoreTokens()
Determines if there are any tokens available
static booleanisAdditiveOp(Token token)
static booleanisAxisIdentifier(Token token)
static booleanisBinaryOp(Token token)
booleanisDelimiter(char ch)
Determines if the specified char is a delimiter
static booleanisDigit(char ch)
Returns true if the char argument is a digit
static booleanisEqualityOp(Token token)
static booleanisLetter(char ch)
Returns true if the char argument is a letter
static booleanisMultiplicativeOp(Token token)
static booleanisNCNameChar(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
booleanisOperator(Token token)
static booleanisQNameChar(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
static booleanisRelationalOp(Token token)
static booleanisWhitespace(char ch)
TokenlookAhead(int offset)
Allows looking ahead for tokens without affecting the token sequence as called by nextToken or previousToken.
TokennextToken()
Retrieves the next available token
voidpushBack()
Moves the position of this Lexer back one
voidresetPosition()
Resets the position of the token pointer to the beginning
StringtoString()
StringtoStringPrevious()
StringtoStringRemainder()

Field Detail

ADDITION_OP

public static final char ADDITION_OP

AT_SYMBOL

public static final char AT_SYMBOL

COLON

public static final char COLON

COMMA

public static final char COMMA

CR

public static final char CR

DOLLAR_SYMBOL

public static final char DOLLAR_SYMBOL

D_QUOTE

public static final char D_QUOTE

EQUALS_OP

public static final char EQUALS_OP

FORWARD_SLASH

public static final char FORWARD_SLASH

GREATER_THAN_OP

public static final char GREATER_THAN_OP

LESS_THAN_OP

public static final char LESS_THAN_OP

LF

public static final char LF

L_BRACKET

public static final char L_BRACKET

L_PAREN

public static final char L_PAREN

MULTIPLY_OP

public static final char MULTIPLY_OP

NEGATION_OP

public static final char NEGATION_OP

PERIOD

public static final char PERIOD

R_BRACKET

public static final char R_BRACKET

R_PAREN

public static final char R_PAREN

SPACE

public static final char SPACE

SUBTRACTION_OP

public static final char SUBTRACTION_OP

S_QUOTE

public static final char S_QUOTE

tokenSet

public static final Token[] tokenSet
the delimiter set of an ExprLexer

TAB

public static final char TAB

VERT_BAR

public static final char VERT_BAR

Constructor Detail

Lexer

public Lexer(String pattern)
Creates a new ExprLexer using the given String

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

isAdditiveOp

public static boolean isAdditiveOp(Token token)

isAxisIdentifier

public static boolean isAxisIdentifier(Token token)

isBinaryOp

public static boolean isBinaryOp(Token token)

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

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

isEqualityOp

public static boolean isEqualityOp(Token token)

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

isMultiplicativeOp

public static boolean isMultiplicativeOp(Token token)

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

isOperator

public boolean isOperator(Token token)

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

isRelationalOp

public static boolean isRelationalOp(Token token)

isWhitespace

public static boolean isWhitespace(char ch)

lookAhead

public Token lookAhead(int offset)
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: 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 String toString()

toStringPrevious

public String toStringPrevious()

toStringRemainder

public String toStringRemainder()