Package com.singularsys.jep.misc
Class CaseInsensitiveFunctionTable
java.lang.Object
com.singularsys.jep.FunctionTable
com.singularsys.jep.misc.CaseInsensitiveFunctionTable
- All Implemented Interfaces:
JepComponent
,Serializable
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:
-
Field Summary
Fields inherited from class com.singularsys.jep.FunctionTable
table
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionaddFunction
(String name, PostfixMathCommandI pfmc) boolean
containsKey
(String key) getFunction
(String name) 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 Details
-
CaseInsensitiveFunctionTable
public CaseInsensitiveFunctionTable() -
CaseInsensitiveFunctionTable
-
-
Method Details
-
getFunction
- Overrides:
getFunction
in classFunctionTable
-
addFunction
- Overrides:
addFunction
in classFunctionTable
-
containsKey
- Overrides:
containsKey
in classFunctionTable
-
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 subclasses should override this method 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
-