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

java.lang.Object
  extended by edu.harvard.hul.ois.jhove.module.pdf.PageLabelNode

public class PageLabelNode
extends java.lang.Object

Class for nodes of a PDF number tree.


Field Summary
protected  PdfDictionary _dict
          The dictionary which defines this node.
protected  PdfModule _module
          The PdfModule this node is associated with.
protected  PageLabelNode _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
PageLabelNode(PdfModule module, PageLabelNode parent, PdfDictionary dict)
          Superclass constructor.
 
Method Summary
 PdfObject _getCurrentValue()
          Returns value associated with current key
 void buildSubtree()
          Build the subtree of descendants of this node, using the Kids entry in the dictionary.
 boolean findNextKeyValue()
          Obtain the next key-value pair from the tree.
 int getCurrentKey()
          Returns key at current position in traversing tree
 int getPrevKey()
          Returns key previously obtained in traversing tree
 PdfObject getPrevValue()
          Returns value associated with key previously obtained in traversing tree
static java.lang.String intToBase26(int n, boolean upperCase)
          A convenience method to turn integers into "letter" page numbers as defined for PDF.
static java.lang.String intToRoman(int n, boolean upperCase)
          A convenience method to turn integers into Roman numerals, for the generation of page labels.
 PageLabelNode nextLeafObject()
          Get the next leaf object which is under this node.
 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 PageLabelNode _parent
The parent node of this node.


_dict

protected PdfDictionary _dict
The dictionary which defines this node.


_walkFinished

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

Constructor Detail

PageLabelNode

public PageLabelNode(PdfModule module,
                     PageLabelNode 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

buildSubtree

public void buildSubtree()
                  throws PdfException
Build the subtree of descendants of this node, using the Kids entry in the dictionary. Leaf nodes are recognized by not having a Kids entry.

Throws:
PdfException

startWalk

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


nextLeafObject

public PageLabelNode nextLeafObject()
Get the next leaf object which is under this node. This function is designed such that calling startWalk() and then repeatedly calling nextLeafObject() will return all the leaf objects in the tree under this node, and finally will return null when there are no more. A leaf object is one which has no Kids; it is required to have a Nums entry.


findNextKeyValue

public boolean findNextKeyValue()
                         throws PdfException
Obtain the next key-value pair from the tree. This returns true if a pair is available, false if not. After this is called, getCurrentKey and getCurrentValue may be called to retrieve the key and value thus found. Each time this is called, currentKey and currentValue get copied into prevKey and prevValue.

Throws:
PdfException

getCurrentKey

public int getCurrentKey()
Returns key at current position in traversing tree


_getCurrentValue

public PdfObject _getCurrentValue()
Returns value associated with current key


getPrevKey

public int getPrevKey()
Returns key previously obtained in traversing tree


getPrevValue

public PdfObject getPrevValue()
Returns value associated with key previously obtained in traversing tree


intToRoman

public static java.lang.String intToRoman(int n,
                                          boolean upperCase)
A convenience method to turn integers into Roman numerals, for the generation of page labels.


intToBase26

public static java.lang.String intToBase26(int n,
                                           boolean upperCase)
A convenience method to turn integers into "letter" page numbers as defined for PDF. The first 26 pages are A-Z, the next 26 AA-ZZ, etc.