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.Loggerprivate booleanprivate static final intprivate final PdfDocument -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGenericNameTree(PdfDocument pdfDoc) Creates a name tree structure in the current document. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an entry to the name tree.protected voidaddEntry(PdfString key, PdfObject value, Consumer<PdfDocument> onErrorAction) Add an entry to the name tree.voidAdd an entry to the name tree.Build aPdfDictionarycontaining the name tree.private PdfDictionary[]constructLeafArr(PdfString[] names) private PdfDictionaryformatNodeWithLimits(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.booleanCheck if the tree is modified.private static PdfStringiterateItems(PdfDictionary dictionary, Map<PdfString, PdfObject> items, PdfString leftOver) private static PdfStringprotected 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 PdfDictionaryreduceTree(PdfString[] names, PdfDictionary[] topLayer, int topLayerLen, int curNodeSpan) voidremoveEntry(PdfString key) Remove an entry from the name tree.protected final voidsetItems(LinkedHashMap<PdfString, PdfObject> items) voidSets 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
-
addEntry
-
removeEntry
Remove an entry from the name tree.- Parameters:
key- key of the entry
-
getEntry
Retrieve an entry from the name tree.- Specified by:
getEntryin interfaceIPdfNameTreeAccess- Parameters:
key- key of entry to retrieve- Returns:
- retrieved entry or
nullif absent
-
getEntry
Retrieve an entry from the name tree.- Specified by:
getEntryin interfaceIPdfNameTreeAccess- Parameters:
key- key of entry to retrieve- Returns:
- retrieved entry or
nullif absent
-
getKeys
Description copied from interface:IPdfNameTreeAccessRetrieve the set of keys in the name tree.- Specified by:
getKeysin 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 aPdfDictionarycontaining the name tree.- Returns:
PdfDictionarycontaining 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
-