org.apache.pdfbox.pdmodel.common
Class PDNumberTreeNode

java.lang.Object
  extended by org.apache.pdfbox.pdmodel.common.PDNumberTreeNode
All Implemented Interfaces:
COSObjectable

public class PDNumberTreeNode
extends Object
implements COSObjectable

This class represents a PDF Number tree. See the PDF Reference 1.7 section 7.9.7 for more details.

Version:
$Revision: 1.4 $
Author:
Ben Litchfield, Igor Podolskiy

Constructor Summary
PDNumberTreeNode(Class<?> valueClass)
          Constructor.
PDNumberTreeNode(COSDictionary dict, Class<?> valueClass)
          Constructor.
 
Method Summary
protected  Object convertCOSToPD(COSBase base)
          Method to convert the COS value in the name tree to the PD Model object.
protected  PDNumberTreeNode createChildNode(COSDictionary dic)
          Create a child node object.
 COSDictionary getCOSDictionary()
          Convert this standard java object to a COS object.
 COSBase getCOSObject()
          Convert this standard java object to a COS object.
 List getKids()
          Return the children of this node.
 Integer getLowerLimit()
          Get the lowest value for a key in the name map.
 Map getNumbers()
          This will return a map of numbers.
 Integer getUpperLimit()
          Get the highest value for a key in the name map.
 Object getValue(Integer index)
          Returns the value corresponding to an index in the number tree.
 void setKids(List kids)
          Set the children of this number tree.
 void setNumbers(Map<Integer,Object> numbers)
          Set the names of for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDNumberTreeNode

public PDNumberTreeNode(Class<?> valueClass)
Constructor.

Parameters:
valueClass - The PD Model type of object that is the value.

PDNumberTreeNode

public PDNumberTreeNode(COSDictionary dict,
                        Class<?> valueClass)
Constructor.

Parameters:
dict - The dictionary that holds the name information.
valueClass - The PD Model type of object that is the value.
Method Detail

getCOSObject

public COSBase getCOSObject()
Convert this standard java object to a COS object.

Specified by:
getCOSObject in interface COSObjectable
Returns:
The cos object that matches this Java object.

getCOSDictionary

public COSDictionary getCOSDictionary()
Convert this standard java object to a COS object.

Returns:
The cos object that matches this Java object.

getKids

public List getKids()
Return the children of this node. This list will contain PDNumberTreeNode objects.

Returns:
The list of children or null if there are no children.

setKids

public void setKids(List kids)
Set the children of this number tree.

Parameters:
kids - The children of this number tree.

getValue

public Object getValue(Integer index)
                throws IOException
Returns the value corresponding to an index in the number tree.

Parameters:
index - The index in the number tree.
Returns:
The value corresponding to the index.
Throws:
IOException - If there is a problem creating the values.

getNumbers

public Map getNumbers()
               throws IOException
This will return a map of numbers. The key will be a java.lang.Integer, the value will depend on where this class is being used.

Returns:
A map of COS objects.
Throws:
IOException - If there is a problem creating the values.

convertCOSToPD

protected Object convertCOSToPD(COSBase base)
                         throws IOException
Method to convert the COS value in the name tree to the PD Model object. The default implementation will simply use reflection to create the correct object type. Subclasses can do whatever they want.

Parameters:
base - The COS object to convert.
Returns:
The converted PD Model object.
Throws:
IOException - If there is an error during creation.

createChildNode

protected PDNumberTreeNode createChildNode(COSDictionary dic)
Create a child node object.

Parameters:
dic - The dictionary for the child node object to refer to.
Returns:
The new child node object.

setNumbers

public void setNumbers(Map<Integer,Object> numbers)
Set the names of for this node. The keys should be java.lang.String and the values must be a COSObjectable. This method will set the appropriate upper and lower limits based on the keys in the map.

Parameters:
numbers - The map of names to objects.

getUpperLimit

public Integer getUpperLimit()
Get the highest value for a key in the name map.

Returns:
The highest value for a key in the map.

getLowerLimit

public Integer getLowerLimit()
Get the lowest value for a key in the name map.

Returns:
The lowest value for a key in the map.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.