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) Add a function to the table.booleancontainsKey(String key) getFunction(String name) Get the function with the given name.Returns a new shallow copy of this function table.Methods inherited from class com.singularsys.jep.FunctionTable
addFunctionIfSet, clear, containsValue, copyFunctionsFrom, entrySet, getLightWeightInstance, init, isEmpty, keySet, remove, size, threadSafeMapCopy, toString, values
-
Constructor Details
-
CaseInsensitiveFunctionTable
public CaseInsensitiveFunctionTable() -
CaseInsensitiveFunctionTable
-
-
Method Details
-
getFunction
Description copied from class:FunctionTableGet the function with the given name.- Overrides:
getFunctionin classFunctionTable- Parameters:
name- function name- Returns:
- the function or null if not found
-
addFunction
Description copied from class:FunctionTableAdd a function to the table.- Overrides:
addFunctionin classFunctionTable- Parameters:
name- name of the functionpfmc- the implementation of the function- Returns:
- the previous function with the same name or null if none
-
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 functions and a constructor taking this map which uses theFunctionTable(Map)constructor.- Overrides:
shallowCopyin classFunctionTable- Returns:
- a new shallow copy of this function table
-