setasign\SetaPDF2\Core\DataStructure\Tree

NumberTree Data structure class for Number Trees

File: /SetaPDF v2/Core/DataStructure/Tree/NumberTree.php
Old class name (alias): \SetaPDF_Core_DataStructure_NumberTree

Class hierarchy

Implements

Summary

Static Properties

$leafNodesPerNode

static public int AbstractTree::$leafNodesPerNode = 64

Leaf nodes per node


Properties

$_document

The document to which the tree depends to

$_isNew

protected bool AbstractTree::$_isNew = false

Is this a new tree or should we update an existing one

$_rootDictionary

The dictionary entry in the dictionary of the root object

$_values

protected array AbstractTree::$_values = array()

A cache for resolved entries

The index is the key while the value is an array of both key and value object.


Methods

__construct()

The constructor.

Parameters
$rootDictionary : \SetaPDF_Core_Type_Dictionary
 
$document : \SetaPDF_Core_Document
 

_findLastLeafNode()

Finds the last leaf node.

Parameters
$node : \SetaPDF_Core_Type_Dictionary
 
$intermediateNodes : array
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_findLeaveNodeByKey()

protected AbstractTree::_findLeaveNodeByKey (
\SetaPDF_Core_Type_Dictionary $node,
int $key,
bool $exactMatch = true,
array &$intermediateNodes = array ( ),
&$kidsInfo = array ( )
): bool|\SetaPDF_Core_Type_Dictionary

Find a appropriate leaf node by a key.

Parameters
$node : \SetaPDF_Core_Type_Dictionary
 
$key : int
 
$exactMatch : bool
 
$intermediateNodes : array
 
$kidsInfo
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_get()

protected AbstractTree::_get (
\SetaPDF_Core_Type_Dictionary $node,
string $key
): array|false

Gets a key value pair by a root node and a key.

Parameters
$node : \SetaPDF_Core_Type_Dictionary
 
$key : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_getBlankLeafNodeObject()

Helper method to create a blank leaf node

Parameters
$intermediate : bool
 

_getEntriesKeyName()

protected NumberTree::_getEntriesKeyName (
void
): string

Get the entries key name for this implementation.

See

_getKeyClassName()

protected NumberTree::_getKeyClassName (
void
): string

Get the key class name used by this tree implementation.

See

_getKeyInstanceName()

protected AbstractTree::_getKeyInstanceName (
void
): string

Get the key instance name by tree implementation.

_getSortType()

protected NumberTree::_getSortType (
void
): int

Get the sort type for this tree implementation.

See

add()

Add a keyed value to the tree.

For name trees: Make sure you pass the name in PDFDocEncoding or UTF-16BE including BOM.

Parameters
$key : int|string|\SetaPDF_Core_Type_ScalarValue

Depends on the implementation

$value : \SetaPDF_Core_Type_AbstractType
 
Exceptions

Throws KeyAlreadyExistsException

Throws \setasign\SetaPDF2\Core\Type\Exception

See

cleanUp()

public AbstractTree::cleanUp (
void
): void

Release objects to free memory and cycled references

After calling this method the instance of this object is unusable!

get()

public AbstractTree::get (
string|int $key,
string $className = null
): \SetaPDF_Core_Type_AbstractType|false|mixed

Get an object by a key.

Parameters
$key : string|int
 
$className : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAll()

public AbstractTree::getAll (
bool $keysOnly = false,
?string $className = null
): array

Get all keyed objects.

Parameters
$keysOnly : bool
 
$className : ?string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getEntriesKeyName()

public AbstractTree::getEntriesKeyName (
void
): string

Get the entries key name.

isNew()

public AbstractTree::isNew (
void
): bool

Checks whether this tree is new or initiated with existing entries.

merge()

public AbstractTree::merge (
\SetaPDF_Core_DataStructure_Tree $tree,
?callback $alreadyExistsCallback = null
): array

Merges another tree into this tree.

As all items have to be unique this method will call a callback function given in $alreadyExistsCallback if an item already exists.

Parameters
$tree : \SetaPDF_Core_DataStructure_Tree
 
$alreadyExistsCallback : ?callback

Will be called if a item already exists.
This method can take control over the renaming of the item. The method will be called as long as it will not throw an exception of KeyAlreadyExistsException.
The parameter of the callback function are: The key value and an incremental number of renaming attempts.

Return Values

An array of renamed items

Exceptions

Throws KeyAlreadyExistsException

Throws \setasign\SetaPDF2\Core\Type\Exception

remove()

public AbstractTree::remove (
string $key
): bool

Remove a key from the tree

Parameters
$key : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

toPhp()

public AbstractTree::toPhp (
void
): array

Returns an array with named keys and name values

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

See