Class 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 owning COSDocument to look up (and, for on-disk documents, parse on first touch) the object with this key.

    Every navigation helper in COSDictionary, COSArray and the com.pd4ml.pdf.cos.path package calls resolve() automatically, so most application code never needs to touch this class directly.

    • Constructor Detail

      • 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

      • getObject

        public COSBase getObject()
        Resolves and returns the referenced object, never null (an unresolvable reference yields COSNull.NULL, matching the PDF spec's treatment of dangling references).
      • resolve

        public COSBase resolve()
        Description copied from class: COSBase
        Resolves through a COSObject indirection; every other COS type is already "resolved" and simply returns itself. Parsers and the COSPathEvaluator call this after every navigation step so callers never have to special-case indirect references.
        Overrides:
        resolve in class COSBase
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object