Package com.pd4ml.pdf.cos
Class COSObject
- java.lang.Object
-
- com.pd4ml.pdf.cos.COSBase
-
- com.pd4ml.pdf.cos.COSObject
-
- All Implemented Interfaces:
COSObjectable
public final class COSObject extends COSBase
An indirect reference, i.e. the"12 0 R"that appears inside another object's value. This is a lazy proxy: dereferencing (getObject()/resolve()) asks the owningCOSDocumentto look up (and, for on-disk documents, parse on first touch) the object with this key.Every navigation helper in
COSDictionary,COSArrayand thecom.pd4ml.pdf.cos.pathpackage callsresolve()automatically, so most application code never needs to touch this class directly.
-
-
Constructor Summary
Constructors Constructor Description COSObject(COSDocument document, COSObjectKey key)COSObject(COSDocument document, COSObjectKey key, COSBase value)Direct constructor for an already-known target, useful when building a document in memory rather than parsing one from disk.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(ICOSVisitor<T> visitor)booleanequals(java.lang.Object other)COSBasegetCOSObject()COSObjectable identity: a raw COS node is its own COS representation.COSDocumentgetDocument()COSObjectKeygetIndirectKey()COSBasegetObject()Resolves and returns the referenced object, nevernull(an unresolvable reference yieldsCOSNull.NULL, matching the PDF spec's treatment of dangling references).inthashCode()COSBaseresolve()Resolves through aCOSObjectindirection; every other COS type is already "resolved" and simply returns itself.java.lang.StringtoString()-
Methods inherited from class com.pd4ml.pdf.cos.COSBase
getGenerationNumber, getKey, getObjectNumber, isDirect, setKey
-
-
-
-
Constructor Detail
-
COSObject
public COSObject(COSDocument document, COSObjectKey key)
-
COSObject
public COSObject(COSDocument document, COSObjectKey key, COSBase value)
Direct constructor for an already-known target, useful when building a document in memory rather than parsing one from disk.
-
-
Method Detail
-
getIndirectKey
public COSObjectKey getIndirectKey()
-
getDocument
public COSDocument getDocument()
-
getObject
public COSBase getObject()
Resolves and returns the referenced object, nevernull(an unresolvable reference yieldsCOSNull.NULL, matching the PDF spec's treatment of dangling references).
-
resolve
public COSBase resolve()
Description copied from class:COSBaseResolves through aCOSObjectindirection; every other COS type is already "resolved" and simply returns itself. Parsers and theCOSPathEvaluatorcall this after every navigation step so callers never have to special-case indirect references.
-
getCOSObject
public COSBase getCOSObject()
Description copied from class:COSBaseCOSObjectable identity: a raw COS node is its own COS representation.- Specified by:
getCOSObjectin interfaceCOSObjectable- Overrides:
getCOSObjectin classCOSBase
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
accept
public <T> T accept(ICOSVisitor<T> visitor) throws COSException
- Specified by:
acceptin classCOSBase- Throws:
COSException
-
-