SetaPDF_Core_DataStructure_NumberTree Data structure class for Number Trees

File: /SetaPDF v2/Core/DataStructure/NumberTree.php

Class hierarchy

Implements

Summary

Static Properties

$leafNodesPerNode

Leaf nodes per node


Properties

$_document

The document to which the tree depends to

$_isNew

protected boolean SetaPDF_Core_DataStructure_Tree::$_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 SetaPDF_Core_DataStructure_Tree::$_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 SetaPDF_Core_Type_Exception

_findLeaveNodeByKey()

protected SetaPDF_Core_DataStructure_Tree::_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 SetaPDF_Core_Type_Exception

_get()

protected SetaPDF_Core_DataStructure_Tree::_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 SetaPDF_Core_Type_Exception

_getBlankLeafNodeObject()

Helper method to create a blank leaf node

Parameters
$intermediate : boolean
 

_getEntriesKeyName()

Get the entries key name for this implementation.

See

_getKeyClassName()

Get the key class name used by this tree implementation.

See

_getKeyInstanceName()

Get the key instance name by tree implementation.

_getSortType()

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 SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException

Throws SetaPDF_Core_Type_Exception

See

cleanUp()

Release objects to free memory and cycled references

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

get()

public SetaPDF_Core_DataStructure_Tree::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 SetaPDF_Core_Type_Exception

getAll()

public SetaPDF_Core_DataStructure_Tree::getAll (
[ bool $keysOnly = false [, null|string $className = null ]]
): array

Get all keyed objects.

Parameters
$keysOnly : bool
 
$className : null|string
 
Exceptions

Throws SetaPDF_Core_Type_Exception

getEntriesKeyName()

Get the entries key name.

isNew()

public SetaPDF_Core_DataStructure_Tree::isNew (
void
): bool

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

merge()

public SetaPDF_Core_DataStructure_Tree::merge (
SetaPDF_Core_DataStructure_Tree $tree [, null|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 : null|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 SetaPDF_Core_DataStructure_Tree_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 SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException

Throws SetaPDF_Core_Type_Exception

remove()

public SetaPDF_Core_DataStructure_Tree::remove (
string $key
): boolean

Remove a key from the tree

Parameters
$key : string
 
Exceptions

Throws SetaPDF_Core_Type_Exception

toPhp()

public SetaPDF_Core_DataStructure_Tree::toPhp (
void
): array

Returns an array with named keys and name values

Exceptions

Throws SetaPDF_Core_Type_Exception

See