Top Description Constructors Methods
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline

public abstract Class PDOutlineNode

extends PDDictionaryWrapper
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline, org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem
Imports
org.apache.pdfbox.cos.COSDictionary, .COSName, org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper

Base class for a node in the outline of a PDF document.
Author
Ben Litchfield

Constructor Summary

AccessConstructor and Description
public
PDOutlineNode()

Default Constructor.

public
PDOutlineNode(COSDictionary
The dictionary storage.
dict
)

Method Summary

Modifier and TypeMethod and Description
public void
addFirst(PDOutlineItem
The node to add.
newChild
)

Adds the given node to the top of the children list.

public void
addLast(PDOutlineItem
The node to add.
newChild
)

Adds the given node to the bottom of the children list.

private void
append(PDOutlineItem newChild)

Appends the child to the linked list of children.

public Iterable<PDOutlineItem>

Returns:

An Iterable view of the items children
children
()

public void
closeNode()

Close this node.

public PDOutlineItem

Returns:

The first child or null if there is no child.
getFirstChild
()

public PDOutlineItem

Returns:

The last child or null if there is no child.
getLastChild
()

public int

Returns:

The Count attribute of the outline dictionary.
getOpenCount
()

Get the number of open nodes or a negative number if this node is closed.

pack-priv PDOutlineItem
pack-priv PDOutlineNode

Returns:

The parent of this node or null if there is no parent.
getParent
()

public boolean

Returns:

true if the node has at least one child
hasChildren
()

public boolean

Returns:

true if this node count is greater than zero, false otherwise.
isNodeOpen
()

public void
openNode()

This will set this node to be open when it is shown in the viewer.

private void
prepend(PDOutlineItem newChild)

Prepends the child to the linked list of children.

pack-priv void
pack-priv void
setFirstChild(PDOutlineNode
The new first child.
outlineNode
)

Set the first child, this will be maintained by this class.

pack-priv void
setLastChild(PDOutlineNode
The new last child.
outlineNode
)

Set the last child, this will be maintained by this class.

pack-priv void
setOpenCount(int
The new open count.
openCount
)

Set the open count.

pack-priv void
private void
pack-priv void
updateParentOpenCount(int
The amount to update by.
delta
)

The count parameter needs to be updated when you add, remove, open or close outline items.

pack-priv void
Inherited from org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper:
equalsgetCOSObjecthashCode

Constructor Detail

PDOutlineNodeback to summary
public PDOutlineNode()

Default Constructor.

PDOutlineNodeback to summary
public PDOutlineNode(COSDictionary dict)
Parameters
dict:COSDictionary

The dictionary storage.

Method Detail

addFirstback to summary
public void addFirst(PDOutlineItem newChild)

Adds the given node to the top of the children list.

Parameters
newChild:PDOutlineItem

The node to add.

Exceptions
IllegalArgumentException:
if the given node is part of a list (i.e. if it has a previous or a next sibling)
addLastback to summary
public void addLast(PDOutlineItem newChild)

Adds the given node to the bottom of the children list.

Parameters
newChild:PDOutlineItem

The node to add.

Exceptions
IllegalArgumentException:
if the given node is part of a list (i.e. if it has a previous or a next sibling)
appendback to summary
private void append(PDOutlineItem newChild)

Appends the child to the linked list of children. This method only adjust pointers but doesn't take care of the Count key in the parent hierarchy.

childrenback to summary
public Iterable<PDOutlineItem> children()
Returns:Iterable<PDOutlineItem>

An Iterable view of the items children

closeNodeback to summary
public void closeNode()

Close this node.

getFirstChildback to summary
public PDOutlineItem getFirstChild()
Returns:PDOutlineItem

The first child or null if there is no child.

getLastChildback to summary
public PDOutlineItem getLastChild()
Returns:PDOutlineItem

The last child or null if there is no child.

getOpenCountback to summary
public int getOpenCount()

Get the number of open nodes or a negative number if this node is closed. See PDF Reference 32000-1:2008 table 152 and 153 for more details. This value is updated as you append children and siblings.

Returns:int

The Count attribute of the outline dictionary.

getOutlineItemback to summary
pack-priv PDOutlineItem getOutlineItem(COSName name)
getParentback to summary
pack-priv PDOutlineNode getParent()
Returns:PDOutlineNode

The parent of this node or null if there is no parent.

hasChildrenback to summary
public boolean hasChildren()
Returns:boolean

true if the node has at least one child

isNodeOpenback to summary
public boolean isNodeOpen()
Returns:boolean

true if this node count is greater than zero, false otherwise.

openNodeback to summary
public void openNode()

This will set this node to be open when it is shown in the viewer. By default, when a new node is created it will be closed. This will do nothing if the node is already open.

prependback to summary
private void prepend(PDOutlineItem newChild)

Prepends the child to the linked list of children. This method only adjust pointers but doesn't take care of the Count key in the parent hierarchy.

requireSingleNodeback to summary
pack-priv void requireSingleNode(PDOutlineItem node)
Exceptions
IllegalArgumentException:
if the given node is part of a list (i.e. if it has a previous or a next sibling)
setFirstChildback to summary
pack-priv void setFirstChild(PDOutlineNode outlineNode)

Set the first child, this will be maintained by this class.

Parameters
outlineNode:PDOutlineNode

The new first child.

setLastChildback to summary
pack-priv void setLastChild(PDOutlineNode outlineNode)

Set the last child, this will be maintained by this class.

Parameters
outlineNode:PDOutlineNode

The new last child.

setOpenCountback to summary
pack-priv void setOpenCount(int openCount)

Set the open count. This number is automatically managed for you when you add items to the outline.

Parameters
openCount:int

The new open count.

setParentback to summary
pack-priv void setParent(PDOutlineNode parent)
switchNodeCountback to summary
private void switchNodeCount()
updateParentOpenCountback to summary
pack-priv void updateParentOpenCount(int delta)

The count parameter needs to be updated when you add, remove, open or close outline items.

Parameters
delta:int

The amount to update by.

updateParentOpenCountForAddedChildback to summary
pack-priv void updateParentOpenCountForAddedChild(PDOutlineItem newChild)