com.icesoft.pdf.pobjects
Class Dictionary

java.lang.Object
  extended bycom.icesoft.pdf.pobjects.Dictionary
Direct Known Subclasses:
Action, Annotation, BorderEffect, BorderStyle, Catalog, EncryptionDictionary, FileSpecification, NameTree, OutlineItem, Outlines, Page, PageTree, PTrailer

public class Dictionary
extends 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 com.icesoft.pdf.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  Hashtable entries
          Table of associative pairs of objects.
protected  boolean inited
          Indicates if Dictionary has been initiated.
protected  Library library
          Pointer to the documents Library object which acts a central repository for the access of PDF object in the document.
 
Constructor Summary
Dictionary(Library l, Hashtable h)
          Creates a new instance of a Dictionary.
 
Method Summary
 Hashtable getEntries()
          Gets a copy of the entries that make up the Dictionary.
 float getFloat(String key)
          Gets a float specified by the key in the dictionary entries.
 int getInt(String key)
          Gets an int specified by the key in the dictionary entries.
 Library getLibrary()
          Gets the PDF Documents Library.
protected  Number getNumber(String key)
          Gets a Number specified by the key in the dictionary entries.
 Object getObject(String key)
           
 Reference getPObjectReference()
          Gets the reference used to identify this Dictionary in the PDF document.
 void init()
          Initiate the Dictionary.
 void setPObjectReference(Reference reference)
          Sets the reference used to identify this Dictionary in the PDF document.
 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

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 Hashtable entries
Table of associative pairs of objects.


inited

protected boolean inited
Indicates if Dictionary has been initiated.

Constructor Detail

Dictionary

public Dictionary(Library l,
                  Hashtable h)
Creates a new instance of a Dictionary.

Parameters:
l - document library.
h - 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(com.icesoft.pdf.pobjects.Reference)

init

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


getEntries

public Hashtable getEntries()
Gets a copy of the entries that make up the Dictionary.

Returns:
a copy of the Dictionary's entries.

getObject

public Object getObject(String key)

getNumber

protected Number getNumber(String 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 Hashtable.
Returns:
Number that the key refers to

getInt

public int getInt(String 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 Hashtable.
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(String 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 Hashtable.
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.

toString

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

Returns:
dictionary values.