|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.parser.AbstractFunction
Class AbstractFunction encapsulates a
function definition and its corresponding
String name for for use with a parser.
This class is abstract since the method
functionCall must be defined in a
derived class.
As of 2.5.0, the class AbstractParser
was made concrete and renamed BaseParser.
At that time, its static inner classes were extracted
and made standalone. This class was formerly named
Procedure but the name
AbstractFunction seemed more descriptive.
This class should not be confused with the class
Function in edu.neu.ccs.
The latter class is defined solely to collect several
interfaces that are useful in classifying
mathematical functions.
| Field Summary | |
private int |
arguments
The number of arguments required by this function. |
private String |
name
The name representing this function. |
| Constructor Summary | |
AbstractFunction(String name,
int arguments)
Constructs a function with the given String name
and given number of expected arguments. |
|
| Method Summary | |
int |
arguments()
Returns the number of arguments of this function. |
void |
checkValues(Object[] values)
Throws a ParseExpection if: the values are null
the length of values is not equal to arguments
|
void |
checkValuesAsNumeric(Object[] values)
Throws a ParseExpection if: the values are null
the length of values is not equal to arguments
the elements in values are not of type XNumber
|
void |
checkValuesAsXObject(Object[] values)
Throws a ParseExpection if: the values are null
the length of values is not equal to arguments
the elements in values are not of type XObject
|
abstract Object |
functionCall(Object[] values)
Applies the function using the provided array of argument values whose length must equal the number of arguments and returns its result. |
static AbstractFunction |
makeFourArg(String name,
Function.FourArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.FourArg
for its implementation. |
static AbstractFunction |
makeNoArg(String name,
Function.NoArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.NoArg
for its implementation. |
static AbstractFunction |
makeOneArg(String name,
Function.OneArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.OneArg
for its implementation. |
static AbstractFunction |
makeThreeArg(String name,
Function.ThreeArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.ThreeArg
for its implementation. |
static AbstractFunction |
makeTwoArg(String name,
Function.TwoArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.TwoArg
for its implementation. |
String |
name()
Returns the String name of this function. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private String name
private int arguments
| Constructor Detail |
public AbstractFunction(String name,
int arguments)
Constructs a function
with the given String name
and given number of expected arguments.
The given name is trimmed prior to being used to define the function name.
Throws IllegalArgumentException
if the name is not valid when tested by
BaseParser.isPossibleIdentifier or
if the given arguments value is negative.
name - the identifier for this functionarguments - the required number of arguments
IllegalArgumentException| Method Detail |
public abstract Object functionCall(Object[] values)
throws ParseException
Applies the function using the provided array of argument values whose length must equal the number of arguments and returns its result.
values - the array of argument values
ParseExceptionpublic final String name()
String name of this function.
public final int arguments()
public final void checkValues(Object[] values)
throws ParseException
null
values - the array of argument values
ParseException
public final void checkValuesAsXObject(Object[] values)
throws ParseException
null
values - the array of argument values
ParseException
public final void checkValuesAsNumeric(Object[] values)
throws ParseException
null
values - the array of argument values
ParseException
public static AbstractFunction makeNoArg(String name,
Function.NoArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.NoArg
for its implementation.
Naturally, this function will require 0 arguments.
name - the function name to be used in a parserf - the implementation function
IllegalArgumentException
public static AbstractFunction makeOneArg(String name,
Function.OneArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.OneArg
for its implementation.
Naturally, this function will require 1 argument.
name - the function name to be used in a parserf - the implementation function
IllegalArgumentException
public static AbstractFunction makeTwoArg(String name,
Function.TwoArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.TwoArg
for its implementation.
Naturally, this function will require 2 arguments.
name - the function name to be used in a parserf - the implementation function
IllegalArgumentException
public static AbstractFunction makeThreeArg(String name,
Function.ThreeArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.ThreeArg
for its implementation.
Naturally, this function will require 3 arguments.
name - the function name to be used in a parserf - the implementation function
IllegalArgumentException
public static AbstractFunction makeFourArg(String name,
Function.FourArg f)
Constructs an AbstractFunction object
using the given name
and the givenFunction.FourArg
for its implementation.
Naturally, this function will require 1 argument.
name - the function name to be used in a parserf - the implementation function
IllegalArgumentException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||