Package com.itextpdf.kernel.pdf
Class GenericNameTree
java.lang.Object
com.itextpdf.kernel.pdf.GenericNameTree
- All Implemented Interfaces:
-
IPdfNameTreeAccess
- Direct Known Subclasses:
-
PdfNameTree
,PdfStructIdTree
Abstract representation of a name tree structure, as used in PDF for various purposes such as the Dests tree, the ID tree of structure elements and the embedded file tree.
-
Constructor Summary
ModifierConstructorDescriptionprotected
GenericNameTree
(PdfDocument pdfDoc) Creates a name tree structure in the current document. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an entry to the name tree.protected void
addEntry
(PdfString key, PdfObject value, Consumer<PdfDocument> onErrorAction) Add an entry to the name tree.void
Add an entry to the name tree.Build aPdfDictionary
containing the name tree.Retrieve an entry from the name tree.Retrieve an entry from the name tree.protected final LinkedHashMap<PdfString,
PdfObject> getItems()
getKeys()
Retrieve the set of keys in the name tree.boolean
Check if the tree is modified.protected static LinkedHashMap<PdfString,
PdfObject> readTree
(PdfDictionary dictionary) Read the entries in a name tree structure from a dictionary object into a linked hash map with fixed order.void
removeEntry
(PdfString key) Remove an entry from the name tree.protected final void
setItems
(LinkedHashMap<PdfString, PdfObject> items) void
Sets the modified flag to true.
-
Constructor Details
-
GenericNameTree
Creates a name tree structure in the current document.- Parameters:
-
pdfDoc
- the document in which the name tree lives
-
-
Method Details
-
addEntry
Add an entry to the name tree.- Parameters:
-
key
- key of the entry -
value
- object to add
-
addEntry
Add an entry to the name tree.- Parameters:
-
key
- key of the entry -
value
- object to add
-
removeEntry
Remove an entry from the name tree.- Parameters:
-
key
- key of the entry
-
getEntry
Retrieve an entry from the name tree.- Specified by:
-
getEntry
in interfaceIPdfNameTreeAccess
- Parameters:
-
key
- key of entry to retrieve - Returns:
-
retrieved entry or
null
if absent
-
getEntry
Retrieve an entry from the name tree.- Specified by:
-
getEntry
in interfaceIPdfNameTreeAccess
- Parameters:
-
key
- key of entry to retrieve - Returns:
-
retrieved entry or
null
if absent
-
getKeys
Description copied from interface:IPdfNameTreeAccess
Retrieve the set of keys in the name tree.- Specified by:
-
getKeys
in interfaceIPdfNameTreeAccess
- Returns:
- set of all keys in the name tree
-
isModified
public boolean isModified()Check if the tree is modified.- Returns:
- True if the object has been modified, false otherwise.
-
setModified
public void setModified()Sets the modified flag to true. It means that the object has been modified. -
buildTree
Build aPdfDictionary
containing the name tree.- Returns:
-
PdfDictionary
containing the name tree
-
addEntry
Add an entry to the name tree.- Parameters:
-
key
- key of the entry -
value
- object to add -
onErrorAction
- action to perform if such entry exists
-
setItems
-
getItems
-
readTree
Read the entries in a name tree structure from a dictionary object into a linked hash map with fixed order.- Parameters:
-
dictionary
- a dictionary object - Returns:
- a map containing the entries in the tree
-