KickJava   Java API By Example, From Geeks To Geeks.

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


1 package prefuse.data.expression;
2
3 import prefuse.data.Schema;
4 import prefuse.data.Tuple;
5
6 /**
7  * Literal expression of a boolean value.
8  * @author <a HREF="http://jheer.org">jeffrey heer</a>
9  */

10 public class BooleanLiteral extends Literal implements Predicate
11 {
12     /** The true boolean literal. */
13     public static final BooleanLiteral TRUE = new BooleanLiteral(true);
14     /** The false boolean literal. */
15     public static final BooleanLiteral FALSE = new BooleanLiteral(false);
16     
17     private final boolean m_value;
18     
19     /**
20      * Create a new BooleanLiteral.
21      * @param b the boolean value
22      */

23     public BooleanLiteral(boolean b) {
24         m_value = b;
25     }
26
27     /**
28      * @see prefuse.data.expression.Expression#getBoolean(prefuse.data.Tuple)
29      */

30     public boolean getBoolean(Tuple tuple) {
31         return m_value;
32     }
33
34     /**
35      * @see prefuse.data.expression.Expression#getType(prefuse.data.Schema)
36      */

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

44     public Object JavaDoc get(Tuple t) {
45         return ( getBoolean(t) ? Boolean.TRUE : Boolean.FALSE );
46     }
47     
48     /**
49      * @see java.lang.Object#toString()
50      */

51     public String JavaDoc toString() {
52         return String.valueOf(m_value).toUpperCase();
53     }
54     
55 } // end of class BooleanLiteral
56
Popular Tags