Class GenericNameTree

  • All Implemented Interfaces:
    IPdfNameTreeAccess
    Direct Known Subclasses:
    PdfNameTree, PdfStructIdTree

    public class GenericNameTree
    extends java.lang.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.
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • modified

        private boolean modified
    • Constructor Detail

      • 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 Detail

      • 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​(java.lang.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​(java.lang.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
      • 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.
      • addEntry

        protected void addEntry​(PdfString key,
                                PdfObject value,
                                java.util.function.Consumer<PdfDocument> onErrorAction)
        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

        protected final void setItems​(java.util.LinkedHashMap<PdfString,​PdfObject> items)
      • readTree

        protected static java.util.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
      • formatNodeWithLimits

        private PdfDictionary formatNodeWithLimits​(PdfString[] names,
                                                   int lower,
                                                   int upper)