|
Building Parsers with Java | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sjm.examples.sling.SlingFunction
SlingFunction is an abstract class that
requires subclasses to implement the method Point
f(double t). Subclasses typically accept other
functions in their constructors, and wrap some base
function around these subfunctions. The
SlingFunction class stores the subfunctions
in a SlingFunction array it calls
source. The function that a subclass
supplies should correspond to the name of the class,
such as Sin.
This class provides two methods that subclasses
typically will not override: fresh and
eval. The fresh method creates
a special type of clone. The eval method
creates a new version of an object, evaluating any
variables in the object's subfunctions to non-variable
values.
| Field Summary | |
protected SlingFunction[] |
source
|
| Constructor Summary | |
SlingFunction()
Construct a function that wraps nothing. |
|
SlingFunction(SlingFunction source)
Construct a function that wraps the provided function. |
|
SlingFunction(SlingFunction[] source)
Construct a function that wraps the provided functions. |
|
SlingFunction(SlingFunction source0,
SlingFunction source1)
Construct a function that wraps the provided functions. |
|
| Method Summary | |
SlingFunction |
eval()
Creates a new version of an object, evaluating any variables in the object's subfunctions to non-variable values. |
Extrema |
extrema(int nPoint)
Return the extreme values of this function will reach when rendered with the given number of points. |
abstract Point |
f(double t)
This is the function that all subclasses implement, so that each function class provides a two-dimensional function of time. |
SlingFunction |
fresh()
Creates a copy of the object and initializes the
source array to an array of the right length,
but leaves the elements of the array empty. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected SlingFunction[] source
| Constructor Detail |
public SlingFunction()
public SlingFunction(SlingFunction[] source)
public SlingFunction(SlingFunction source)
public SlingFunction(SlingFunction source0,
SlingFunction source1)
| Method Detail |
public SlingFunction eval()
For example, an object of subclass Arithmetic
might contain r*cos(theta). If
r has a value of 2 and theta
has a value of, say, 2*pi*t, then the object
will evaluate to 2*cos(2*pi*t).
public Extrema extrema(int nPoint)
int - the number of points to consider in
rendering the functionpublic abstract Point f(double t)
t - a number that represents how far along a
plot is, and thus tells which point to
returnpublic SlingFunction fresh()
source array to an array of the right length,
but leaves the elements of the array empty.
|
by Steve Metsker | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||