Class COSObjectPool
- java.lang.Object
-
- org.apache.pdfbox.pdfwriter.compress.COSObjectPool
-
public class COSObjectPool extends java.lang.ObjectAn instance of this class mapsCOSBaseinstances toCOSObjectKeys and allows for a bidirectional lookup.
-
-
Field Summary
Fields Modifier and Type Field Description private longhighestXRefObjectNumberprivate java.util.Map<COSObjectKey,COSBase>keyPoolprivate java.util.Map<COSBase,COSObjectKey>objectPool
-
Constructor Summary
Constructors Constructor Description COSObjectPool(long highestXRefObjectNumber)Creates a map ofCOSBaseinstances toCOSObjectKeys, allowing bidirectional lookups.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(COSBase object)Returns true, if the givenCOSBaseis a registered object of this pool.booleancontains(COSObjectKey key)Returns true, if aCOSBaseis registered for the givenCOSObjectKey.longgetHighestXRefObjectNumber()Returns the highest known object number (see:COSObjectKeyfor further information), that is currently registered in this pool.COSObjectKeygetKey(COSBase object)Returns theCOSObjectKeyfor a given registeredCOSBase.COSBasegetObject(COSObjectKey key)Returns theCOSBase, that is registered for the givenCOSObjectKey, or null if no object is registered for that key.COSObjectKeyput(COSObjectKey key, COSBase object)Update the key and object maps.
-
-
-
Field Detail
-
keyPool
private final java.util.Map<COSObjectKey,COSBase> keyPool
-
objectPool
private final java.util.Map<COSBase,COSObjectKey> objectPool
-
highestXRefObjectNumber
private long highestXRefObjectNumber
-
-
Constructor Detail
-
COSObjectPool
public COSObjectPool(long highestXRefObjectNumber)
Creates a map ofCOSBaseinstances toCOSObjectKeys, 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 theCOSObjectKeyfor a given registeredCOSBase. Returns null if such an object is not registered.- Parameters:
object- TheCOSBaseaCOSObjectKeyshall be determined for.- Returns:
- key The
COSObjectKey, that matches the registeredCOSBase, or null if such an object is not registered.
-
contains
public boolean contains(COSObjectKey key)
Returns true, if aCOSBaseis registered for the givenCOSObjectKey.- Parameters:
key- TheCOSObjectKeythat shall be checked for a registeredCOSBase.- Returns:
- True, if a
COSBaseis registered for the givenCOSObjectKey.
-
getObject
public COSBase getObject(COSObjectKey key)
Returns theCOSBase, that is registered for the givenCOSObjectKey, or null if no object is registered for that key.- Parameters:
key- TheCOSObjectKeya registeredCOSBaseshall be found for.- Returns:
- The
COSBase, that is registered for the givenCOSObjectKey, or null if no object is registered for that key.
-
contains
public boolean contains(COSBase object)
Returns true, if the givenCOSBaseis a registered object of this pool.
-
getHighestXRefObjectNumber
public long getHighestXRefObjectNumber()
Returns the highest known object number (see:COSObjectKeyfor further information), that is currently registered in this pool.- Returns:
- The highest known object number (see:
COSObjectKeyfor further information), that is currently registered in this pool.
-
-