public class PdfDictionary extends PdfObject
PdfDictionary
is the Pdf dictionary object.
A dictionary is an associative table containing pairs of objects. The first element of each pair is called the key and the second element is called the value. Unlike dictionaries in the PostScript language, a key must be a PdfName
. A value can be any kind of PdfObject
, including a dictionary. A dictionary is generally used to collect and tie together the attributes of a complex object, with each key-value pair specifying the name and value of an attribute.
A dictionary is represented by two left angle brackets (<<), followed by a sequence of key-value pairs, followed by two right angle brackets (>>).
This object is described in the 'Portable Document Format Reference Manual version 1.7' section 3.2.6 (page 59-60).
PdfObject
, PdfName
, BadPdfFormatException
, Serialized Form
Modifier and Type | Field and Description |
---|---|
static PdfName |
CATALOG
This is a possible type of dictionary
|
static PdfName |
FONT
This is a possible type of dictionary
|
protected LinkedHashMap<PdfName,PdfObject> |
hashMap
This is the hashmap that contains all the values and keys of the dictionary
|
static PdfName |
OUTLINES
This is a possible type of dictionary
|
static PdfName |
PAGE
This is a possible type of dictionary
|
static PdfName |
PAGES
This is a possible type of dictionary
|
Constructor and Description |
---|
PdfDictionary()
Constructs an empty PdfDictionary -object.
|
PdfDictionary(int capacity) |
PdfDictionary(PdfName type)
Constructs a PdfDictionary -object of a certain type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkType(PdfName type)
Checks the type of the dictionary.
|
void |
clear()
Removes all the PdfObject s and its keys from the PdfDictionary .
|
boolean |
contains(PdfName key)
Returns true if this PdfDictionary contains a mapping for the specified key.
|
PdfObject |
get(PdfName key)
Returns the PdfObject associated to the specified key.
|
PdfArray |
getAsArray(PdfName key)
Returns a PdfObject as a PdfArray , resolving indirect references.
|
PdfBoolean |
getAsBoolean(PdfName key)
Returns a PdfObject as a PdfBoolean , resolving indirect references.
|
PdfDictionary |
getAsDict(PdfName key)
Returns a PdfObject as a PdfDictionary , resolving indirect references.
|
PdfIndirectReference |
getAsIndirectObject(PdfName key)
Returns a PdfObject as a PdfIndirectReference .
|
PdfName |
getAsName(PdfName key)
Returns a PdfObject as a PdfName , resolving indirect references.
|
PdfNumber |
getAsNumber(PdfName key)
Returns a PdfObject as a PdfNumber , resolving indirect references.
|
PdfStream |
getAsStream(PdfName key)
Returns a PdfObject as a PdfStream , resolving indirect references.
|
PdfString |
getAsString(PdfName key)
Returns a PdfObject as a PdfString , resolving indirect references.
|
PdfObject |
getDirectObject(PdfName key)
Returns the PdfObject associated to the specified key, resolving a possible indirect reference to a direct object.
|
Set<PdfName> |
getKeys()
Get all keys that are set.
|
boolean |
isCatalog()
Checks if a Dictionary is of the type CATALOG.
|
boolean |
isFont()
Checks if a Dictionary is of the type FONT.
|
boolean |
isOutlineTree()
Checks if a Dictionary is of the type OUTLINES.
|
boolean |
isPage()
Checks if a Dictionary is of the type PAGE.
|
boolean |
isPages()
Checks if a Dictionary is of the type PAGES.
|
void |
merge(PdfDictionary other) |
void |
mergeDifferent(PdfDictionary other) |
void |
put(PdfName key, PdfObject object)
Associates the specified PdfObject as value with the specified PdfName as key in this map.
|
void |
putAll(PdfDictionary dic)
Copies all of the mappings from the specified PdfDictionary to this PdfDictionary .
|
void |
putEx(PdfName key, PdfObject value)
Associates the specified PdfObject as value to the specified PdfName as key in this map.
|
void |
remove(PdfName key)
Removes a PdfObject and its key from the PdfDictionary .
|
int |
size()
Returns the number of key-value mappings in this PdfDictionary .
|
void |
toPdf(PdfWriter writer, OutputStream os)
Writes the PDF representation of this PdfDictionary as an array of byte to the given OutputStream .
|
String |
toString()
Returns a string representation of this PdfDictionary .
|
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
public static final PdfName FONT
public static final PdfName OUTLINES
public static final PdfName PAGE
public static final PdfName PAGES
public static final PdfName CATALOG
protected LinkedHashMap<PdfName,PdfObject> hashMap
public PdfDictionary()
PdfDictionary
-object.
public PdfDictionary(int capacity)
public PdfDictionary(PdfName type)
PdfDictionary
-object of a certain type.
type
- a PdfName
public void toPdf(PdfWriter writer, OutputStream os) throws IOException
PdfDictionary
as an array of byte
to the given OutputStream
.
toPdf
in class PdfObject
writer
- for backwards compatibility
os
- the OutputStream
to write the bytes to.
IOException
public String toString()
PdfDictionary
. The string doesn't contain any of the content of this dictionary. Rather the string "dictionary" is returned, possibly followed by the type of this PdfDictionary
, if set.
toString
in class PdfObject
PdfDictionary
PdfObject.toString()
public void put(PdfName key, PdfObject object)
PdfObject
as value with the specified PdfName
as key in this map. If the map previously contained a mapping for this key, the old value is replaced. If the value is null
or PdfNull
the key is deleted.
key
- a PdfName
object
- the PdfObject
to be associated with the key
public void putEx(PdfName key, PdfObject value)
PdfObject
as value to the specified PdfName
as key in this map. If the value is a PdfNull
, it is treated just as any other PdfObject
. If the value is null
however nothing is done.
key
- a PdfName
value
- the PdfObject
to be associated to the key
public void putAll(PdfDictionary dic)
PdfDictionary
to this PdfDictionary
. These mappings will replace any mappings previously contained in this PdfDictionary
.
dic
- The PdfDictionary
with the mappings to be copied over
public void remove(PdfName key)
PdfObject
and its key from the PdfDictionary
.
key
- a PdfName
public void clear()
PdfObject
s and its keys from the PdfDictionary
.
public PdfObject get(PdfName key)
PdfObject
associated to the specified key.
key
- a PdfName
public PdfObject getDirectObject(PdfName key)
PdfObject
associated to the specified key, resolving a possible indirect reference to a direct object. This method will never return a PdfIndirectReference
object.
key
- A key for the PdfObject
to be returned
PdfObject
or null
public Set<PdfName> getKeys()
true
if it is, otherwise false
.
public int size()
PdfDictionary
.
PdfDictionary
.
public boolean contains(PdfName key)
true
if this PdfDictionary
contains a mapping for the specified key.
true
if the key is set, otherwise false
.
public boolean isFont()
Dictionary
is of the type FONT.
true
if it is, otherwise false
.
public boolean isPage()
Dictionary
is of the type PAGE.
true
if it is, otherwise false
.
public boolean isPages()
Dictionary
is of the type PAGES.
true
if it is, otherwise false
.
public boolean isCatalog()
Dictionary
is of the type CATALOG.
true
if it is, otherwise false
.
public boolean isOutlineTree()
Dictionary
is of the type OUTLINES.
true
if it is, otherwise false
.
public boolean checkType(PdfName type)
type
- the type you're looking for
public void merge(PdfDictionary other)
public void mergeDifferent(PdfDictionary other)
public PdfDictionary getAsDict(PdfName key)
PdfObject
as a PdfDictionary
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfDictionary
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfDictionary
object, or null
public PdfArray getAsArray(PdfName key)
PdfObject
as a PdfArray
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfArray
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfArray
object, or null
public PdfStream getAsStream(PdfName key)
PdfObject
as a PdfStream
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfStream
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfStream
object, or null
public PdfString getAsString(PdfName key)
PdfObject
as a PdfString
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfString
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfString
object, or null
public PdfNumber getAsNumber(PdfName key)
PdfObject
as a PdfNumber
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfNumber
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfNumber
object, or null
public PdfName getAsName(PdfName key)
PdfObject
as a PdfName
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfName
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfName
object, or null
public PdfBoolean getAsBoolean(PdfName key)
PdfObject
as a PdfBoolean
, resolving indirect references. The object associated with the PdfName
given is retrieved and resolved to a direct object. If it is a PdfBoolean
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfBoolean
object, or null
public PdfIndirectReference getAsIndirectObject(PdfName key)
PdfObject
as a PdfIndirectReference
. The object associated with the PdfName
given is retrieved If it is a PdfIndirectReference
, it is cast down and returned as such. Otherwise null
is returned.
key
- A PdfName
PdfIndirectReference
object, or null
Copyright © 1998–2017. All rights reserved.