Class GenericNameTree

java.lang.Object
com.itextpdf.kernel.pdf.GenericNameTree
All Implemented Interfaces:
IPdfNameTreeAccess
Direct Known Subclasses:
PdfNameTree, PdfStructIdTree

public class GenericNameTree extends Object implements IPdfNameTreeAccess
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 Details

    • GenericNameTree

      protected GenericNameTree (PdfDocument pdfDoc)
      Creates a name tree structure in the current document.
      Parameters:
      pdfDoc - the document in which the name tree lives
  • Method Details

    • addEntry

      public void addEntry (PdfString key, PdfObject value)
      Add an entry to the name tree.
      Parameters:
      key - key of the entry
      value - object to add
    • addEntry

      public void addEntry (String key, PdfObject value)
      Add an entry to the name tree.
      Parameters:
      key - key of the entry
      value - object to add
    • removeEntry

      public void removeEntry (PdfString key)
      Remove an entry from the name tree.
      Parameters:
      key - key of the entry
    • getEntry

      public PdfObject getEntry (PdfString key)
      Retrieve an entry from the name tree.
      Specified by:
      getEntry in interface IPdfNameTreeAccess
      Parameters:
      key - key of entry to retrieve
      Returns:
      retrieved entry or null if absent
    • getEntry

      public PdfObject getEntry (String key)
      Retrieve an entry from the name tree.
      Specified by:
      getEntry in interface IPdfNameTreeAccess
      Parameters:
      key - key of entry to retrieve
      Returns:
      retrieved entry or null if absent
    • getKeys

      public Set<PdfString> getKeys()
      Description copied from interface: IPdfNameTreeAccess
      Retrieve the set of keys in the name tree.
      Specified by:
      getKeys in interface IPdfNameTreeAccess
      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

      public PdfDictionary buildTree()
      Build a PdfDictionary containing the name tree.
      Returns:
      PdfDictionary containing the name tree
    • setItems

      protected final void setItems (LinkedHashMap<PdfString,PdfObject> items)
    • getItems

      protected final LinkedHashMap<PdfString,PdfObject> getItems()
    • readTree

      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.
      Parameters:
      dictionary - a dictionary object
      Returns:
      a map containing the entries in the tree