KickJava   Java API By Example, From Geeks To Geeks.

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


1 package prefuse.data.expression;
2
3 import prefuse.data.Schema;
4 import prefuse.data.Tuple;
5
6 /**
7  * Expression instance that returns the value stored in a Tuple data field.
8  *
9  * @author <a HREF="http://jheer.org">jeffrey heer</a>
10  */

11 public class ColumnExpression extends AbstractExpression implements Predicate {
12
13     protected final String JavaDoc m_field;
14     
15     /**
16      * Create a new ColumnExpression.
17      * @param field the column / data field name to use
18      */

19     public ColumnExpression(String JavaDoc field) {
20         m_field = field;
21     }
22     
23     /**
24      * Get the column / data field name used by this expression.
25      * @return the column / data field name
26      */

27     public String JavaDoc getColumnName() {
28         return m_field;
29     }
30     
31     // ------------------------------------------------------------------------
32
// Expression Interface
33

34     /**
35      * @see prefuse.data.expression.Expression#getType(prefuse.data.Schema)
36      */

37     public Class JavaDoc getType(Schema s) {
38         return s.getColumnType(m_field);
39     }
40
41     /**
42      * @see prefuse.data.expression.Expression#get(prefuse.data.Tuple)
43      */

44     public Object JavaDoc get(Tuple t) {
45         return t.get(m_field);
46     }
47
48     /**
49      * @see prefuse.data.expression.Expression#getInt(prefuse.data.Tuple)
50      */

51     public int getInt(Tuple t) {
52         return t.getInt(m_field);
53     }
54
55     /**
56      * @see prefuse.data.expression.Expression#getLong(prefuse.data.Tuple)
57      */

58     public long getLong(Tuple t) {
59         return t.getLong(m_field);
60     }
61
62     /**
63      * @see prefuse.data.expression.Expression#getFloat(prefuse.data.Tuple)
64      */

65     public float getFloat(Tuple t) {
66         return t.getFloat(m_field);
67     }
68
69     /**
70      * @see prefuse.data.expression.Expression#getDouble(prefuse.data.Tuple)
71      */

72     public double getDouble(Tuple t) {
73         return t.getDouble(m_field);
74     }
75
76     /**
77      * @see prefuse.data.expression.Expression#getBoolean(prefuse.data.Tuple)
78      */

79     public boolean getBoolean(Tuple t) {
80         return t.getBoolean(m_field);
81     }
82
83     /**
84      * @see java.lang.Object#toString()
85      */

86     public String JavaDoc toString() {
87         return "["+m_field+"]";
88     }
89     
90 } // end of class ColumnExpression
91
Popular Tags