2 Copyright 2011 frank asseg
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
17 package de.congrace.exp4j;
19 import java.text.NumberFormat;
20 import java.util.ArrayList;
21 import java.util.List;
24 * Abstract base class for mathematical expressions
26 * @author fas@congrace.de
28 abstract class AbstractExpression {
29 private final String expression;
30 private final Token[] tokens;
31 private final String[] variableStrings;
32 private final NumberFormat numberFormat = NumberFormat.getInstance();
35 * Construct a new {@link AbstractExpression}
38 * the mathematical expression to be used
40 * the {@link Token}s in the expression
41 * @param variableNames
42 * an array of variable names which are used in the expression
44 AbstractExpression(String expression, Token[] tokens, String[] variableStrings) {
45 this.expression = expression;
47 this.variableStrings = variableStrings;
51 * get the mathematical expression {@link String}
53 * @return the expression
55 public String getExpression() {
60 * get the used {@link NumberFormat}
62 * @return the used {@link NumberFormat}
64 public NumberFormat getNumberFormat() {
69 * get the {@link Token}s
71 * @return the array of {@link Token}s