java.lang.Object | |
↳ | com.pdftron.sdf.NameTree |
A NameTree is a common data structure in PDF. See section 3.8.5 'Name Trees' in PDF Reference Manual for more details. A name tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NameTrees allow efficient storage of very large association collections (string/Obj* maps). A NameTree can have many more entries than a SDF/Cos dictionary can. NameTree-s use SDF/Cos-style strings (not null-terminated C strings), which may use Unicode encoding etc.
PDFDoc doc = new PDFDoc("../Data/PDFReference.pdf");
NameTree dests = NameTree.find(doc.getSDFDoc(), "Dests");
if (dests.isValid()) {
// Traversing the NameTree
for (DictIterator i = dests.getIterator(); i.hasNext(); i.next())
string key = i.key().getAsPDFText(); // ...
}
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NameTree(Obj name_tree)
Create a high level NameTree wrapper around an existing SDF/Cos NameTree.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static NameTree |
create(Doc doc, String name)
Retrieves the NameTree inside the '/Root/Names' dictionary with the
specified key name, or creates it if it does not exist.
| ||||||||||
void |
erase(DictIterator pos)
Removes the NameTree entry pointed by the iterator.
| ||||||||||
void |
erase(byte[] key)
Removes the specified object from the tree.
| ||||||||||
static NameTree |
find(Doc doc, String name)
Retrieves a name tree, with the given key name, from the '/Root/Names'
dictionary of the doc.
| ||||||||||
NameTreeIterator |
getIterator(byte[] key)
Search for the specified key in the NameTree.
| ||||||||||
NameTreeIterator |
getIterator()
Get the NameTree iterator.
| ||||||||||
Obj |
getSDFObj()
Get the SDFObj.
| ||||||||||
Obj |
getValue(byte[] key)
Get the value of specified key
| ||||||||||
boolean |
isValid()
Checks if NameTree is valid.
| ||||||||||
void |
put(byte[] key, Obj value)
Puts a new entry in the name tree.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a high level NameTree wrapper around an existing SDF/Cos NameTree. This does not copy the object.
name_tree | SDF/Cos root of the NameTree object. |
---|
Retrieves the NameTree inside the '/Root/Names' dictionary with the specified key name, or creates it if it does not exist.
Note: although it is possible to create a name tree anywhere in the document the convention is that all trees are located under '/Root/Names' dictionary.
doc | - The document in which the name tree is created. |
---|---|
name | - The name of the NameTree to create. |
PDFNetException |
---|
Removes the NameTree entry pointed by the iterator.
pos | to be deleted NameTree |
---|
PDFNetException |
---|
Removes the specified object from the tree. Does nothing if no object with that name exists.
key | data buffer representing the key of the entry to be removed. |
---|
PDFNetException |
---|
Retrieves a name tree, with the given key name, from the '/Root/Names' dictionary of the doc.
doc | - The document in which to search for the name. |
---|---|
name | - The name of the name tree to find. |
PDFNetException |
---|
Search for the specified key in the NameTree.
key | data buffer representing the key to be found. |
---|
PDFNetException | NameTreeIterator i = dests.find("MyKey", 5);
if (i.hasNext()) {
string key = i.getKey().getAsPDFText();
Obj value = i.getValue();
}
|
---|
Get the NameTree iterator. Example:
for (NameTreeIterator i = dests.getIterator(); i.hasNext(); i.next()) {
string key = i.getKey().getAsPDFText();
}
PDFNetException |
---|
Get the SDFObj.
Get the value of specified key
key | key of the NameTree |
---|
PDFNetException |
---|
Checks if NameTree is valid.
PDFNetException |
---|
Puts a new entry in the name tree. If an entry with this key is already in the tree, it is replaced.
key | data buffer representing the key of the new entry. |
---|---|
value | the value |
PDFNetException |
---|