Package com.singularsys.jep.misc
Class CaseInsensitiveFunctionTable
- java.lang.Object
-
- com.singularsys.jep.FunctionTable
-
- com.singularsys.jep.misc.CaseInsensitiveFunctionTable
-
- All Implemented Interfaces:
JepComponent
,java.io.Serializable
public class CaseInsensitiveFunctionTable extends FunctionTable
A version of a function table which is case insensitive.Note that this table does not include any functions by default. You will need to add any functions you need.
jep = new Jep(); jep.setComponent(new CaseInsensitiveFunctionTable()); jep.addFunction("if",new If()); jep.parse("if(1>0,2,3)"); System.out.println(jep.evaluate());
If you want to include all the functions in an existing table you can use
FunctionTable oldFT = jep.getFunctionTable(); jep.setComponent(new CaseInsensitiveFunctionTable()); for(Entry<String, PostfixMathCommandI> ent:oldFT.entrySet()) { jep.addFunction(ent.getKey(), ent.getValue()); }
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.FunctionTable
table
-
-
Constructor Summary
Constructors Modifier Constructor Description CaseInsensitiveFunctionTable()
protected
CaseInsensitiveFunctionTable(java.util.Map<java.lang.String,PostfixMathCommandI> tbl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PostfixMathCommandI
addFunction(java.lang.String name, PostfixMathCommandI pfmc)
boolean
containsKey(java.lang.String key)
PostfixMathCommandI
getFunction(java.lang.String name)
FunctionTable
shallowCopy()
Returns a new shallow copy of this function table.-
Methods inherited from class com.singularsys.jep.FunctionTable
clear, containsValue, entrySet, getLightWeightInstance, init, isEmpty, keySet, remove, size, threadSafeMapCopy, toString, values
-
-
-
-
Constructor Detail
-
CaseInsensitiveFunctionTable
public CaseInsensitiveFunctionTable()
-
CaseInsensitiveFunctionTable
protected CaseInsensitiveFunctionTable(java.util.Map<java.lang.String,PostfixMathCommandI> tbl)
-
-
Method Detail
-
getFunction
public PostfixMathCommandI getFunction(java.lang.String name)
- Overrides:
getFunction
in classFunctionTable
-
addFunction
public PostfixMathCommandI addFunction(java.lang.String name, PostfixMathCommandI pfmc)
- Overrides:
addFunction
in classFunctionTable
-
containsKey
public boolean containsKey(java.lang.String key)
- Overrides:
containsKey
in classFunctionTable
-
shallowCopy
public FunctionTable shallowCopy()
Description copied from class:FunctionTable
Returns a new shallow copy of this function table. Calls theFunctionTable.threadSafeMapCopy()
method to ensure the table is safe to use a separate thread. All sub-classes should override this methods to create a function table of the matching type. A typical implementation would be@Override public FunctionTable shallowCopy() { Map<String,PostfixMathCommandI> newMap = this.threadSafeMapCopy(); return new myFunctionTable(newMap); }
using theFunctionTable.threadSafeMapCopy()
method to return a copy of the map of operators and a constructor taking this map which uses theFunctionTable(Map)
constructor.- Overrides:
shallowCopy
in classFunctionTable
- Returns:
- a new shallow copy of this function table
-
-