Class PDFXref

java.lang.Object
org.openpdf.renderer.PDFXref

public class PDFXref extends Object
a cross reference representing a line in the PDF cross referencing table.

There are two forms of the PDFXref, destinguished by absolutely nothing. The first type of PDFXref is used as indirect references in a PDFObject. In this type, the id is an index number into the object cross reference table. The id will range from 0 to the size of the cross reference table.

The second form is used in the Java representation of the cross reference table. In this form, the id is the file position of the start of the object in the PDF file. See the use of both of these in the PDFFile.dereference() method, which takes a PDFXref of the first form, and uses (internally) a PDFXref of the second form.

This is an unhappy state of affairs, and should be fixed. Fortunatly, the two uses have already been factored out as two different methods.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
     
    private int
     
    private int
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PDFXref(byte[] line)
    create a new PDFXref, given a sequence of bytes representing the fixed-width cross reference table line
    PDFXref(int id, int gen)
    create a new PDFXref, given a parsed id and generation.
    PDFXref(int id, int gen, boolean compressed)
    create a new PDFXref, given a parsed id, compressedObjId and index
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
    get compressed flag of this object
    int
    get the character index into the file of the start of this object
    int
    get the generation of this object
    int
    get the object number of this object
    int
    get the generation of this object
    Get the object this reference refers to, or null if it hasn't been set.
    int
     
    void
    Set the object this reference refers to.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      private int id
    • generation

      private int generation
    • compressed

      private final boolean compressed
    • reference

      private SoftReference<PDFObject> reference
  • Constructor Details

    • PDFXref

      public PDFXref(int id, int gen)
      create a new PDFXref, given a parsed id and generation.
    • PDFXref

      public PDFXref(int id, int gen, boolean compressed)
      create a new PDFXref, given a parsed id, compressedObjId and index
    • PDFXref

      public PDFXref(byte[] line)
      create a new PDFXref, given a sequence of bytes representing the fixed-width cross reference table line
  • Method Details

    • getFilePos

      public int getFilePos()
      get the character index into the file of the start of this object
    • getGeneration

      public int getGeneration()
      get the generation of this object
    • getIndex

      public int getIndex()
      get the generation of this object
    • getID

      public int getID()
      get the object number of this object
    • getCompressed

      public boolean getCompressed()
      get compressed flag of this object
    • getObject

      public PDFObject getObject()
      Get the object this reference refers to, or null if it hasn't been set.
      Returns:
      the object if it exists, or null if not
    • setObject

      public void setObject(PDFObject obj)
      Set the object this reference refers to.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object