Package com.singularsys.jep
Class FunctionTable
- java.lang.Object
-
- com.singularsys.jep.FunctionTable
-
- All Implemented Interfaces:
JepComponent
,java.io.Serializable
- Direct Known Subclasses:
BigDecFunctionTable
,CaseInsensitiveFunctionTable
,ComplexFunctionTable
,IntegerFunctionTable
,MatrixFunctionTable
,NullWrappedFunctionTable
,RationalFunctionTable
,RealFunctionTable
,StandardFunctionTable
public class FunctionTable extends java.lang.Object implements JepComponent
A table holding details of the functions known to Jep. This class has no functions loaded.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,PostfixMathCommandI>
table
-
Constructor Summary
Constructors Modifier Constructor Description FunctionTable()
Constructor with an empty map.protected
FunctionTable(java.util.Map<java.lang.String,PostfixMathCommandI> oldMap)
Constructor with a prespecified map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PostfixMathCommandI
addFunction(java.lang.String name, PostfixMathCommandI pfmc)
void
clear()
boolean
containsKey(java.lang.String key)
boolean
containsValue(PostfixMathCommandI value)
java.util.Set<java.util.Map.Entry<java.lang.String,PostfixMathCommandI>>
entrySet()
PostfixMathCommandI
getFunction(java.lang.String name)
JepComponent
getLightWeightInstance()
Returnsthis
.void
init(Jep jep)
Initialize the component.boolean
isEmpty()
java.util.Set<java.lang.String>
keySet()
PostfixMathCommandI
remove(java.lang.String key)
FunctionTable
shallowCopy()
Returns a new shallow copy of this function table.int
size()
protected java.util.Map<java.lang.String,PostfixMathCommandI>
threadSafeMapCopy()
Return a copy of the internal map with the same set of functions as this one.java.lang.String
toString()
java.util.Collection<PostfixMathCommandI>
values()
-
-
-
Field Detail
-
table
protected java.util.Map<java.lang.String,PostfixMathCommandI> table
-
-
Constructor Detail
-
FunctionTable
public FunctionTable()
Constructor with an empty map.
-
FunctionTable
protected FunctionTable(java.util.Map<java.lang.String,PostfixMathCommandI> oldMap)
Constructor with a prespecified map. Subclasses should define similar constructors to allow theshallowCopy()
to work.- Parameters:
oldMap
- map with existing set of functions- Since:
- 4.0
-
-
Method Detail
-
init
public void init(Jep jep)
Description copied from interface:JepComponent
Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.- Specified by:
init
in interfaceJepComponent
- Parameters:
jep
- the current Jep instance
-
getFunction
public PostfixMathCommandI getFunction(java.lang.String name)
-
addFunction
public PostfixMathCommandI addFunction(java.lang.String name, PostfixMathCommandI pfmc)
-
clear
public void clear()
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,PostfixMathCommandI>> entrySet()
-
isEmpty
public boolean isEmpty()
-
keySet
public java.util.Set<java.lang.String> keySet()
-
size
public int size()
-
values
public java.util.Collection<PostfixMathCommandI> values()
-
containsKey
public boolean containsKey(java.lang.String key)
-
containsValue
public boolean containsValue(PostfixMathCommandI value)
-
remove
public PostfixMathCommandI remove(java.lang.String key)
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Returnsthis
. If any functions are not thread-safe then useshallowCopy()
instead.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
this
-
threadSafeMapCopy
protected java.util.Map<java.lang.String,PostfixMathCommandI> threadSafeMapCopy()
Return a copy of the internal map with the same set of functions as this one. If any of the pfmc's implement theJepComponent
interface then that functionsJepComponent.getLightWeightInstance()
method will be called to return a thread safe function. This method can be combined with theFunctionTable(Map)
constructor to allow sub-classes to implement a thread-safegetLightWeightInstance()
method.- Returns:
- Since:
- 4.0
-
shallowCopy
public FunctionTable shallowCopy()
Returns a new shallow copy of this function table. Calls thethreadSafeMapCopy()
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 thethreadSafeMapCopy()
method to return a copy of the map of operators and a constructor taking this map which uses theFunctionTable(Map)
constructor.- Returns:
- a new shallow copy of this function table
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-