Class COSObjectPool

java.lang.Object
org.apache.pdfbox.pdfwriter.compress.COSObjectPool

public class COSObjectPool extends Object
An instance of this class maps COSBase instances to COSObjectKeys and allows for a bidirectional lookup.
  • Field Details

  • Constructor Details

    • COSObjectPool

      public COSObjectPool(long highestXRefObjectNumber)
      Creates a map of COSBase instances to COSObjectKeys, allowing bidirectional lookups. This constructor can be used for pre - initialized structures to start the assignment of new object numbers starting from the hereby given offset.
      Parameters:
      highestXRefObjectNumber - The highest known object number.
  • Method Details

    • put

      public COSObjectKey put(COSObjectKey key, COSBase object)
      Update the key and object maps.
      Parameters:
      key - The key, that shall be added.
      object - The object, that shall be added.
      Returns:
      The actual key, the object has been added for.
    • getKey

      public COSObjectKey getKey(COSBase object)
      Returns the COSObjectKey for a given registered COSBase. Returns null if such an object is not registered.
      Parameters:
      object - The COSBase a COSObjectKey shall be determined for.
      Returns:
      key The COSObjectKey, that matches the registered COSBase, or null if such an object is not registered.
    • contains

      public boolean contains(COSObjectKey key)
      Returns true, if a COSBase is registered for the given COSObjectKey.
      Parameters:
      key - The COSObjectKey that shall be checked for a registered COSBase.
      Returns:
      True, if a COSBase is registered for the given COSObjectKey.
    • getObject

      public COSBase getObject(COSObjectKey key)
      Returns the COSBase, that is registered for the given COSObjectKey, or null if no object is registered for that key.
      Parameters:
      key - The COSObjectKey a registered COSBase shall be found for.
      Returns:
      The COSBase, that is registered for the given COSObjectKey, or null if no object is registered for that key.
    • contains

      public boolean contains(COSBase object)
      Returns true, if the given COSBase is a registered object of this pool.
      Parameters:
      object - The COSBase that shall be checked.
      Returns:
      True, if such a COSBase is registered in this pool.
    • getHighestXRefObjectNumber

      public long getHighestXRefObjectNumber()
      Returns the highest known object number (see: COSObjectKey for further information), that is currently registered in this pool.
      Returns:
      The highest known object number (see: COSObjectKey for further information), that is currently registered in this pool.