View Javadoc

1   /*
2    * $Header: /home/projects/jaxen/scm/jaxen/src/java/main/org/jaxen/saxpath/base/TokenTypes.java,v 1.4 2004/09/16 21:05:25 bewins Exp $
3    * $Revision: 1.4 $
4    * $Date: 2004/09/16 21:05:25 $
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.4 2004/09/16 21:05:25 bewins Exp $
60   */
61  
62  package org.jaxen.saxpath.base;
63  
64  
65  
66  class TokenTypes
67  {
68      static final int LEFT_PAREN = 1;
69      static final int RIGHT_PAREN = 2;
70  
71      static final int LEFT_BRACKET = 3;
72      static final int RIGHT_BRACKET = 4;
73  
74      static final int PLUS = 5;
75      static final int MINUS = 6;
76      static final int LESS_THAN = 7;
77      static final int LESS_THAN_EQUALS = 8;
78      static final int GREATER_THAN = 9;
79      static final int GREATER_THAN_EQUALS = 10;
80  
81      static final int SLASH = 11;
82      static final int DOUBLE_SLASH = 12;
83      static final int DOT = 13;
84      static final int DOT_DOT = 14;
85  
86      static final int IDENTIFIER = 15;
87  
88      static final int AT = 16;
89      static final int PIPE = 17;
90      static final int COLON = 18;
91      static final int DOUBLE_COLON = 19;
92      static final int STAR = 20;
93  
94      static final int EQUALS = 21;
95      static final int NOT_EQUALS = 22;
96      static final int NOT = 23;
97  
98      static final int DIV = 24;
99      static final int MOD = 25;
100 
101     static final int DOLLAR = 26;
102 
103     static final int LITERAL = 27;
104 
105     static final int AND = 28;
106     static final int OR = 29;
107 
108     static final int INTEGER = 30;
109     static final int DOUBLE = 31;
110 
111     static final int COMMA = 32;
112 
113     //static final int SKIP = 99;
114     //static final int EOF = 100;
115     static final int SKIP = -2;
116     static final int EOF = -1;
117     static final int ERROR = -3;
118 
119     String getTokenText( int tokenType )
120     {
121         switch( tokenType )
122         {
123             case LEFT_PAREN:
124                 return "(";
125             case RIGHT_PAREN:
126                 return ")";
127             case LEFT_BRACKET:
128                 return "[";
129             case RIGHT_BRACKET:
130                 return "]";
131             case PLUS:
132                 return "+";
133             case MINUS:
134                 return "-";
135             case LESS_THAN:
136                 return "<";
137             case LESS_THAN_EQUALS:
138                 return "<=";
139             case GREATER_THAN:
140                 return ">";
141             case GREATER_THAN_EQUALS:
142                 return ">=";
143             case SLASH:
144                 return "/";
145             case DOUBLE_SLASH:
146                 return "//";
147             case DOT:
148                 return ".";
149             case DOT_DOT:
150                 return "..";
151             case IDENTIFIER:
152                 return "(identifier)";
153             case AT:
154                 return "@";
155             case PIPE:
156                 return "|";
157             case COLON:
158                 return ":";
159             case DOUBLE_COLON:
160                 return "::";
161             case STAR:
162                 return "*";
163 
164             case EQUALS:
165                 return "=";
166             case NOT_EQUALS:
167                 return "!=";
168             case NOT:
169                 return "!";
170             case DIV:
171                 return "div";
172             case MOD:
173                 return "mod";
174 
175             case DOLLAR:
176                 return "$";
177 
178             case LITERAL:
179                 return "(literal)";
180             case AND:
181                 return "and";
182             case OR:
183                 return "or";
184             case INTEGER:
185                 return "(integer)";
186             case DOUBLE:
187                 return "(double)";
188             case COMMA:
189                 return ",";
190             case ERROR:
191                 return "(error)";
192             default:
193                 return null;
194         }
195     }
196 }