001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.language.simple.types;
018
019/**
020 * The different token types used by the simple parser.
021 */
022public class SimpleTokenType {
023
024    private final TokenType type;
025    private final String value;
026
027    public SimpleTokenType(TokenType type, String value) {
028        this.type = type;
029        this.value = value;
030    }
031
032    /**
033     * Gets the type of this token
034     *
035     * @return the type
036     */
037    public TokenType getType() {
038        return type;
039    }
040
041    /**
042     * Gets the input value in this token
043     *
044     * @return the value
045     */
046    public String getValue() {
047        return value;
048    }
049
050    /**
051     * Whether the type is whitespace
052     */
053    public boolean isWhitespace() {
054        return type == TokenType.whiteSpace;
055    }
056
057    /**
058     * Whether the type is eol
059     */
060    public boolean isEol() {
061        return type == TokenType.eol;
062    }
063
064    /**
065     * Whether the type is escape
066     */
067    public boolean isEscape() {
068        return type == TokenType.escape;
069    }
070
071    /**
072     * Whether the type is single quote
073     */
074    public boolean isSingleQuote() {
075        return type == TokenType.singleQuote;
076    }
077
078    /**
079     * Whether the type is double quote
080     */
081    public boolean isDoubleQuote() {
082        return type == TokenType.doubleQuote;
083    }
084
085    /**
086     * Whether the type is a function start
087     */
088    public boolean isFunctionStart() {
089        return type == TokenType.functionStart;
090    }
091
092    /**
093     * Whether the type is a function end
094     */
095    public boolean isFunctionEnd() {
096        return type == TokenType.functionEnd;
097    }
098
099    /**
100     * Whether the type is binary operator
101     */
102    public boolean isBinary() {
103        return type == TokenType.binaryOperator;
104    }
105
106    /**
107     * Whether the type is unary operator
108     */
109    public boolean isUnary() {
110        return type == TokenType.unaryOperator;
111    }
112
113    /**
114     * Whether the type is logical operator
115     */
116    public boolean isLogical() {
117        return type == TokenType.logicalOperator;
118    }
119
120    /**
121     * Whether the type is a null value
122     */
123    public boolean isNullValue() {
124        return type == TokenType.nullValue;
125    }
126
127    @Override
128    public String toString() {
129        return value;
130    }
131}