public class FuncMap extends Object
FuncMap maps a name to a function. A FuncMap is used in the eval method of an Expression object. This class can be used as the default function-map. The loadDefaultFunctions() method can be used to take advantage of the many already implemented functions (see below).
During the evaluation of an expression, if a function is not supported then a RuntimeException is thrown.
Default functions:
Note: Case sensitivity can only be specified in the constructor (for consistency). When case sensitivity is false, the String.equalsIgnoreCase method is used. When case sensitivity is true, the String.equals method is used. The matching does not include the parenthesis. For example, when case sensitivity is false and the default functions have been loaded, then "RaNd", "rand", and "RAND" all map to the RandFunction(). By default, case sensitivity is false.
Constructor and Description |
---|
FuncMap() |
FuncMap(boolean caseSensitive) |
Modifier and Type | Method and Description |
---|---|
Function |
getFunction(String funcName,
int numParam)
Returns a function based on the name and the specified number of parameters.
|
String[] |
getFunctionNames()
Returns an array of exact length of the function names stored in this map.
|
Function[] |
getFunctions()
Returns an array of exact length of the functions stored in this map.
|
boolean |
isCaseSensitive()
Returns true if the case of the function names is considered.
|
void |
loadDefaultFunctions()
Adds the mappings for many common functions.
|
void |
remove(String funcName)
Removes the function-name and the associated function from the map.
|
void |
setFunction(String funcName,
Function f)
Assigns the name to map to the specified function.
|
public void loadDefaultFunctions()
public Function getFunction(String funcName, int numParam)
RuntimeException
- If no supporting function can be found.public void setFunction(String funcName, Function f)
IllegalArgumentException
- If any of the parameters are null.public boolean isCaseSensitive()
public String[] getFunctionNames()
public Function[] getFunctions()
public void remove(String funcName)
Copyright © 2016. All rights reserved.