KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > etymon > pj > object > PjBoolean


1 package com.etymon.pj.object;
2
3 import java.io.*;
4
5 /**
6    A representation of the PDF Boolean type.
7    @author Nassib Nassar
8 */

9 public class PjBoolean
10     extends PjObject {
11
12     /**
13        Creates a Boolean object.
14        @param b the Boolean value to initialize this object to.
15     */

16     public PjBoolean(boolean b) {
17         _b = b;
18     }
19
20     /**
21        Returns the Boolean value of this object.
22        @return the Boolean value of this object.
23     */

24     public boolean getBoolean() {
25         return _b;
26     }
27
28     /**
29        Writes this Boolean to a stream in PDF format.
30        @param os the stream to write to.
31        @return the number of bytes written.
32        @exception IOException if an I/O error occurs.
33      */

34     public long writePdf(OutputStream os) throws IOException {
35         if (_b) {
36             return write(os, "true");
37         } else {
38             return write(os, "false");
39         }
40     }
41
42     /**
43        Returns a string representation of this Boolean in PDF format.
44        @return the string representation.
45        public String toString() {
46         if (_b) {
47             return "true";
48         } else {
49             return "false";
50         }
51     }
52     */

53
54     /**
55        Returns a deep copy of this object.
56        @return a deep copy of this object.
57     */

58     public Object JavaDoc clone() {
59         return this;
60     }
61     
62     /**
63        Compares two PjBoolean objects for equality.
64        @param obj the reference object to compare to.
65        @return true if this object is the same as obj, false
66        otherwise.
67     */

68     public boolean equals(Object JavaDoc obj) {
69         if (obj == null) {
70             return false;
71         }
72         if (obj instanceof PjBoolean) {
73             return (_b == ((PjBoolean)obj)._b);
74         } else {
75             return false;
76         }
77     }
78     
79         public static final PjBoolean TRUE = new PjBoolean(true);
80         public static final PjBoolean FALSE = new PjBoolean(false);
81
82     private boolean _b;
83     
84 }
85
Popular Tags