edu.harvard.hul.ois.jhove.module.pdf
Class DocNode

java.lang.Object
  extended by edu.harvard.hul.ois.jhove.module.pdf.DocNode
Direct Known Subclasses:
PageObject, PageTreeNode

public abstract class DocNode
extends java.lang.Object

Abstract class for nodes of a PDF document tree.


Field Summary
protected  PdfDictionary _dict
          The dictionary which defines this node.
protected  PdfModule _module
          The PdfModule this node is associated with.
protected  boolean _pageObjectFlag
          True if this node is a PageObject.
protected  PageTreeNode _parent
          The parent node of this node.
protected  boolean _walkFinished
          Set to true when all subnodes of this node have been iterated through following a StartWalk.
 
Constructor Summary
DocNode(PdfModule module, PageTreeNode parent, PdfDictionary dict)
          Superclass constructor.
 
Method Summary
 PdfObject get(java.lang.String key, boolean inheritable)
          Get an named property.
 PdfDictionary getDict()
          Returns the page object or page tree node dictionary from which this object was constructed.
 PdfDictionary getFontResources()
          Returns the dictionary of fonts within the node's Resources dictionary, if both exist.
 PdfArray getMediaBox()
          Get the MediaBox of this node.
 DocNode getParent()
          Returns the parent of this node.
 PdfDictionary getResources()
          Get the Resources dictionary.
 boolean isPageObject()
          Returns true if this node is a PageObject.
abstract  DocNode nextDocNode()
          Get the next DocNode which is under this node.
abstract  PageObject nextPageObject()
          Get the next PageObject which is under this node.
abstract  void startWalk()
          Initialize an iterator through the descendants of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_module

protected PdfModule _module
The PdfModule this node is associated with.


_parent

protected PageTreeNode _parent
The parent node of this node.


_dict

protected PdfDictionary _dict
The dictionary which defines this node.


_pageObjectFlag

protected boolean _pageObjectFlag
True if this node is a PageObject.


_walkFinished

protected boolean _walkFinished
Set to true when all subnodes of this node have been iterated through following a StartWalk.

Constructor Detail

DocNode

public DocNode(PdfModule module,
               PageTreeNode parent,
               PdfDictionary dict)
Superclass constructor.

Parameters:
module - The PdfModule under which we're operating
parent - The parent node in the document tree; may be null only for the root node
dict - The dictionary object on which this node is based
Method Detail

isPageObject

public boolean isPageObject()
Returns true if this node is a PageObject.


startWalk

public abstract void startWalk()
Initialize an iterator through the descendants of this node.


nextPageObject

public abstract PageObject nextPageObject()
                                   throws PdfMalformedException
Get the next PageObject which is under this node.

Throws:
PdfMalformedException

nextDocNode

public abstract DocNode nextDocNode()
                             throws PdfMalformedException
Get the next DocNode which is under this node. All PageTreeNodes and PageObjects are eventually returned by walking through a structure with nextNode.

Throws:
PdfMalformedException

getParent

public DocNode getParent()
Returns the parent of this node.


getDict

public PdfDictionary getDict()
Returns the page object or page tree node dictionary from which this object was constructed.


getResources

public PdfDictionary getResources()
                           throws PdfException
Get the Resources dictionary. Either a PageTreeNode or a PageObject can have a Resources dictionary. Returns null if there is no Resources dictionary. The object may be referenced indirectly.

Throws:
PdfException

getFontResources

public PdfDictionary getFontResources()
                               throws PdfException
Returns the dictionary of fonts within the node's Resources dictionary, if both exist. Otherwise returns null. The dictionary will most often have indirect object references as values. What is returned is not a Font dictionary, but rather a dictionary of Font dictionaries.

Throws:
PdfException

getMediaBox

public PdfArray getMediaBox()
                     throws PdfInvalidException
Get the MediaBox of this node. MediaBox is an inheritable property, so it walks up the chain of ancestors if it doesn't contain one. Returns null if none. Throws a PdfInvalidException if an invalid MediaBox is found.

Throws:
PdfInvalidException

get

public PdfObject get(java.lang.String key,
                     boolean inheritable)
Get an named property. If this object doesn't have the specified property and inheritable is true, walks up the chain of ancestors to try to find one. If no ancestor has the property or inheritable is false, returns null.