Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.common

public abstract Class PDNameTreeNode<T extends COSObjectable>

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.PDDestinationNameTreeNode, org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode, org.apache.pdfbox.pdmodel.PDJavascriptNameTreeNode, org.apache.pdfbox.pdmodel.PDStructureElementNameTreeNode
Type Parameters
<T>
The type of the values in this name tree.
Imports
java.io.IOException, java.util.ArrayList, .Collections, .LinkedHashMap, .List, .Map, .Set, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, .COSString

This class represents a node in a name tree.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
private static final Log
private final COSDictionary
private PDNameTreeNode<T>

Constructor Summary

AccessConstructor and Description
protected
PDNameTreeNode()

Constructor.

protected
PDNameTreeNode(COSDictionary
The dictionary that holds the name information.
dict
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private void
protected abstract T

Returns:

The converted PD Model object.
convertCOSToPD
(COSBase
The COS object to convert.
base
)

Method to convert the COS value in the name tree to the PD Model object.

protected abstract PDNameTreeNode<T>

Returns:

The new child node object.
createChildNode
(COSDictionary
The dictionary for the child node object to refer to.
dic
)

Create a child node object.

public COSDictionary

Returns:

The cos object that matches this Java object.
getCOSObject
()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

public List<PDNameTreeNode<T>>

Returns:

The list of children or null if there are no children.
getKids
()

Return the children of this node.

public String

Returns:

The lowest value for a key in the map.
getLowerLimit
()

Get the lowest value for a key in the name map.

public Map<String, T>

Returns:

ordered map of COS objects or null if the dictionary contains no 'Names' entry on this level.
getNames
()

This will return a map of names on this level.

public PDNameTreeNode<T>

Returns:

parent node
getParent
()

Returns the parent node.

public String

Returns:

The highest value for a key in the map.
getUpperLimit
()

Get the highest value for a key in the name map.

public T

Returns:

The value of the name in the tree.
getValue
(String
The name in the tree.
name
)

The name to retrieve.

public boolean

Returns:

true if this is a root node
isRootNode
()

Determines if this is a root node or not.

public void
setKids(List<? extends PDNameTreeNode<T>>
The children of this named tree. These have to be in sorted order. Because of that, it is usually easier to call setNames(Map) with a map and pass a single element list here.
kids
)

Set the children of this named tree.

private void
setLowerLimit(String
The new lowest value for a key in the map.
lower
)

Set the lowest value for the key in the map.

public void
setNames(Map<String, T>
map of names to objects, or null for nothing.
names
)

Set the names for this node.

public void
setParent(PDNameTreeNode<T>
the node to be set as parent
parentNode
)

Sets the parent to the given node.

private void
setUpperLimit(String
The new highest value for a key in the map.
upper
)

Set the highest value for the key in the map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Log LOG
nodeback to summary
private final COSDictionary node
parentback to summary
private PDNameTreeNode<T> parent

Constructor Detail

PDNameTreeNodeback to summary
protected PDNameTreeNode()

Constructor.

PDNameTreeNodeback to summary
protected PDNameTreeNode(COSDictionary dict)

Constructor.

Parameters
dict:COSDictionary

The dictionary that holds the name information.

Method Detail

calculateLimitsback to summary
private void calculateLimits()
convertCOSToPDback to summary
protected abstract T 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 return the given COSBase object. Subclasses should do something specific.

Parameters
base:COSBase

The COS object to convert.

Returns:T

The converted PD Model object.

Exceptions
IOException:
If there is an error during creation.
createChildNodeback to summary
protected abstract PDNameTreeNode<T> createChildNode(COSDictionary dic)

Create a child node object.

Parameters
dic:COSDictionary

The dictionary for the child node object to refer to.

Returns:PDNameTreeNode<T>

The new child node object.

getCOSObjectback to summary
public COSDictionary getCOSObject()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

Returns:COSDictionary

The cos object that matches this Java object.

Annotations
@Override
getKidsback to summary
public List<PDNameTreeNode<T>> getKids()

Return the children of this node. This list will contain PDNameTreeNode objects.

Returns:List<PDNameTreeNode<T>>

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

getLowerLimitback to summary
public String getLowerLimit()

Get the lowest value for a key in the name map.

Returns:String

The lowest value for a key in the map.

getNamesback to summary
public Map<String, T> getNames() throws IOException

This will return a map of names on this level. The key will be a string, and the value will depend on where this class is being used.

Returns:Map<String, T>

ordered map of COS objects or null if the dictionary contains no 'Names' entry on this level.

Exceptions
IOException:
If there is an error while creating the sub types.
See Also
getKids()
getParentback to summary
public PDNameTreeNode<T> getParent()

Returns the parent node.

Returns:PDNameTreeNode<T>

parent node

getUpperLimitback to summary
public String getUpperLimit()

Get the highest value for a key in the name map.

Returns:String

The highest value for a key in the map.

getValueback to summary
public T getValue(String name) throws IOException

The name to retrieve.

Parameters
name:String

The name in the tree.

Returns:T

The value of the name in the tree.

Exceptions
IOException:
If there is a problem creating the destinations.
isRootNodeback to summary
public boolean isRootNode()

Determines if this is a root node or not.

Returns:boolean

true if this is a root node

setKidsback to summary
public void setKids(List<? extends PDNameTreeNode<T>> kids)

Set the children of this named tree.

Parameters
kids:List<? extends PDNameTreeNode<T>>

The children of this named tree. These have to be in sorted order. Because of that, it is usually easier to call setNames(Map) with a map and pass a single element list here.

setLowerLimitback to summary
private void setLowerLimit(String lower)

Set the lowest value for the key in the map.

Parameters
lower:String

The new lowest value for a key in the map.

setNamesback to summary
public void setNames(Map<String, T> names)

Set the names for this node. This method will set the appropriate upper and lower limits based on the keys in the map and take care of the ordering.

Parameters
names:Map<String, T>

map of names to objects, or null for nothing.

setParentback to summary
public void setParent(PDNameTreeNode<T> parentNode)

Sets the parent to the given node.

Parameters
parentNode:PDNameTreeNode<T>

the node to be set as parent

setUpperLimitback to summary
private void setUpperLimit(String upper)

Set the highest value for the key in the map.

Parameters
upper:String

The new highest value for a key in the map.