Class PDNameTreeNode<T extends COSObjectable>
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.common.PDNameTreeNode<T>
-
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDDestinationNameTreeNode,PDEmbeddedFilesNameTreeNode,PDIntegerNameTreeNode,PDJavascriptNameTreeNode,PDStructureElementNameTreeNode
public abstract class PDNameTreeNode<T extends COSObjectable> extends Object implements COSObjectable
This class represents a node in a name tree.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPDNameTreeNode()Constructor.protectedPDNameTreeNode(COSDictionary dict)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TconvertCOSToPD(COSBase base)Method to convert the COS value in the name tree to the PD Model object.protected abstract PDNameTreeNode<T>createChildNode(COSDictionary dic)Create a child node object.COSDictionarygetCOSObject()Convert this standard java object to a COS object.List<PDNameTreeNode<T>>getKids()Return the children of this node.StringgetLowerLimit()Get the lowest value for a key in the name map.Map<String,T>getNames()This will return a map of names.PDNameTreeNodegetParent()Returns the parent node.StringgetUpperLimit()Get the highest value for a key in the name map.TgetValue(String name)The name to retrieve.booleanisRootNode()Determines if this is a root node or not.voidsetKids(List<? extends PDNameTreeNode<T>> kids)Set the children of this named tree.voidsetNames(Map<String,T> names)Set the names of for this node.voidsetParent(PDNameTreeNode parentNode)Sets the parent to the given node.
-
-
-
Constructor Detail
-
PDNameTreeNode
protected PDNameTreeNode()
Constructor.
-
PDNameTreeNode
protected PDNameTreeNode(COSDictionary dict)
Constructor.- Parameters:
dict- The dictionary that holds the name information.
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
Convert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The cos object that matches this Java object.
-
getParent
public PDNameTreeNode getParent()
Returns the parent node.- Returns:
- parent node
-
setParent
public void setParent(PDNameTreeNode parentNode)
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
public List<PDNameTreeNode<T>> 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
public void setKids(List<? extends PDNameTreeNode<T>> kids)
Set the children of this named tree.- Parameters:
kids- The children of this named tree.
-
getValue
public T 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.
- Throws:
IOException- If an there is a problem creating the destinations.
-
getNames
public Map<String,T> getNames() throws IOException
This will return a map of names. 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
nullif dictionary contains no 'Names' entry - Throws:
IOException- If there is an error while creating the sub types.
-
convertCOSToPD
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- The COS object to convert.- Returns:
- The converted PD Model object.
- Throws:
IOException- If there is an error during creation.
-
createChildNode
protected abstract PDNameTreeNode<T> 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.
-
setNames
public void setNames(Map<String,T> 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- map of names to objects, ornull
-
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.
-
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.
-
-