Class Dictionary


  • public class Dictionary
    extends java.lang.Object
    A dictionary is a map and supports writing the bytes for the dictionary in the PDF syntax. The dictionary has an optional type entry which is treated as a special case (to ensure it comes first in the output if it is specified).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.Object> map
      Data storage.
      private java.lang.String type
      The type entry.
    • Constructor Summary

      Constructors 
      Constructor Description
      Dictionary()
      Creates a new instance with no type.
      Dictionary​(java.lang.String type)
      Creates a new dictionary with the specified type (which can be null).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getType()
      Returns the dictionary type.
      boolean isEmpty()
      Returns true if the dictionary has no entries, and false otherwise.
      void put​(java.lang.String key, java.lang.Object value)
      Puts an entry in the dictionary.
      java.lang.Object remove​(java.lang.String key)
      Removes an entry from the dictionary, returning the value that was stored previously.
      void setType​(java.lang.String type)
      Sets the type (for example, "/Catalog").
      int size()
      Returns the number of items in the dictionary.
      byte[] toPDFBytes()
      Returns a byte array containing the ASCII encoding of the dictionary.
      java.lang.String toPDFString()
      Returns a string containing the PDF text describing the dictionary.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • type

        private java.lang.String type
        The type entry. We treat this as a special case, because when a type is defined, we want it to appear first in the PDF output. Note that it can be set to null for some dictionaries.
      • map

        private java.util.Map<java.lang.String,​java.lang.Object> map
        Data storage.
    • Constructor Detail

      • Dictionary

        public Dictionary()
        Creates a new instance with no type.
      • Dictionary

        public Dictionary​(java.lang.String type)
        Creates a new dictionary with the specified type (which can be null).
        Parameters:
        type - the type value (for example, "/Catalog").
    • Method Detail

      • getType

        public java.lang.String getType()
        Returns the dictionary type.
        Returns:
        The dictionary type (possibly (null).
      • setType

        public void setType​(java.lang.String type)
        Sets the type (for example, "/Catalog").
        Parameters:
        type - the type (null permitted).
      • isEmpty

        public boolean isEmpty()
        Returns true if the dictionary has no entries, and false otherwise.
        Returns:
        A boolean.
        See Also:
        size()
      • size

        public int size()
        Returns the number of items in the dictionary.
        Returns:
        The number of items in the dictionary.
      • put

        public void put​(java.lang.String key,
                        java.lang.Object value)
        Puts an entry in the dictionary.
        Parameters:
        key - the key.
        value - the value.
      • remove

        public java.lang.Object remove​(java.lang.String key)
        Removes an entry from the dictionary, returning the value that was stored previously.
        Parameters:
        key - the key.
        Returns:
        The value that was associated with the key.
      • toPDFBytes

        public byte[] toPDFBytes()
        Returns a byte array containing the ASCII encoding of the dictionary.
        Returns:
        A byte array.
      • toPDFString

        public java.lang.String toPDFString()
        Returns a string containing the PDF text describing the dictionary. Note that this is a Java string, conversion to byte format happens elsewhere.
        Returns:
        A string.