Package org.apache.pdfbox.pdmodel.common
Class PDNameTreeNode<T extends COSObjectable>
java.lang.Object
org.apache.pdfbox.pdmodel.common.PDNameTreeNode<T>
- Type Parameters:
T
- The type of the values in this name tree.
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDDestinationNameTreeNode
,PDEmbeddedFilesNameTreeNode
,PDJavascriptNameTreeNode
,PDStructureElementNameTreeNode
public abstract class PDNameTreeNode<T extends COSObjectable>
extends Object
implements COSObjectable
This class represents a node in a name tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Log
private final COSDictionary
private PDNameTreeNode<T>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
PDNameTreeNode
(COSDictionary dict) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
protected abstract T
convertCOSToPD
(COSBase base) Method to convert the COS value in the name tree to the PD Model object.protected abstract PDNameTreeNode<T>
Create a child node object.Convert this standard java object to a COS object.getKids()
Return the children of this node.Get the lowest value for a key in the name map.getNames()
This will return a map of names on this level.Returns the parent node.Get the highest value for a key in the name map.The name to retrieve.boolean
Determines if this is a root node or not.void
setKids
(List<? extends PDNameTreeNode<T>> kids) Set the children of this named tree.private void
setLowerLimit
(String lower) Set the lowest value for the key in the map.void
Set the names for this node.void
setParent
(PDNameTreeNode<T> parentNode) Sets the parent to the given node.private void
setUpperLimit
(String upper) Set the highest value for the key in the map.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
node
-
parent
-
-
Constructor Details
-
PDNameTreeNode
protected PDNameTreeNode()Constructor. -
PDNameTreeNode
Constructor.- Parameters:
dict
- The dictionary that holds the name information.
-
-
Method Details
-
getCOSObject
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getParent
Returns the parent node.- Returns:
- parent node
-
setParent
Sets the parent to the given node.- Parameters:
parentNode
- the node to be set as parent
-
isRootNode
public boolean isRootNode()Determines if this is a root node or not.- Returns:
- true if this is a root node
-
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.
-
setKids
Set the children of this named tree.- Parameters:
kids
- The children of this named tree. These have to be in sorted order. Because of that, it is usually easier to callsetNames(Map)
with a map and pass a single element list here.
-
calculateLimits
private void calculateLimits() -
getValue
The name to retrieve.- Parameters:
name
- The name in the tree.- Returns:
- The value of the name in the tree.
- Throws:
IOException
- If there is a problem creating the destinations.
-
getNames
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:
- ordered map of COS objects or
null
if the dictionary contains no 'Names' entry on this level. - Throws:
IOException
- If there is an error while creating the sub types.- See Also:
-
convertCOSToPD
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
- The COS object to convert.- Returns:
- The converted PD Model object.
- Throws:
IOException
- If there is an error during creation.
-
createChildNode
Create a child node object.- Parameters:
dic
- The dictionary for the child node object to refer to.- Returns:
- The new child node object.
-
setNames
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 of names to objects, ornull
for nothing.
-
getUpperLimit
Get the highest value for a key in the name map.- Returns:
- The highest value for a key in the map.
-
setUpperLimit
Set the highest value for the key in the map.- Parameters:
upper
- The new highest value for a key in the map.
-
getLowerLimit
Get the lowest value for a key in the name map.- Returns:
- The lowest value for a key in the map.
-
setLowerLimit
Set the lowest value for the key in the map.- Parameters:
lower
- The new lowest value for a key in the map.
-