com.hp.hpl.jena.graph.query
Interface Expression
- All Known Implementing Classes:
- Expression.Base, Expression.BoolConstant
- 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.
- Author:
- kers
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.Literal
An abstract base class for literal nodes; subclasses implement getValue(). |
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. |
boolean |
evalBool(VariableValues vv)
Answer true iff the Expression evaluates to true given the variable bindings. |
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 |
isLiteral()
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 does the same evaluation as this Expression when
supplied with a mapping from variable indexes to their values. |
TRUE
public static final Expression TRUE
- An Expression which always evaluates to
true
.
FALSE
public static final Expression FALSE
- An Expression which always evaluates to
false
.
evalBool
public boolean evalBool(VariableValues vv)
- Answer true iff the Expression evaluates to true given the variable bindings.
- Parameters:
vv
- the mapping from variable[ name]s to their values
prepare
public Valuator prepare(VariableIndexes vi)
- Answer a Valuator which does the same evaluation as this Expression when
supplied with a mapping from variable indexes to their values. The
composition of the variable->index map
vi
and the
index->value map given to the valuator is equivalent to the VariableValues
map that would be supplied to evalBool
.
isVariable
public boolean isVariable()
- Answer true iff this Expression represents a variable.
getName
public java.lang.String getName()
- If this Expression is a variable, answer a [non-null] String which is its name.
Otherwise the behaviour is unspecified.
isLiteral
public boolean isLiteral()
- Answer true iff this Expression represents a literal [Java object] value.
getValue
public java.lang.Object getValue()
- If this Expression is a literal, answer the value of that literal. Otherwise the
behaviour is unspecified.
isApply
public boolean isApply()
- Answer true iff this Expression represents the application of some function
[or operator] to some arguments [or operands].
getFun
public java.lang.String getFun()
- If this Expression is an application, return the string identifying the function,
which should be a URI. Otherwise the behaviour is unspecified.
argCount
public int argCount()
- If this Expression is an application, answer the number of arguments that
it has. Otherwise the behaviour is unspecified.
getArg
public Expression getArg(int i)
- If this Expression is an application, and 0 <= i < argCount(), answer the
i
th argument. Otherwise the behaviour is unspecified.
Copyright © 2000-2003 Hewlett-Packard. All Rights Reserved.