prefuse.data.expression
Interface Expression

All Known Subinterfaces:
Function, Predicate
All Known Implementing Classes:
AbstractExpression, AbstractPredicate, BooleanLiteral, ColumnExpression, ComparisonPredicate, FunctionExpression, GroupExpression, HoverPredicate, InGroupPredicate, RangePredicate, StartVisiblePredicate, ValidatedPredicate, VisiblePredicate

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.

Author:
jeffrey heer

Method Summary
 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
 

Method Detail

getType

public java.lang.Class getType(Schema s)
Returns the type that this expression evaluates to when tuples with the given Schema are provided as input.


visit

public void visit(ExpressionVisitor v)
Passes the visitor through this expression and any sub expressions

Parameters:
v - the ExpressionVisitor

get

public java.lang.Object get(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as an Object

getInt

public int getInt(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as an int

getLong

public long getLong(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as a long

getFloat

public float getFloat(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as a float

getDouble

public double getDouble(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as a double

getBoolean

public boolean getBoolean(Tuple t)
Evaluate the Expression on the given input Tuple.

Parameters:
t - the input Tuple
Returns:
the Expression return value, as a boolean

addExpressionListener

public void addExpressionListener(ExpressionListener lstnr)
Add a listener to this Expression.

Parameters:
lstnr - the expression listener to add

removeExpressionListener

public void removeExpressionListener(ExpressionListener lstnr)
Remove a listener to this Expression.

Parameters:
lstnr - the expression listener to remove


Copyright ? 2007 Regents of the University of California