org.apache.pdfbox.pdfwriter.compress

## 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 `COSObjectKey`s and allows for a bidirectional lookup.

Author:
  Christian Appl

### Constructor Summary

Constructors
Constructor and Description
`COSObjectPool(long highestXRefObjectNumber)` Creates a map of `COSBase` instances to `COSObjectKey`s, allowing bidirectional lookups.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `contains(COSBase object)` Returns true, if the given `COSBase` is a registered object of this pool.
`boolean` `contains(COSObjectKey key)` Returns true, if a `COSBase` is registered for the given `COSObjectKey`.
`long` `getHighestXRefObjectNumber()` Returns the highest known object number (see: `COSObjectKey` for further information), that is currently registered in this pool.
`COSObjectKey` `getKey(COSBase object)` Returns the `COSObjectKey` for a given registered `COSBase`.
`COSBase` `getObject(COSObjectKey key)` Returns the `COSBase`, that is registered for the given `COSObjectKey`, or null if no object is registered for that key.
`COSObjectKey` `put(COSObjectKey key, COSBase object)` Update the key and object maps.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### COSObjectPool

    public COSObjectPool(long highestXRefObjectNumber)

Creates a map of `COSBase` instances to `COSObjectKey`s, 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 Detail

#### 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.