KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > expression > Expression


1 package prefuse.data.expression;
2
3 import prefuse.data.Schema;
4 import prefuse.data.Tuple;
5 import prefuse.data.event.ExpressionListener;
6
7 /**
8  * <p>An Expression is an arbitrary function that takes a single Tuple as an
9  * argument. Expressions support both Object-valued and primitive-valued
10  * (int, long, float, double, boolean) evaluation methods. The appropriate
11  * method to call depends on the particular Expression implementation.
12  * A {@link #getType(Schema)} method provides mechanism for determining the
13  * return type of a given Expression instance. A {@link Predicate} is an
14  * Expression which is guaranteed to support the {@link #getBoolean(Tuple)}
15  * method, is often used to filter tuples.</p>
16  *
17  * <p>Expressions also support a listener interface, allowing clients to
18  * monitor changes to expressions, namely rearrangements or modification
19  * of contained sub-expressions. The Expression interface also supports
20  * visitors, which can be used to visit every sub-expression in an expression
21  * tree.</p>
22  *
23  * <p>Using the various Expression implementations in the
24  * {@link prefuse.data.expression.Expression} package, clients can
25  * programatically construct a tree of expressions for use as complex
26  * query predicates or as functions for computing a derived data column
27  * (see {@link prefuse.data.Table#addColumn(String, Expression)}. Often it is
28  * more convenient to write expressions in the prefuse expression language,
29  * a SQL-like data manipulation language, and compile the Expression tree
30  * using the {@link prefuse.data.expression.parser.ExpressionParser}. The
31  * documentation for the ExpressionParser class includes a full reference
32  * for the textual expression language.</p>
33  *
34  * @author <a HREF="http://jheer.org">jeffrey heer</a>
35  */

36 public interface Expression {
37
38     /**
39      * Returns the type that this expression evaluates to when tuples
40      * with the given Schema are provided as input.
41      */

42     public Class JavaDoc getType(Schema s);
43     
44     /**
45      * Passes the visitor through this expression and any sub expressions
46      * @param v the ExpressionVisitor
47      */

48     public void visit(ExpressionVisitor v);
49     
50     /**
51      * Evaluate the Expression on the given input Tuple.
52      * @param t the input Tuple
53      * @return the Expression return value, as an Object
54      */

55     public Object JavaDoc get(Tuple t);
56     
57     /**
58      * Evaluate the Expression on the given input Tuple.
59      * @param t the input Tuple
60      * @return the Expression return value, as an int
61      */

62     public int getInt(Tuple t);
63     
64     /**
65      * Evaluate the Expression on the given input Tuple.
66      * @param t the input Tuple
67      * @return the Expression return value, as a long
68      */

69     public long getLong(Tuple t);
70     
71     /**
72      * Evaluate the Expression on the given input Tuple.
73      * @param t the input Tuple
74      * @return the Expression return value, as a float
75      */

76     public float getFloat(Tuple t);
77
78     /**
79      * Evaluate the Expression on the given input Tuple.
80      * @param t the input Tuple
81      * @return the Expression return value, as a double
82      */

83     public double getDouble(Tuple t);
84
85     /**
86      * Evaluate the Expression on the given input Tuple.
87      * @param t the input Tuple
88      * @return the Expression return value, as a boolean
89      */

90     public boolean getBoolean(Tuple t);
91     
92     /**
93      * Add a listener to this Expression.
94      * @param lstnr the expression listener to add
95      */

96     public void addExpressionListener(ExpressionListener lstnr);
97     
98     /**
99      * Remove a listener to this Expression.
100      * @param lstnr the expression listener to remove
101      */

102     public void removeExpressionListener(ExpressionListener lstnr);
103     
104 } // end of interface Expression
105
Popular Tags