Package cl.obcom.desktopfx.expr
Class Function
java.lang.Object
cl.obcom.desktopfx.expr.Function
Function evaluator that can be used in an
Expression
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
checkFunctionArgs
(List<Expression> args) Throws an exception if the number ofargs
is less than the number of required function arguments (argc
).abstract Object
evaluate
(List<Expression> args) Evaluates this function using the supplied list of arguments.final int
getArgc()
Returns the number of required arguments of this function.final String
getName()
Returns the name of this function.
-
Constructor Details
-
Function
Constructs a newFunction
instance with given name.- Parameters:
name
- the name of the function.argc
- the number of required function arguments.- Throws:
NullPointerException
- ifname
isnull
.IllegalArgumentException
- ifargc
is negative.
-
-
Method Details
-
getName
Returns the name of this function.- Returns:
- the name of this function.
-
getArgc
public final int getArgc()Returns the number of required arguments of this function.- Returns:
- the number of required arguments of this function.
-
checkFunctionArgs
Throws an exception if the number ofargs
is less than the number of required function arguments (argc
). Ifargs
isnull
, this method assumes zero arguments.- Parameters:
args
- the arguments passed toevaluate
(can be null).- Throws:
ExpressionException
- if number ofargs
is less thanargc
.
-
evaluate
Evaluates this function using the supplied list of arguments.- Parameters:
args
- the arguments required for the evaluation (can be null).- Returns:
- the result of evaluating this function with supplied arguments.
- Throws:
Exception
- if an error occurs evaluating the function.
-