public interface Expression
An Expression is an arbitrary function that takes a single Tuple as an
argument. Expressions support both Object-valued and primitive-valued
(int, long, float, double, boolean) evaluation methods. The appropriate
method to call depends on the particular Expression implementation.
A getType(Schema)
method provides mechanism for determining the
return type of a given Expression instance. A Predicate
is an
Expression which is guaranteed to support the getBoolean(Tuple)
method, is often used to filter tuples.
Expressions also support a listener interface, allowing clients to monitor changes to expressions, namely rearrangements or modification of contained sub-expressions. The Expression interface also supports visitors, which can be used to visit every sub-expression in an expression tree.
Using the various Expression implementations in the
Expression
package, clients can
programatically construct a tree of expressions for use as complex
query predicates or as functions for computing a derived data column
(see Table.addColumn(String, Expression)
. Often it is
more convenient to write expressions in the prefuse expression language,
a SQL-like data manipulation language, and compile the Expression tree
using the ExpressionParser
. The
documentation for the ExpressionParser class includes a full reference
for the textual expression language.
Modifier and Type | Method and Description |
---|---|
void |
addExpressionListener(ExpressionListener lstnr)
Add a listener to this Expression.
|
java.lang.Object |
get(Tuple t)
Evaluate the Expression on the given input Tuple.
|
boolean |
getBoolean(Tuple t)
Evaluate the Expression on the given input Tuple.
|
double |
getDouble(Tuple t)
Evaluate the Expression on the given input Tuple.
|
float |
getFloat(Tuple t)
Evaluate the Expression on the given input Tuple.
|
int |
getInt(Tuple t)
Evaluate the Expression on the given input Tuple.
|
long |
getLong(Tuple t)
Evaluate the Expression on the given input Tuple.
|
java.lang.Class |
getType(Schema s)
Returns the type that this expression evaluates to when tuples
with the given Schema are provided as input.
|
void |
removeExpressionListener(ExpressionListener lstnr)
Remove a listener to this Expression.
|
void |
visit(ExpressionVisitor v)
Passes the visitor through this expression and any sub expressions
|
java.lang.Class getType(Schema s)
void visit(ExpressionVisitor v)
v
- the ExpressionVisitorjava.lang.Object get(Tuple t)
t
- the input Tupleint getInt(Tuple t)
t
- the input Tuplelong getLong(Tuple t)
t
- the input Tuplefloat getFloat(Tuple t)
t
- the input Tupledouble getDouble(Tuple t)
t
- the input Tupleboolean getBoolean(Tuple t)
t
- the input Tuplevoid addExpressionListener(ExpressionListener lstnr)
lstnr
- the expression listener to addvoid removeExpressionListener(ExpressionListener lstnr)
lstnr
- the expression listener to removeCopyright ? 2013 Regents of the University of California