View Javadoc

    1   /*
    2    * $Header: /home/projects/jaxen/scm/jaxen/src/java/main/org/jaxen/saxpath/base/TokenTypes.java,v 1.8 2005/06/28 13:44:45 elharo Exp $
    3    * $Revision: 1.8 $
    4    * $Date: 2005/06/28 13:44:45 $
    5    *
    6    * ====================================================================
    7    *
    8    * Copyright (C) 2000-2004 bob mcwhirter & James Strachan.
    9    * All rights reserved.
    10   *
    11   * Redistribution and use in source and binary forms, with or without
    12   * modification, are permitted provided that the following conditions
    13   * are met:
    14   *
    15   * 1. Redistributions of source code must retain the above copyright
    16   *    notice, this list of conditions, and the following disclaimer.
    17   *
    18   * 2. Redistributions in binary form must reproduce the above copyright
    19   *    notice, this list of conditions, and the disclaimer that follows
    20   *    these conditions in the documentation and/or other materials
    21   *    provided with the distribution.
    22   *
    23   * 3. The name "Jaxen" must not be used to endorse or promote products
    24   *    derived from this software without prior written permission.  For
    25   *    written permission, please contact license@jaxen.org.
    26   *
    27   * 4. Products derived from this software may not be called "Jaxen", nor
    28   *    may "Jaxen" appear in their name, without prior written permission
    29   *    from the Jaxen Project Management (pm@jaxen.org).
    30   *
    31   * In addition, we request (but do not require) that you include in the
    32   * end-user documentation provided with the redistribution and/or in the
    33   * software itself an acknowledgement equivalent to the following:
    34   *     "This product includes software developed by the
    35   *      Jaxen Project <http://www.jaxen.org/>."
    36   * Alternatively, the acknowledgment may be graphical using the logos
    37   * available at http://www.jaxen.org/
    38   *
    39   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    40   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    41   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    42   * DISCLAIMED.  IN NO EVENT SHALL THE Jaxen AUTHORS OR THE PROJECT
    43   * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    44   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    45   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    46   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    47   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    48   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    49   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    50   * SUCH DAMAGE.
    51   *
    52   * ====================================================================
    53   * This software consists of voluntary contributions made by many
    54   * individuals on behalf of the Jaxen Project and was originally
    55   * created by bob mcwhirter <bob@werken.com> and
    56   * James Strachan <jstrachan@apache.org>.  For more information on the
    57   * Jaxen Project, please see <http://www.jaxen.org/>.
    58   *
    59   * $Id: TokenTypes.java,v 1.8 2005/06/28 13:44:45 elharo Exp $
    60   */
    61
    62  package org.jaxen.saxpath.base;
    63
    64  import org.jaxen.JaxenRuntimeException;
    65
    66
    67
    68  class TokenTypes
    69  {
    70      static final int EOF   = -1;
    71      static final int SKIP  = -2;
    72      static final int ERROR = -3;
    73
    74      static final int EQUALS = 1;
    75      static final int NOT_EQUALS = 2;
    76
    77      static final int LESS_THAN_SIGN = 3;
    78      static final int LESS_THAN_OR_EQUALS_SIGN = 4;
    79      static final int GREATER_THAN_SIGN = 5;
    80      static final int GREATER_THAN_OR_EQUALS_SIGN = 6;
    81
    82      static final int PLUS  = 7;
    83      static final int MINUS = 8;
    84      static final int STAR  = 9;
    85      static final int MOD   = 10;
    86      static final int DIV   = 11;
    87
    88      static final int SLASH = 12;
    89      static final int DOUBLE_SLASH = 13;
    90      static final int DOT = 14;
    91      static final int DOT_DOT = 15;
    92
    93      static final int IDENTIFIER = 16;
    94
    95      static final int AT = 17;
    96      static final int PIPE = 18;
    97      static final int COLON = 19;
    98      static final int DOUBLE_COLON = 20;
    99
    100     static final int LEFT_BRACKET = 21;
    101     static final int RIGHT_BRACKET = 22;
    102     static final int LEFT_PAREN = 23;
    103     static final int RIGHT_PAREN = 24;
    104
    105     static final int NOT = 25;
    106     static final int DOLLAR = 26;
    107     static final int LITERAL = 27;
    108     static final int AND = 28;
    109     static final int OR = 29;
    110
    111     static final int INTEGER = 30;
    112     static final int DOUBLE = 31;
    113
    114     static final int COMMA = 32;
    115
    116     static String getTokenText( int tokenType )
    117     {
    118         switch( tokenType )
    119         {
    120             case ERROR:
    121                 return "(error)";
    122             case EQUALS:
    123                 return "=";
    124             case NOT_EQUALS:
    125                 return "!=";
    126             case LESS_THAN_SIGN:
    127                 return "<";
    128             case LESS_THAN_OR_EQUALS_SIGN:
    129                 return "<=";
    130             case GREATER_THAN_SIGN:
    131                 return ">";
    132             case GREATER_THAN_OR_EQUALS_SIGN:
    133                 return ">=";
    134             case PLUS:
    135                 return "+";
    136             case MINUS:
    137                 return "-";
    138             case STAR:
    139                 return "*";
    140             case DIV:
    141                 return "div";
    142             case MOD:
    143                 return "mod";
    144             case SLASH:
    145                 return "/";
    146             case DOUBLE_SLASH:
    147                 return "//";
    148             case DOT:
    149                 return ".";
    150             case DOT_DOT:
    151                 return "..";
    152             case IDENTIFIER:
    153                 return "(identifier)";
    154             case AT:
    155                 return "@";
    156             case PIPE:
    157                 return "|";
    158             case COLON:
    159                 return ":";
    160             case DOUBLE_COLON:
    161                 return "::";
    162             case LEFT_BRACKET:
    163                 return "[";
    164             case RIGHT_BRACKET:
    165                 return "]";
    166             case LEFT_PAREN:
    167                 return "(";
    168             case RIGHT_PAREN:
    169                 return ")";
    170             case NOT:
    171                 return "!";
    172             case DOLLAR:
    173                 return "$";
    174             case LITERAL:
    175                 return "(literal)";
    176             case AND:
    177                 return "and";
    178             case OR:
    179                 return "or";
    180             case INTEGER:
    181                 return "(integer)";
    182             case DOUBLE:
    183                 return "(double)";
    184             case COMMA:
    185                 return ",";
    186             default:
    187                 throw new JaxenRuntimeException("Unrecognized token type: " + tokenType);
    188         }
    189     }
    190 }