|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rafa.math.gen.Function
public class Function
Wrapper around a
MESP
parser, which simplifies the task of retrieving automatically non-default
functions from named generators in the NameRegistry
.
Field Summary | |
---|---|
protected static java.lang.String[] |
DEFAULTS
The default function names as provided by MESP's FuncMap.loadDefaultFunctions() . |
protected static java.lang.String |
X
The independent variable |
Constructor Summary | |
---|---|
Function(java.lang.String function)
|
|
Function(java.lang.String function,
java.util.Map<java.lang.String,java.lang.Number> vars,
java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
|
Method Summary | |
---|---|
protected void |
checkName(java.lang.String name)
Checks that a function name is valid for the parser. |
java.util.Collection<Dependency> |
getDependencies(java.lang.Object target)
Gets detailed information about the dependencies of this object on a given one. |
protected java.util.List<java.lang.String> |
getFunctionNames()
Retrieves the names of the functions (helpers) actually used by this one, i.e. |
double |
getValue(double xValue,
boolean refreshFunctions)
Gets the function value for a given value of x . |
protected void |
loadFuncMap()
Loads every known function - predefined by MESP and user-defined (in the name registry) - for later use. |
protected void |
loadFuncMap(java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
Loads functions which may be used as helpers. |
void |
loadFunction(java.lang.String n)
Loads one helper function from the name registry into the function map. |
void |
loadFunction(java.lang.String f,
java.util.List<? extends java.lang.Number> list)
Loads a list of numbers to be used as a helper function by this one. |
void |
loadVariable(java.lang.String name,
java.lang.Number value)
Loads a variable to be used from this function. |
protected void |
loadVarMap(java.util.Map<java.lang.String,java.lang.Number> vars)
|
protected void |
parse(java.lang.String function)
Updates the function expression. |
protected void |
parse(java.lang.String function,
java.util.Map<java.lang.String,java.lang.Number> vars,
java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
|
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String X
protected static final java.lang.String[] DEFAULTS
FuncMap.loadDefaultFunctions()
.
Constructor Detail |
---|
public Function(java.lang.String function)
public Function(java.lang.String function, java.util.Map<java.lang.String,java.lang.Number> vars, java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
Method Detail |
---|
protected void loadVarMap(java.util.Map<java.lang.String,java.lang.Number> vars)
protected void loadFuncMap()
protected void loadFuncMap(java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
name registry
(user-defined,
global scope) and the passed parameter (user-defined, local
scope).
funcs
- the functions to be used locally in this one (not shared
with any others).public void loadFunction(java.lang.String n)
n
- The name of the function (generator) as stored in the name
registry.public void loadFunction(java.lang.String f, java.util.List<? extends java.lang.Number> list)
foo
, the string foo(0)
will evaluate to 11
and foo(3)
to 33.
f
- the name given to the function.list
- A list of numbers. If null
, the
NameRegistry
is searched for the name to get a
number generator
.public void loadVariable(java.lang.String name, java.lang.Number value)
name
- the variable name.value
- the variable value.public double getValue(double xValue, boolean refreshFunctions)
x
.
xValue
- the value assigned to the x
variable
in the expression.refreshFunctions
- should the function map be refreshed?
protected void parse(java.lang.String function)
function
- protected void parse(java.lang.String function, java.util.Map<java.lang.String,java.lang.Number> vars, java.util.Map<java.lang.String,java.util.List<? extends java.lang.Number>> funcs)
public java.lang.String toString()
toString
in class java.lang.Object
protected java.util.List<java.lang.String> getFunctionNames()
protected void checkName(java.lang.String name) throws InvalidNameException
NameRegistry
, but only for existing predefined default functions
(see DEFAULTS
).
name
- a function name
ExistingNameException
- if the name collides with a predefined
function name.
InvalidNameException
- if the name is not valid.public java.util.Collection<Dependency> getDependencies(java.lang.Object target)
Dependent
getDependencies
in interface Dependent
target
- the required object. If null
, all of the
dependencies will be returned.
Dependency
objects pointing to the same
object (target
), or null
if there is no
dependency on that object.public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |