Class 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
    • 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 class java.lang.Object
      • toStringPrevious

        public java.lang.String toStringPrevious()
      • toStringRemainder

        public java.lang.String toStringRemainder()