01: package com.etymon.pj.object;
02:
03: import java.io.*;
04:
05: /**
06: A representation of the PDF Boolean type.
07: @author Nassib Nassar
08: */
09: public class PjBoolean extends PjObject {
10:
11: /**
12: Creates a Boolean object.
13: @param b the Boolean value to initialize this object to.
14: */
15: public PjBoolean(boolean b) {
16: _b = b;
17: }
18:
19: /**
20: Returns the Boolean value of this object.
21: @return the Boolean value of this object.
22: */
23: public boolean getBoolean() {
24: return _b;
25: }
26:
27: /**
28: Writes this Boolean to a stream in PDF format.
29: @param os the stream to write to.
30: @return the number of bytes written.
31: @exception IOException if an I/O error occurs.
32: */
33: public long writePdf(OutputStream os) throws IOException {
34: if (_b) {
35: return write(os, "true");
36: } else {
37: return write(os, "false");
38: }
39: }
40:
41: /**
42: Returns a string representation of this Boolean in PDF format.
43: @return the string representation.
44: public String toString() {
45: if (_b) {
46: return "true";
47: } else {
48: return "false";
49: }
50: }
51: */
52:
53: /**
54: Returns a deep copy of this object.
55: @return a deep copy of this object.
56: */
57: public Object clone() {
58: return this ;
59: }
60:
61: /**
62: Compares two PjBoolean objects for equality.
63: @param obj the reference object to compare to.
64: @return true if this object is the same as obj, false
65: otherwise.
66: */
67: public boolean equals(Object obj) {
68: if (obj == null) {
69: return false;
70: }
71: if (obj instanceof PjBoolean) {
72: return (_b == ((PjBoolean) obj)._b);
73: } else {
74: return false;
75: }
76: }
77:
78: public static final PjBoolean TRUE = new PjBoolean(true);
79: public static final PjBoolean FALSE = new PjBoolean(false);
80:
81: private boolean _b;
82:
83: }
|