org.exolab.adaptx.xpath.engine

Class Lexer


public class Lexer
extends java.lang.Object

A Lexical Analizer of XPath patterns and expressions
Version:
$Revision: 1.1.1.1 $ $Date: 2003/03/01 07:39:40 $
Author:
Keith Visco

Field Summary

static char
ADDITION_OP
static char
AT_SYMBOL
static char
COLON
static char
COMMA
static char
CR
static char
DOLLAR_SYMBOL
static char
D_QUOTE
static char
EQUALS_OP
static char
FORWARD_SLASH
static char
GREATER_THAN_OP
static char
LESS_THAN_OP
static char
LF
static char
L_BRACKET
static char
L_PAREN
static char
MULTIPLY_OP
static char
NEGATION_OP
static char
PERIOD
static char
R_BRACKET
static char
R_PAREN
static char
SPACE
static char
SUBTRACTION_OP
static char
S_QUOTE
static char
TAB
static char
VERT_BAR
static Token[]
tokenSet
the delimiter set of an ExprLexer

Constructor Summary

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

Method Summary

int
countTokens()
Counts the number of times nextToken can be called without returning null
boolean
hasMoreTokens()
Determines if there are any tokens available
static 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 delimiter
static boolean
isDigit(char ch)
Returns true if the char argument is a digit
static boolean
isEqualityOp(Token token)
static boolean
isLetter(char ch)
Returns true if the char argument is a letter
static 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-199904114
boolean
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-199904114
static 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 token
void
pushBack()
Moves the position of this Lexer back one
void
resetPosition()
Resets the position of the token pointer to the beginning
String
toString()
String
toStringPrevious()
String
toStringRemainder()

Field Details

ADDITION_OP

public static final char ADDITION_OP
Field Value:
'+'

AT_SYMBOL

public static final char AT_SYMBOL
Field Value:
'@'

COLON

public static final char COLON
Field Value:
':'

COMMA

public static final char COMMA
Field Value:
','

CR

public static final char CR
Field Value:
'\r'

DOLLAR_SYMBOL

public static final char DOLLAR_SYMBOL
Field Value:
'$'

D_QUOTE

public static final char D_QUOTE
Field Value:
'\'

EQUALS_OP

public static final char EQUALS_OP
Field Value:
'='

FORWARD_SLASH

public static final char FORWARD_SLASH
Field Value:
'/'

GREATER_THAN_OP

public static final char GREATER_THAN_OP
Field Value:
'>'

LESS_THAN_OP

public static final char LESS_THAN_OP
Field Value:
'<'

LF

public static final char LF
Field Value:
'\n'

L_BRACKET

public static final char L_BRACKET
Field Value:
'['

L_PAREN

public static final char L_PAREN
Field Value:
'('

MULTIPLY_OP

public static final char MULTIPLY_OP
Field Value:
'*'

NEGATION_OP

public static final char NEGATION_OP
Field Value:
'!'

PERIOD

public static final char PERIOD
Field Value:
'.'

R_BRACKET

public static final char R_BRACKET
Field Value:
']'

R_PAREN

public static final char R_PAREN
Field Value:
')'

SPACE

public static final char SPACE
Field Value:
' '

SUBTRACTION_OP

public static final char SUBTRACTION_OP
Field Value:
'-'

S_QUOTE

public static final char S_QUOTE
Field Value:
'\'

TAB

public static final char TAB
Field Value:
'\t'

VERT_BAR

public static final char VERT_BAR
Field Value:
'|'

tokenSet

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

Constructor Details

Lexer

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

Method Details

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)
            throws 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

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()