908e50753beb9b09445218d732c9712a8d07b2b2
[debian/openrocket] / core / src / net / sf / openrocket / util / exp4j / AbstractExpression.java
1 /*
2    Copyright 2011 frank asseg
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  */
17 package net.sf.openrocket.util.exp4j;
18
19 import java.text.NumberFormat;
20 import java.util.List;
21
22 /**
23  * Abstract base class for mathematical expressions
24  * 
25  * @author fas@congrace.de
26  */
27 abstract class AbstractExpression {
28         private final String expression;
29         private final Token[] tokens;
30         private final String[] variableNames;
31         private final NumberFormat numberFormat = NumberFormat.getInstance();
32
33         /**
34          * Construct a new {@link AbstractExpression}
35          * 
36          * @param expression
37          *            the mathematical expression to be used
38          * @param tokens
39          *            the {@link Token}s in the expression
40          * @param variableNames
41          *            an array of variable names which are used in the expression
42          */
43         AbstractExpression(String expression, Token[] tokens, String[] variableNames) {
44                 this.expression = expression;
45                 this.tokens = tokens;
46                 this.variableNames = variableNames;
47         }
48
49         /**
50          * get the mathematical expression {@link String}
51          * 
52          * @return the expression
53          */
54         public String getExpression() {
55                 return expression;
56         }
57
58         /**
59          * get the used {@link NumberFormat}
60          * 
61          * @return the used {@link NumberFormat}
62          */
63         public NumberFormat getNumberFormat() {
64                 return numberFormat;
65         }
66
67         /**
68          * get the {@link Token}s
69          * 
70          * @return the array of {@link Token}s
71          */
72         Token[] getTokens() {
73                 return tokens;
74         }
75
76         /**
77          * get the variable names
78          * 
79          * @return the {@link List} of variable names
80          */
81         String[] getVariableNames() {
82                 return variableNames;
83         }
84
85 }