org.pdfbox.pdmodel.common

Class PDNameTreeNode

Implemented Interfaces:
COSObjectable
Known Direct Subclasses:
PDDestinationNameTreeNode, PDEmbeddedFilesNameTreeNode

public class PDNameTreeNode
extends java.lang.Object
implements COSObjectable

This class represends a PDF Name tree. See the PDF Reference 1.5 section 3.8.5 for more details.
Version:
$Revision: 1.4 $
Author:
Ben Litchfield

Constructor Summary

PDNameTreeNode(Class valueClass)
Constructor.
PDNameTreeNode(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 PDNameTreeNode
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.
String
getLowerLimit()
Get the lowest value for a key in the name map.
Map
getNames()
This will return a map of names.
String
getUpperLimit()
Get the highest value for a key in the name map.
Object
getValue(String name)
The name to retrieve.
void
setKids(List kids)
Set the children of this named tree.
void
setNames(Map names)
Set the names of for this node.

Constructor Details

PDNameTreeNode

public PDNameTreeNode(Class valueClass)
Constructor.
Parameters:
valueClass - The PD Model type of object that is the value.

PDNameTreeNode

public PDNameTreeNode(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 Details

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.

createChildNode

protected PDNameTreeNode 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.

getCOSDictionary

public COSDictionary getCOSDictionary()
Convert this standard java object to a COS object.
Returns:
The cos object that matches this Java object.

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.

getKids

public List getKids()
Return the children of this node. This list will contain PDNameTreeNode objects.
Returns:
The list of children or null if there are no children.

getLowerLimit

public String getLowerLimit()
Get the lowest value for a key in the name map.
Returns:
The lowest value for a key in the map.

getNames

public Map getNames()
            throws IOException
This will return a map of names. The key will be a java.lang.String the value will depend on where this class is being used.
Returns:
A map of cos objects.

getUpperLimit

public String getUpperLimit()
Get the highest value for a key in the name map.
Returns:
The highest value for a key in the map.

getValue

public Object getValue(String name)
            throws IOException
The name to retrieve.
Parameters:
name - The name in the tree.
Returns:
The value of the name in the tree.

setKids

public void setKids(List kids)
Set the children of this named tree.
Parameters:
kids - The children of this named tree.

setNames

public void setNames(Map names)
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:
names - The map of names to objects.