Package com.orsonpdf
Class Dictionary
java.lang.Object
com.orsonpdf.Dictionary
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 -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with no type.Dictionary
(String type) Creates a new dictionary with the specified type (which can benull
). -
Method Summary
Modifier and TypeMethodDescriptiongetType()
Returns the dictionary type.boolean
isEmpty()
Returnstrue
if the dictionary has no entries, andfalse
otherwise.void
Puts an entry in the dictionary.Removes an entry from the dictionary, returning the value that was stored previously.void
Sets the type (for example, "/Catalog").int
size()
Returns the number of items in the dictionary.byte[]
Returns a byte array containing the ASCII encoding of the dictionary.Returns a string containing the PDF text describing the dictionary.
-
Field Details
-
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
Data storage.
-
-
Constructor Details
-
Dictionary
public Dictionary()Creates a new instance with no type. -
Dictionary
Creates a new dictionary with the specified type (which can benull
).- Parameters:
type
- the type value (for example, "/Catalog").
-
-
Method Details
-
getType
Returns the dictionary type.- Returns:
- The dictionary type (possibly (
null
).
-
setType
Sets the type (for example, "/Catalog").- Parameters:
type
- the type (null
permitted).
-
isEmpty
public boolean isEmpty()Returnstrue
if the dictionary has no entries, andfalse
otherwise.- Returns:
- A boolean.
- See Also:
-
size
public int size()Returns the number of items in the dictionary.- Returns:
- The number of items in the dictionary.
-
put
Puts an entry in the dictionary.- Parameters:
key
- the key.value
- the value.
-
remove
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
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.
-