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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LinkedHashMap
<PdfString, PdfObject> private static final org.slf4j.Logger
private boolean
private static final int
private final PdfDocument
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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.private PdfDictionary[]
constructLeafArr
(PdfString[] names) private PdfDictionary
formatNodeWithLimits
(PdfString[] names, int lower, int upper) 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.private static PdfString
iterateItems
(PdfDictionary dictionary, Map<PdfString, PdfObject> items, PdfString leftOver) private static PdfString
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.private PdfDictionary
reduceTree
(PdfString[] names, PdfDictionary[] topLayer, int topLayerLen, int curNodeSpan) 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.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
NODE_SIZE
private static final int NODE_SIZE- See Also:
-
items
-
pdfDoc
-
modified
private boolean modified
-
-
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 entryvalue
- object to add
-
addEntry
Add an entry to the name tree.- Parameters:
key
- key of the entryvalue
- 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 entryvalue
- object to addonErrorAction
- 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
-
formatNodeWithLimits
-
reduceTree
private PdfDictionary reduceTree(PdfString[] names, PdfDictionary[] topLayer, int topLayerLen, int curNodeSpan) -
constructLeafArr
-
iterateItems
-
iterateLeafNode
-