Package org.apache.pdfbox.pdmodel.common
Class PDNumberTreeNode
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.common.PDNumberTreeNode
-
- All Implemented Interfaces:
COSObjectable
public class PDNumberTreeNode extends java.lang.Object implements COSObjectable
This class represents a PDF Number tree. See the PDF Reference 1.7 section 7.9.7 for more details.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.Log
LOG
private COSDictionary
node
private java.lang.Class<? extends COSObjectable>
valueType
-
Constructor Summary
Constructors Constructor Description PDNumberTreeNode(java.lang.Class<? extends COSObjectable> valueClass)
Constructor.PDNumberTreeNode(COSDictionary dict, java.lang.Class<? extends COSObjectable> valueClass)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected COSObjectable
convertCOSToPD(COSBase base)
Method to convert the COS value in the number tree to the PD Model object.protected PDNumberTreeNode
createChildNode(COSDictionary dic)
Create a child node object.COSDictionary
getCOSObject()
Convert this standard java object to a COS object.java.util.List<PDNumberTreeNode>
getKids()
Return the children of this node.java.lang.Integer
getLowerLimit()
Get the lowest value for a key in the number map.java.util.Map<java.lang.Integer,COSObjectable>
getNumbers()
This will return a map of numbers.java.lang.Integer
getUpperLimit()
Get the highest value for a key in the number map.java.lang.Object
getValue(java.lang.Integer index)
Returns the value corresponding to an index in the number tree.void
setKids(java.util.List<? extends PDNumberTreeNode> kids)
Set the children of this number tree.private void
setLowerLimit(java.lang.Integer lower)
Set the lowest value for the key in the map.void
setNumbers(java.util.Map<java.lang.Integer,? extends COSObjectable> numbers)
Set the numbers for this node.private void
setUpperLimit(java.lang.Integer upper)
Set the highest value for the key in the map.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
node
private final COSDictionary node
-
valueType
private java.lang.Class<? extends COSObjectable> valueType
-
-
Constructor Detail
-
PDNumberTreeNode
public PDNumberTreeNode(java.lang.Class<? extends COSObjectable> valueClass)
Constructor.- Parameters:
valueClass
- The PD Model type of object that is the value.
-
PDNumberTreeNode
public PDNumberTreeNode(COSDictionary dict, java.lang.Class<? extends COSObjectable> valueClass)
Constructor.- Parameters:
dict
- The dictionary that holds the number information.valueClass
- The PD Model type of object that is the value.
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getKids
public java.util.List<PDNumberTreeNode> 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(java.util.List<? extends PDNumberTreeNode> kids)
Set the children of this number tree.- Parameters:
kids
- The children of this number tree.
-
getValue
public java.lang.Object getValue(java.lang.Integer index) throws java.io.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:
java.io.IOException
- If there is a problem creating the values.
-
getNumbers
public java.util.Map<java.lang.Integer,COSObjectable> getNumbers() throws java.io.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:
java.io.IOException
- If there is a problem creating the values.
-
convertCOSToPD
protected COSObjectable convertCOSToPD(COSBase base) throws java.io.IOException
Method to convert the COS value in the number 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:
java.io.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(java.util.Map<java.lang.Integer,? extends COSObjectable> numbers)
Set the numbers for this node. This method will set the appropriate upper and lower limits based on the keys in the map.- Parameters:
numbers
- The map of numbers to objects, ornull
for nothing.
-
getUpperLimit
public java.lang.Integer getUpperLimit()
Get the highest value for a key in the number map.- Returns:
- The highest value for a key in the map.
-
setUpperLimit
private void setUpperLimit(java.lang.Integer upper)
Set the highest value for the key in the map.- Parameters:
upper
- The new highest value for a key in the map.
-
getLowerLimit
public java.lang.Integer getLowerLimit()
Get the lowest value for a key in the number map.- Returns:
- The lowest value for a key in the map.
-
setLowerLimit
private void setLowerLimit(java.lang.Integer lower)
Set the lowest value for the key in the map.- Parameters:
lower
- The new lowest value for a key in the map.
-
-