KickJava   Java API By Example, From Geeks To Geeks.

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


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

9 public class PjReference
10     extends PjObject {
11
12     /**
13        Creates a PDF reference object.
14        @param obj the object number for the new reference.
15     */

16     public PjReference(PjNumber obj) {
17         _obj = obj;
18         _gen = PjNumber.ZERO;
19     }
20
21     /**
22        Creates a PDF reference object.
23        @param obj the object number for the new reference.
24        @param gen the generation number for the new reference.
25     */

26     public PjReference(PjNumber obj, PjNumber gen) {
27         _obj = obj;
28         _gen = gen;
29     }
30
31     /**
32        Returns the object number referenced by this PDF reference.
33        @return the object number within this PDF reference.
34     */

35     public PjNumber getObjNumber() {
36         return _obj;
37     }
38
39     /**
40        Returns the generation number referenced by this PDF reference.
41        @return the generation number within this PDF reference.
42     */

43     public PjNumber getGenNumber() {
44         return _gen;
45     }
46
47     /**
48        Writes this PDF reference object to a stream in PDF format.
49        @param os the stream to write to.
50        @return the number of bytes written.
51        @exception IOException if an I/O error occurs.
52     */

53     public long writePdf(OutputStream os) throws IOException {
54         long z = _obj.writePdf(os);
55         z = z + write(os, " ");
56         z = z + _gen.writePdf(os);
57         z = z + write(os, " R");
58         return z;
59     }
60
61     /**
62        Returns a string representation of this reference in PDF format.
63        @return the string representation.
64     public String toString() {
65         return _obj.toString() + ' ' + _gen.toString() + " R";
66     }
67      */

68
69     /**
70        Returns a deep copy of this object.
71        @return a deep copy of this object.
72     */

73     public Object JavaDoc clone() {
74         return this;
75     }
76     
77     /**
78        Compares two PjReference objects for equality.
79        @param obj the reference object to compare to.
80        @return true if this object is the same as obj, false
81        otherwise.
82     */

83     public boolean equals(Object JavaDoc obj) {
84         if (obj == null) {
85             return false;
86         }
87         if (obj instanceof PjReference) {
88             return ( (_obj.equals(((PjReference)obj)._obj)) &&
89                  (_gen.equals(((PjReference)obj)._gen)) );
90         } else {
91             return false;
92         }
93     }
94
95     /**
96        Returns a hash code value for the object.
97        @return a hashcode value for this object.
98     */

99     public int hashCode() {
100         return _obj.hashCode();
101     }
102     
103     private PjNumber _obj;
104     private PjNumber _gen;
105     
106 }
107
Popular Tags