com.lowagie.text.pdf

Class PdfDictionary

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

See Also: PdfObject PdfName BadPdfFormatException

Field Summary
static PdfNameCATALOG
This is a possible type of dictionary
PdfNamedictionaryType
This is the type of this dictionary
static PdfNameFONT
This is a possible type of dictionary
protected HashMaphashMap
This is the hashmap that contains all the values and keys of the dictionary
static PdfNameOUTLINES
This is a possible type of dictionary
static PdfNamePAGE
This is a possible type of dictionary
static PdfNamePAGES
This is a possible type of dictionary
Constructor Summary
PdfDictionary()
Constructs an empty PdfDictionary-object.
PdfDictionary(PdfName type)
Constructs a PdfDictionary-object of a certain type.
Method Summary
booleancontains(PdfName key)
PdfObjectget(PdfName key)
Gets a PdfObject with a certain key from the PdfDictionary.
PdfArraygetAsArray(PdfName key)
PdfBooleangetAsBoolean(PdfName key)
PdfDictionarygetAsDict(PdfName key)
All the getAs functions will return either null, or the specified object type This function will automatically look up indirect references.
PdfIndirectReferencegetAsIndirectObject(PdfName key)
PdfNamegetAsName(PdfName key)
PdfNumbergetAsNumber(PdfName key)
PdfStreamgetAsStream(PdfName key)
PdfStringgetAsString(PdfName key)
PdfObjectgetDirectObject(PdfName key)
This function behaves the same as 'get', but will never return an indirect reference, it will always look such references up and return the actual object.
SetgetKeys()
booleanisCatalog()
Checks if a Dictionary is of the type CATALOG.
booleanisDictionaryType(PdfName type)
Checks if a PdfDictionary is of a certain type.
booleanisFont()
Checks if a Dictionary is of the type FONT.
booleanisOutlineTree()
Checks if a Dictionary is of the type OUTLINES.
booleanisPage()
Checks if a Dictionary is of the type PAGE.
booleanisPages()
Checks if a Dictionary is of the type PAGES.
voidmerge(PdfDictionary other)
voidmergeDifferent(PdfDictionary other)
voidput(PdfName key, PdfObject value)
Adds a PdfObject and its key to the PdfDictionary.
voidputAll(PdfDictionary dic)
voidputEx(PdfName key, PdfObject value)
Adds a PdfObject and its key to the PdfDictionary.
voidremove(PdfName key)
Removes a PdfObject and its key from the PdfDictionary.
intsize()
voidtoPdf(PdfWriter writer, OutputStream os)
Returns the PDF representation of this PdfDictionary.
StringtoString()

Field Detail

CATALOG

public static final PdfName CATALOG
This is a possible type of dictionary

dictionaryType

private PdfName dictionaryType
This is the type of this dictionary

FONT

public static final PdfName FONT
This is a possible type of dictionary

hashMap

protected HashMap hashMap
This is the hashmap that contains all the values and keys of the dictionary

OUTLINES

public static final PdfName OUTLINES
This is a possible type of dictionary

PAGE

public static final PdfName PAGE
This is a possible type of dictionary

PAGES

public static final PdfName PAGES
This is a possible type of dictionary

Constructor Detail

PdfDictionary

public PdfDictionary()
Constructs an empty PdfDictionary-object.

PdfDictionary

public PdfDictionary(PdfName type)
Constructs a PdfDictionary-object of a certain type.

Parameters: type a PdfName

Method Detail

contains

public boolean contains(PdfName key)

get

public PdfObject get(PdfName key)
Gets a PdfObject with a certain key from the PdfDictionary.

Parameters: key key of the entry (a PdfName)

Returns: the previous PdfObject corresponding with the key

getAsArray

public PdfArray getAsArray(PdfName key)

getAsBoolean

public PdfBoolean getAsBoolean(PdfName key)

getAsDict

public PdfDictionary getAsDict(PdfName key)
All the getAs functions will return either null, or the specified object type This function will automatically look up indirect references. There's one obvious exception, the one that will only return an indirect reference. All direct objects come back as a null. Mark A Storer (2/17/06)

Parameters: key

Returns: the appropriate object in its final type, or null

getAsIndirectObject

public PdfIndirectReference getAsIndirectObject(PdfName key)

getAsName

public PdfName getAsName(PdfName key)

getAsNumber

public PdfNumber getAsNumber(PdfName key)

getAsStream

public PdfStream getAsStream(PdfName key)

getAsString

public PdfString getAsString(PdfName key)

getDirectObject

public PdfObject getDirectObject(PdfName key)
This function behaves the same as 'get', but will never return an indirect reference, it will always look such references up and return the actual object.

Parameters: key

Returns: null, or a non-indirect object

getKeys

public Set getKeys()

isCatalog

public boolean isCatalog()
Checks if a Dictionary is of the type CATALOG.

Returns: true if it is, false if it isn't.

isDictionaryType

public boolean isDictionaryType(PdfName type)

Deprecated:

Checks if a PdfDictionary is of a certain type.

Parameters: type a type of dictionary

Returns: true of false

isFont

public boolean isFont()
Checks if a Dictionary is of the type FONT.

Returns: true if it is, false if it isn't.

isOutlineTree

public boolean isOutlineTree()
Checks if a Dictionary is of the type OUTLINES.

Returns: true if it is, false if it isn't.

isPage

public boolean isPage()
Checks if a Dictionary is of the type PAGE.

Returns: true if it is, false if it isn't.

isPages

public boolean isPages()
Checks if a Dictionary is of the type PAGES.

Returns: true if it is, false if it isn't.

merge

public void merge(PdfDictionary other)

mergeDifferent

public void mergeDifferent(PdfDictionary other)

put

public void put(PdfName key, PdfObject value)
Adds a PdfObject and its key to the PdfDictionary. If the value is null or PdfNull the key is deleted.

Parameters: key key of the entry (a PdfName) value value of the entry (a PdfObject)

putAll

public void putAll(PdfDictionary dic)

putEx

public void putEx(PdfName key, PdfObject value)
Adds a PdfObject and its key to the PdfDictionary. If the value is null it does nothing.

Parameters: key key of the entry (a PdfName) value value of the entry (a PdfObject)

remove

public void remove(PdfName key)
Removes a PdfObject and its key from the PdfDictionary.

Parameters: key key of the entry (a PdfName)

size

public int size()

toPdf

public void toPdf(PdfWriter writer, OutputStream os)
Returns the PDF representation of this PdfDictionary.

toString

public String toString()