|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Expression
Expression - the interface for expressions that is expected by Query for constraints. An Expression can be evaluated (given a name->value mapping); it can be prepared into a Valuator (given a name->index mapping); and it can be analysed into its components.
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.
Nested Class Summary | |
---|---|
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(). |
Field Summary | |
---|---|
static Expression |
FALSE
An Expression which always evaluates to false . |
static Expression |
TRUE
An Expression which always evaluates to true . |
Method Summary | |
---|---|
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. |
java.lang.String |
getFun()
If this Expression is an application, return the string identifying the function, which should be a URI. |
java.lang.String |
getName()
If this Expression is a variable, answer a [non-null] String which is its name. |
java.lang.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] |
Field Detail |
---|
static final Expression TRUE
true
.
static final Expression FALSE
false
.
Method Detail |
---|
Valuator prepare(VariableIndexes vi)
boolean isVariable()
java.lang.String getName()
boolean isConstant()
java.lang.Object getValue()
boolean isApply()
java.lang.String getFun()
int argCount()
Expression getArg(int i)
i
th argument. Otherwise the behaviour is unspecified.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |