001: package com.etymon.pj.object;
002:
003: import java.io.*;
004:
005: /**
006: A representation of the PDF reference type.
007: @author Nassib Nassar
008: */
009: public class PjReference extends PjObject {
010:
011: /**
012: Creates a PDF reference object.
013: @param obj the object number for the new reference.
014: */
015: public PjReference(PjNumber obj) {
016: _obj = obj;
017: _gen = PjNumber.ZERO;
018: }
019:
020: /**
021: Creates a PDF reference object.
022: @param obj the object number for the new reference.
023: @param gen the generation number for the new reference.
024: */
025: public PjReference(PjNumber obj, PjNumber gen) {
026: _obj = obj;
027: _gen = gen;
028: }
029:
030: /**
031: Returns the object number referenced by this PDF reference.
032: @return the object number within this PDF reference.
033: */
034: public PjNumber getObjNumber() {
035: return _obj;
036: }
037:
038: /**
039: Returns the generation number referenced by this PDF reference.
040: @return the generation number within this PDF reference.
041: */
042: public PjNumber getGenNumber() {
043: return _gen;
044: }
045:
046: /**
047: Writes this PDF reference object to a stream in PDF format.
048: @param os the stream to write to.
049: @return the number of bytes written.
050: @exception IOException if an I/O error occurs.
051: */
052: public long writePdf(OutputStream os) throws IOException {
053: long z = _obj.writePdf(os);
054: z = z + write(os, " ");
055: z = z + _gen.writePdf(os);
056: z = z + write(os, " R");
057: return z;
058: }
059:
060: /**
061: Returns a string representation of this reference in PDF format.
062: @return the string representation.
063: public String toString() {
064: return _obj.toString() + ' ' + _gen.toString() + " R";
065: }
066: */
067:
068: /**
069: Returns a deep copy of this object.
070: @return a deep copy of this object.
071: */
072: public Object clone() {
073: return this ;
074: }
075:
076: /**
077: Compares two PjReference objects for equality.
078: @param obj the reference object to compare to.
079: @return true if this object is the same as obj, false
080: otherwise.
081: */
082: public boolean equals(Object obj) {
083: if (obj == null) {
084: return false;
085: }
086: if (obj instanceof PjReference) {
087: return ((_obj.equals(((PjReference) obj)._obj)) && (_gen
088: .equals(((PjReference) obj)._gen)));
089: } else {
090: return false;
091: }
092: }
093:
094: /**
095: Returns a hash code value for the object.
096: @return a hashcode value for this object.
097: */
098: public int hashCode() {
099: return _obj.hashCode();
100: }
101:
102: private PjNumber _obj;
103: private PjNumber _gen;
104:
105: }
|