Top Description Fields Constructors Methods
org.apache.pdfbox.cos

public Class COSDictionary

extends COSBase
implements COSUpdateInfo
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.cos.COSUpdateInfo, org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.cos.COSStream, org.apache.pdfbox.cos.UnmodifiableCOSDictionary
Imports
java.io.IOException, .InputStream, java.util.ArrayList, .Arrays, .Calendar, .Collection, .LinkedHashMap, .List, .Map, .Map.Entry, .Set, java.util.function.BiConsumer, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.io.IOUtils, org.apache.pdfbox.pdmodel.common.COSObjectable, org.apache.pdfbox.util.DateConverter

This class represents a dictionary where name/value pairs reside.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
protected Map<COSName, COSBase>
items

The name-value pairs of this dictionary.

private static final Log
LOG

Log instance.

private static final String
private final COSUpdateState

Constructor Summary

AccessConstructor and Description
public
COSDictionary()

Constructor.

public
COSDictionary(COSDictionary
The dictionary to copy.
dict
)

Copy Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ICOSVisitor
The object to notify when visiting this object.
visitor
)

Implements abstract org.apache.pdfbox.cos.COSBase.accept.

visitor pattern double dispatch method.

public void
addAll(COSDictionary
The dictionaries to get the key/value pairs from.
dict
)

This will add all of the dictionaries keys/values to this dictionary.

public COSDictionary

Returns:

an unmodifiable view of this dictionary
asUnmodifiableDictionary
()

Returns an unmodifiable view of this dictionary.

public void
clear()

This will clear all items in the map.

public boolean

Returns:

true if the map contains this key.
containsKey
(COSName
The key to find in the map.
name
)

public boolean

Returns:

true if the map contains this key.
containsKey
(String
The key to find in the map.
name
)

public boolean

Returns:

true if the map contains this value.
containsValue
(Object
The value to find in the map.
value
)

public Set<Map.Entry<COSName, COSBase>>

Returns:

name-value entries in this dictionary
entrySet
()

Returns the name-value entries in this dictionary.

public void
forEach(BiConsumer<? super COSName, ? super COSBase>
The action to be performed for each entry
action
)

Convenience method that calls Map.forEach(BiConsumer).

public boolean

Returns:

The value converted to a boolean.
getBoolean
(String
The key to the item in the dictionary.
key
,
boolean
The value returned if the entry is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a cos boolean and convert it to a primitive boolean.

public boolean

Returns:

The entry converted to a boolean.
getBoolean
(COSName
The key to the item in the dictionary.
key
,
boolean
The value returned if the entry is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a COSBoolean and convert it to a primitive boolean.

public boolean

Returns:

The entry converted to a boolean.
getBoolean
(COSName
The first key to the item in the dictionary.
firstKey
,
COSName
The second key to the item in the dictionary.
secondKey
,
boolean
The value returned if the entry is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a COSBoolean and convert it to a primitive boolean.

public COSArray

Returns:

The COSArray.
getCOSArray
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a COSArray.

public COSDictionary

Returns:

The COSDictionary.
getCOSDictionary
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a COSDictionary.

public COSDictionary

Returns:

The COSDictionary.
getCOSDictionary
(COSName
The first key to the item in the dictionary.
firstKey
,
COSName
The second key to the item in the dictionary.
secondKey
)

This is a convenience method that will get the dictionary object that is expected to be a COSDictionary.

public COSName

Returns:

The COS name.
getCOSName
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name.

public COSName

Returns:

The COS name.
getCOSName
(COSName
The key to the item in the dictionary.
key
,
COSName
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a name.

public COSObject

Returns:

The COSObject.
getCOSObject
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a COSObject.

public COSStream

Returns:

The COSStream.
getCOSStream
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a COSStream.

public Calendar

Returns:

The name converted to a date.
getDate
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public Calendar

Returns:

The name converted to a date.
getDate
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public Calendar

Returns:

The name converted to a date.
getDate
(String
The key to the item in the dictionary.
key
,
Calendar
The default value to return if the entry does not exist in the dictionary or if the date was invalid.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a date.

public Calendar

Returns:

The name converted to a date.
getDate
(COSName
The key to the item in the dictionary.
key
,
Calendar
The default value to return if the entry does not exist in the dictionary or if the date was invalid.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a date.

public COSBase

Returns:

The object that matches the key.
getDictionaryObject
(String
The key to the object that we are getting.
key
)

This will get an object from this dictionary.

public COSBase

Returns:

The object that matches the key.
getDictionaryObject
(COSName
The first key to try.
firstKey
,
COSName
The second key to try.
secondKey
)

This is a special case of getDictionaryObject that takes multiple keys, it will handle the situation where multiple keys could get the same value, ie if either CS or ColorSpace is used to get the colorspace.

public COSBase

Returns:

The object that matches the key.
getDictionaryObject
(COSName
The key to the object that we are getting.
key
)

This will get an object from this dictionary.

private static String
public Calendar

Returns:

The name converted to a string.
getEmbeddedDate
(COSName
The embedded dictionary to get.
embedded
,
COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public Calendar

Returns:

The name converted to a string.
getEmbeddedDate
(COSName
The embedded dictionary to get.
embedded
,
COSName
The key to the item in the dictionary.
key
,
Calendar
The default value to return if the entry does not exist in the dictionary or if the date was invalid.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a date.

public int

Returns:

The value of the embedded integer.
getEmbeddedInt
(COSName
The name of the embedded dictionary.
embeddedDictionary
,
COSName
The key in the embedded dictionary.
key
)

Get an integer from an embedded dictionary.

public int

Returns:

The value of the embedded integer.
getEmbeddedInt
(COSName
The name of the embedded dictionary.
embeddedDictionary
,
COSName
The key in the embedded dictionary.
key
,
int
The value if there is no embedded dictionary or it does not contain the key.
defaultValue
)

Get an integer from an embedded dictionary.

public String

Returns:

The name converted to a string.
getEmbeddedString
(COSName
The embedded dictionary.
embedded
,
COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public String

Returns:

The name converted to a string.
getEmbeddedString
(COSName
The embedded dictionary.
embedded
,
COSName
The key to the item in the dictionary.
key
,
String
The default value to return.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public boolean

Returns:

true if the number at bitPos is '1'
getFlag
(COSName
The COSName of the field to get the flag from.
field
,
int
the bitPosition to get the value from.
bitFlag
)

Gets the boolean value from the flags at the given bit position.

public float

Returns:

The float value.
getFloat
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an float.

public float

Returns:

The float value.
getFloat
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an float.

public float

Returns:

The float value.
getFloat
(String
The key to the item in the dictionary.
key
,
float
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a float.

public float

Returns:

The float value.
getFloat
(COSName
The key to the item in the dictionary.
key
,
float
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an float.

public void
getIndirectObjectKeys(List<COSObjectKey>
a list of already found indirect objects.
indirectObjects
)
Deprecated use getIndirectObjectKeys(Collection) instead

Collects all indirect objects numbers within this dictionary and all included dictionaries.

public void
getIndirectObjectKeys(Collection<COSObjectKey>
a collection of already found indirect objects.
indirectObjects
)

Collects all indirect objects numbers within this dictionary and all included dictionaries.

public int

Returns:

The integer value.
getInt
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an int.

public int

Returns:

The integer value..
getInt
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an int.

public int

Returns:

The integer value.
getInt
(String
The key to the item in the dictionary.
key
,
int
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public int

Returns:

The integer value.
getInt
(COSName
The key to the item in the dictionary.
key
,
int
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public int

Returns:

The integer value.
getInt
(COSName
The first key to the item in the dictionary.
firstKey
,
COSName
The second key to the item in the dictionary.
secondKey
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public int

Returns:

The integer value.
getInt
(COSName
The first key to the item in the dictionary.
firstKey
,
COSName
The second key to the item in the dictionary.
secondKey
,
int
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public COSBase

Returns:

The item that matches the key.
getItem
(COSName
The key to the object.
key
)

This will do a lookup into the dictionary.

public COSBase

Returns:

The item that matches the key.
getItem
(String
The key to the object.
key
)

This will do a lookup into the dictionary.

public COSBase

Returns:

The object that matches the key.
getItem
(COSName
The first key to try.
firstKey
,
COSName
The second key to try.
secondKey
)

This is a special case of getItem that takes multiple keys, it will handle the situation where multiple keys could get the same value, ie if either CS or ColorSpace is used to get the colorspace.

public COSName

Returns:

The key for the value in the map or null if it does not exist.
getKeyForValue
(Object
The value to search for in the map.
value
)

Search in the map for the value that matches the parameter and return the first key that maps to that value.

public long

Returns:

The long value.
getLong
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an long.

public long

Returns:

The long value.
getLong
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be an long.

public long

Returns:

The integer value.
getLong
(String
The key to the item in the dictionary.
key
,
long
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public long

Returns:

The integer value.
getLong
(COSName
The key to the item in the dictionary.
key
,
long
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be an integer.

public String

Returns:

The name converted to a string.
getNameAsString
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public String

Returns:

The name converted to a string.
getNameAsString
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public String

Returns:

The name converted to a string.
getNameAsString
(String
The key to the item in the dictionary.
key
,
String
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public String

Returns:

The name converted to a string.
getNameAsString
(COSName
The key to the item in the dictionary.
key
,
String
The value to return if the dictionary item is null.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.

public COSBase

Returns:

the object
getObjectFromPath
(String
the relative path to the object.
objPath
)

Nice method, gives you every object you want Arrays works properly too.

public String

Returns:

The name converted to a string.
getString
(String
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a string.

public String

Returns:

The name converted to a string.
getString
(COSName
The key to the item in the dictionary.
key
)

This is a convenience method that will get the dictionary object that is expected to be a string.

public String

Returns:

The name converted to a string.
getString
(String
The key to the item in the dictionary.
key
,
String
The default value to return.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a string.

public String

Returns:

The name converted to a string.
getString
(COSName
The key to the item in the dictionary.
key
,
String
The default value to return.
defaultValue
)

This is a convenience method that will get the dictionary object that is expected to be a string.

public COSUpdateState
public Collection<COSBase>

Returns:

All the values for the dictionary.
getValues
()

This will get all of the values for the dictionary.

public Set<COSName>

Returns:

names of the entries in this dictionary
keySet
()

Returns the names of the entries in this dictionary.

public void
removeItem(COSName
The key to the item to remove from the dictionary.
key
)

This will remove an item for the dictionary.

public void
setBoolean(String
The key to the dictionary object.
key
,
boolean
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setBoolean(COSName
The key to the dictionary object.
key
,
boolean
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setDate(String
The key to the date value.
key
,
Calendar
The date value.
date
)

Set the value of a date entry in the dictionary.

public void
setDate(COSName
The key to the date.
key
,
Calendar
The date to set.
date
)

Set the date object.

public void
setEmbeddedDate(COSName
The embedded dictionary.
embedded
,
COSName
The key to the date.
key
,
Calendar
The date to set.
date
)

Set the date object.

public void
setEmbeddedInt(COSName
The embedded dictionary.
embeddedDictionary
,
COSName
The key to the object,
key
,
int
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSInteger object.

public void
setEmbeddedString(COSName
The embedded dictionary to set the item in.
embedded
,
COSName
The key to the object,
key
,
String
The string value for the name.
value
)

This is a convenience method that will convert the value to a COSString object.

public void
setFlag(COSName
The COSName of the field to set the value into.
field
,
int
the bit position to set the value in.
bitFlag
,
boolean
the value the bit position should have.
value
)

Sets the given boolean value at bitPos in the flags.

public void
setFloat(String
The key to the object,
key
,
float
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSFloat object.

public void
setFloat(COSName
The key to the object,
key
,
float
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSFloat object.

public void
setInt(String
The key to the object,
key
,
int
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSInteger object.

public void
setInt(COSName
The key to the object,
key
,
int
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSInteger object.

public void
setItem(COSName
The key to the dictionary object.
key
,
COSBase
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setItem(COSName
The key to the dictionary object.
key
,
COSObjectable
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setItem(String
The key to the dictionary object.
key
,
COSObjectable
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setItem(String
The key to the dictionary object.
key
,
COSBase
The value to the dictionary object.
value
)

This will set an item in the dictionary.

public void
setLong(String
The key to the object,
key
,
long
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSInteger object.

public void
setLong(COSName
The key to the object,
key
,
long
The int value for the name.
value
)

This is a convenience method that will convert the value to a COSInteger object.

public void
setName(String
The key to the object,
key
,
String
The string value for the name.
value
)

This is a convenience method that will convert the value to a COSName object.

public void
setName(COSName
The key to the object,
key
,
String
The string value for the name.
value
)

This is a convenience method that will convert the value to a COSName object.

public void
setString(String
The key to the object,
key
,
String
The string value for the name.
value
)

This is a convenience method that will convert the value to a COSString object.

public void
setString(COSName
The key to the object,
key
,
String
The string value for the name.
value
)

This is a convenience method that will convert the value to a COSString object.

public int

Returns:

The number of elements in the dictionary.
size
()

This will return the number of elements in this dictionary.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.apache.pdfbox.cos.COSBase:
getCOSObjectgetKeyisDirectsetDirectsetKey