public interface Expression
An Expression can be a variable, an application, or a literal value. If an access method (eg getName) is applied to an Expression for which it is not appropriate (eg an application), the result is unspecified; an implementation is free to throw an exception, deliver a null result, deliver a misleading value, whatever is convenient.
The nested class Util
provides some expression utility
methods, including a generic version of prepare
. The nested
abstract class Base
and its sub-classes Literal
,
Variable
, and Application
provide a framework
for developers to implement Expressions over.
Modifier and Type | Interface and Description |
---|---|
static class |
Expression.Application
An abstract base class for apply nodes; subclasses implement getFun(),
argCount(), and getArg().
|
static class |
Expression.Base
An abstract base class for Expressions; over-ride as appropriate.
|
static class |
Expression.BoolConstant
Base class used to implement
TRUE and FALSE . |
static class |
Expression.Constant
An abstract base class for literal nodes; subclasses implement getValue().
|
static class |
Expression.Fixed
A concrete class for representing fixed constants; each instance
can hold a separate value and its valuator returns that value.
|
static class |
Expression.Util
Utility methods for Expressions, captured in a class because they can't be
written directly in the interface.
|
static class |
Expression.Valof
Valof provides an implementation of VariableValues which composes the
"compile-time" VariableIndexes map with the "run-time" IndexValues map
to produce a VariableValues map.
|
static class |
Expression.Variable
An abstract base class for variable nodes; subclasses implement getName().
|
Modifier and Type | Field and Description |
---|---|
static Expression |
FALSE
An Expression which always evaluates to
false . |
static Expression |
TRUE
An Expression which always evaluates to
true . |
Modifier and Type | Method and Description |
---|---|
int |
argCount()
If this Expression is an application, answer the number of arguments that
it has.
|
Expression |
getArg(int i)
If this Expression is an application, and 0 <= i < argCount(), answer the
i th argument. |
String |
getFun()
If this Expression is an application, return the string identifying the function,
which should be a URI.
|
String |
getName()
If this Expression is a variable, answer a [non-null] String which is its name.
|
Object |
getValue()
If this Expression is a literal, answer the value of that literal.
|
boolean |
isApply()
Answer true iff this Expression represents the application of some function
[or operator] to some arguments [or operands].
|
boolean |
isConstant()
Answer true iff this Expression represents a literal [Java object] value.
|
boolean |
isVariable()
Answer true iff this Expression represents a variable.
|
Valuator |
prepare(VariableIndexes vi)
Answer a Valuator which, when run with a set of index-to-value bindings,
evaluates this expression in the light of the given variable-to-index bindings
[ie as though the variables were bound to the corresponding values]
|
static final Expression TRUE
true
.static final Expression FALSE
false
.Valuator prepare(VariableIndexes vi)
boolean isVariable()
String getName()
boolean isConstant()
Object getValue()
boolean isApply()
String getFun()
int argCount()
Expression getArg(int i)
i
th argument. Otherwise the behaviour is unspecified.Copyright ? 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP