Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# NumberTree

extends Object

java.lang.Object
↳ | com.pdftron.sdf.NumberTree

## Class Overview

A NumberTree is a common data structure in PDF. See section 3.8.6 'Number Trees' in PDF Reference Manual for more details. A number tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NumberTrees allow efficient storage of very large association collections (number/Obj* maps). A NumberTree can have many more entries than a SDF/Cos dictionary can. Sample code: PDFDoc doc = new PDFDoc("../Data/test.pdf"); NumberTree labels = doc.getRoot().get("PageLabels").value()); if (labels.isValid()) { // Traversing the NumberTree for (NumberTreeIterator i = labels.GetIterator(); i.HasNext(); i.Next()) num = i.Key().GetNumber(); }

## Summary

Public Constructors
| NumberTree(Obj number_tree) Create a high level NumberTree wrapper around an existing SDF/Cos NumberTree.

Public Methods
void | erase(DictIterator pos) Removes the NumberTree entry pointed by the iterator.
void | erase(long key) Removes the specified object from the tree.
DictIterator | getIterator() Get the iterator.
DictIterator | getIterator(long key) Search for the specified key in the NumberTree.
Obj | getSDFObj() Get the SDFObj.
Obj | getValue(long key) Get the value of the specified NumberTree.
boolean | isValid() Checks if NumberTree is valid.
void | put(long key, Obj value) Puts a new entry in the name tree.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public NumberTree (Obj number_tree)

Create a high level NumberTree wrapper around an existing SDF/Cos NumberTree. This does not copy the object.

##### Parameters

number_tree | SDF/Cos root of the NumberTree object.

## Public Methods

#### public void erase (DictIterator pos)

Removes the NumberTree entry pointed by the iterator.

##### Parameters

pos | the pos

##### Throws

PDFNetException |

#### public void erase (long key)

Removes the specified object from the tree. Does nothing if no object with that number exists.

##### Parameters

key | A number representing the key of the entry to be removed.

##### Throws

PDFNetException |

#### public DictIterator getIterator ()

Get the iterator.

##### Returns

- an iterator to the first key/value pair (i.e. NNTreeData) in the document. You can use the Next method on the returned iterator to traverese all entries stored under the NumberTree. `for (NumberTreeIterator i = dests.getIterator(); i.hasNext(); i.next()) num = i.GetKey().GetNumber();`

##### Throws

PDFNetException |

#### public DictIterator getIterator (long key)

Search for the specified key in the NumberTree.

##### Parameters

key | the number representing the key to be found. `NumberTreeIterator i = dests.find(5); if (i.hasNext()) { double key = i.getKey()->getNumber(); Obj value=i.getValue();` }

##### Returns

- If the key is present the function returns a NumberTreeIterator the points to the given Key/Value pair. If the key is not found the function returns End() (a non-valid) iterator.

##### Throws

PDFNetException |

#### public Obj getSDFObj ()

Get the SDFObj.

##### Returns

- the object to the underlying SDF/Cos object. If the NumberTree.IsValid() returns false the SDF/Cos object is NULL.

#### public Obj getValue (long key)

Get the value of the specified NumberTree.

##### Parameters

key | the key of the NumberTree

##### Returns

- the value of specified NumberTree

##### Throws

PDFNetException |

#### public boolean isValid ()

Checks if NumberTree is valid.

##### Returns

- whether this is a valid (non-null) NumberTree. If the function returns false the underlying SDF/Cos object is null and the NumberTree object should be treated as null as well.

##### Throws

PDFNetException |

#### public void put (long key, Obj value)

Puts a new entry in the name tree. If an entry with this number is already in the tree, it is replaced.

##### Parameters

key | A number representing the key of the new entry.
value | the value

##### Throws

PDFNetException |