Package com.pd4ml.pdf.cos.util
Class NumberTreeUtil
- java.lang.Object
-
- com.pd4ml.pdf.cos.util.NumberTreeUtil
-
public final class NumberTreeUtil extends java.lang.ObjectLooks up a value in a PDF "number tree" (/Numsleaf array of[key1, value1, key2, value2, ...]pairs, optionally split across/Kidswith/Limitsranges for large trees) -- the structure used by/StructTreeRoot/ParentTree,/PageLabelsand a handful of other PDF constructs.Thread-safety: this class holds no state of its own (every method is
static, and each call builds its own fresh visited-set for cycle detection) -- call either method freely and concurrently from any number of threads, including several at once walking the very same tree (COSDictionary/COSArrayreads here are read-only).
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static COSBaselookup(COSDictionary root, int key)Returns the value stored underkeyin the number tree rooted atroot, ornull.static intmaxKey(COSDictionary root)The highest key stored anywhere in the number tree rooted atroot(searching every/Kidssubtree, ignoring/Limitssince those are advisory and this needs the true maximum regardless), or-1ifrootisnullor the tree has no entries at all.
-
-
-
Method Detail
-
lookup
public static COSBase lookup(COSDictionary root, int key)
Returns the value stored underkeyin the number tree rooted atroot, ornull.
-
maxKey
public static int maxKey(COSDictionary root)
The highest key stored anywhere in the number tree rooted atroot(searching every/Kidssubtree, ignoring/Limitssince those are advisory and this needs the true maximum regardless), or-1ifrootisnullor the tree has no entries at all. Used by a caller that wants to append fresh, never-colliding keys to an existing number tree -- e.g. adding new/StructTreeRoot/ParentTreeentries for annotations a feature just added to an already-tagged PDF -- when the tree's own/ParentTreeNextKey-style hint (a convention specific toParentTree, not a general number-tree feature) isn't present or trusted.
-
-