1 /* 2 * Copyright 2002-2009 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.springframework.expression.spel.standard; 17 18 /** 19 * @author Andy Clement 20 * @since 3.0 21 */ 22 enum TokenKind { 23 // ordered by priority - operands first 24 LITERAL_INT, LITERAL_LONG, LITERAL_HEXINT, LITERAL_HEXLONG, LITERAL_STRING, LITERAL_REAL, LITERAL_REAL_FLOAT, 25 LPAREN("("), RPAREN(")"), COMMA(","), IDENTIFIER, 26 COLON(":"),HASH("#"),RSQUARE("]"), LSQUARE("["), 27 LCURLY("{"),RCURLY("}"), 28 DOT("."), PLUS("+"), STAR("*"), MINUS("-"), SELECT_FIRST("^["), SELECT_LAST("$["), QMARK("?"), PROJECT("!["), 29 DIV("/"), GE(">="), GT(">"), LE("<="), LT("<"), EQ("=="), NE("!="), 30 MOD("%"), NOT("!"), ASSIGN("="), INSTANCEOF("instanceof"), MATCHES("matches"), BETWEEN("between"), 31 SELECT("?["), POWER("^"), 32 ELVIS("?:"), SAFE_NAVI("?."), BEAN_REF("@") 33 ; 34 35 char[] tokenChars; 36 private boolean hasPayload; // is there more to this token than simply the kind 37 TokenKind(String tokenString)38 private TokenKind(String tokenString) { 39 tokenChars = tokenString.toCharArray(); 40 hasPayload = tokenChars.length==0; 41 } 42 TokenKind()43 private TokenKind() { 44 this(""); 45 } 46 toString()47 public String toString() { 48 return this.name()+(tokenChars.length!=0?"("+new String(tokenChars)+")":""); 49 } 50 hasPayload()51 public boolean hasPayload() { 52 return hasPayload; 53 } 54 getLength()55 public int getLength() { 56 return tokenChars.length; 57 } 58 }