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
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionaddFunction(String name, PostfixMathCommandI pfmc) booleancontainsKey(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:
getFunctionin classFunctionTable
-
addFunction
- Overrides:
addFunctionin classFunctionTable
-
containsKey
- Overrides:
containsKeyin classFunctionTable
-
shallowCopy
Description copied from class:FunctionTableReturns 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:
shallowCopyin classFunctionTable- Returns:
- a new shallow copy of this function table
-