org.icepdf.core.pobjects
Class Dictionary

java.lang.Object
  extended by org.icepdf.core.pobjects.Dictionary
Direct Known Subclasses:
Action, Annotation, BorderEffect, BorderStyle, Catalog, CryptFilter, CryptFilterEntry, EncryptionDictionary, ExtGState, FieldDictionary, FileSpecification, Font, FontDescriptor, NameNode, NameTree, OptionalContent, OptionalContentGroup, OptionalContentMembership, OutlineItem, Outlines, Page, PageTree, PColorSpace, PInfo, PTrailer, Resources, ShadingPattern, SoftMask, Stream, Thumbnail, ViewerPreferences

public class Dictionary
extends java.lang.Object

This class represents a PDF document's Dictionary object. A Dictionary object is an associative table containing pairs of objects, known as the dictionary's entries. The first element of each entry is the key and the second element is the value. Dictionary objects are the main building blocks of a PDF document. They are commonly used to collect and tie together the attributes of complex objects such as fonts or pages within a document.

Most of the Objects found in the package org.icepdf.core.pobject.* extend this class. Dictionary objects by convention have a "Type" entry which identifies the type of object the dictionary describes. Classes that extend Dictionary add functionality based on the specified Dictionary type.

Since:
1.0

Field Summary
protected  java.util.HashMap entries
          Table of associative pairs of objects.
static Name FORM_TYPE_KEY
           
protected  boolean inited
          Indicates if Dictionary has been initiated.
protected  boolean isDeleted
          Flag to indicate this object has been flaged for deletion.
protected  boolean isNew
          Flags the object as new and not previously saved in the file
static Name LENGTH_KEY
           
protected  Library library
          Pointer to the documents Library object which acts a central repository for the access of PDF object in the document.
static Name SUBTYPE_KEY
           
static Name TYPE_KEY
           
 
Constructor Summary
Dictionary(Library library, java.util.HashMap entries)
          Creates a new instance of a Dictionary.
 
Method Summary
 java.util.HashMap getEntries()
          Gets a copy of the entries that make up the Dictionary.
 float getFloat(Name key)
          Gets a float specified by the key in the dictionary entries.
 int getInt(Name key)
          Gets an int specified by the key in the dictionary entries.
 Library getLibrary()
          Gets the PDF Documents Library.
protected  java.lang.Number getNumber(Name key)
          Gets a Number specified by the key in the dictionary entries.
 java.lang.Object getObject(Name key)
           
 Reference getPObjectReference()
          Gets the reference used to identify this Dictionary in the PDF document.
 void init()
          Initiate the Dictionary.
 boolean isDeleted()
           
 boolean isNew()
           
 void setDeleted(boolean deleted)
           
 void setNew(boolean aNew)
           
 void setPObjectReference(Reference reference)
          Sets the reference used to identify this Dictionary in the PDF document.
 java.lang.String toString()
          Returns a summary of the dictionary entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_KEY

public static final Name TYPE_KEY

SUBTYPE_KEY

public static final Name SUBTYPE_KEY

LENGTH_KEY

public static final Name LENGTH_KEY

FORM_TYPE_KEY

public static final Name FORM_TYPE_KEY

library

protected Library library
Pointer to the documents Library object which acts a central repository for the access of PDF object in the document.


entries

protected java.util.HashMap entries
Table of associative pairs of objects.


inited

protected boolean inited
Indicates if Dictionary has been initiated.


isDeleted

protected boolean isDeleted
Flag to indicate this object has been flaged for deletion.


isNew

protected boolean isNew
Flags the object as new and not previously saved in the file

Constructor Detail

Dictionary

public Dictionary(Library library,
                  java.util.HashMap entries)
Creates a new instance of a Dictionary.

Parameters:
library - document library.
entries - dictionary entries.
Method Detail

setPObjectReference

public void setPObjectReference(Reference reference)

Sets the reference used to identify this Dictionary in the PDF document. The reference number and generation number of this reference is needed by the encryption algorithm to correctly decrypt this object.

This method should only be used by the PDF Parser. Use of this method outside the context of the PDF Parser may result in unpredictable behavior.

Parameters:
reference - Reference used to identify this Dictionary in the PDF document.
See Also:
getPObjectReference()

getPObjectReference

public Reference getPObjectReference()

Gets the reference used to identify this Dictionary in the PDF document. The reference number and generation number of this reference is needed by the encryption algorithm to correctly decrypt this object.

Returns:
Reference used to identify this Dictionary in a PDF document.
See Also:
setPObjectReference(org.icepdf.core.pobjects.Reference)

init

public void init()
Initiate the Dictionary. Retrieve any needed attributes.


getEntries

public java.util.HashMap getEntries()
Gets a copy of the entries that make up the Dictionary.

Returns:
a copy of the Dictionary's entries.

getObject

public java.lang.Object getObject(Name key)

getNumber

protected java.lang.Number getNumber(Name key)
Gets a Number specified by the key in the dictionary entries. If the value is a reference, the Number object that the reference points to is returned. If the key cannot be found, or the resulting object is not a Number, then null is returned.

Parameters:
key - key to find in entries HashMap.
Returns:
Number that the key refers to

getInt

public int getInt(Name key)
Gets an int specified by the key in the dictionary entries. If the value is a reference, the int value that the reference points to is returned.

Parameters:
key - key to find in entries HashMap.
Returns:
int value if a valid key, else zero if the key does not point to an int or is invalid.

getFloat

public float getFloat(Name key)
Gets a float specified by the key in the dictionary entries. If the value is a reference, the float value that the reference points to is returned.

Parameters:
key - key to find in entries HashMap.
Returns:
float value if a valid key, else zero if the key does not point to a float or is invalid.

getLibrary

public Library getLibrary()
Gets the PDF Documents Library. A Library object is the central repository of all objects that make up the PDF document hierarchy.

Returns:
documents library.

isDeleted

public boolean isDeleted()

setDeleted

public void setDeleted(boolean deleted)

isNew

public boolean isNew()

setNew

public void setNew(boolean aNew)

toString

public java.lang.String toString()
Returns a summary of the dictionary entries.

Overrides:
toString in class java.lang.Object
Returns:
dictionary values.