Class HierarchicalContainer

A specialized Container whose contents can be accessed like it was a tree-like structure.

addItem()

See Also
addItem()

addItem(Object)

areChildrenAllowed(Object)

Parameters

itemId

ID of the Item in the container whose child capability is to be tested

return

true if the specified Item exists in the Container and it can have children, false if it's not found from the container or it can't have children.

Description copied from interface: areChildrenAllowed

Tests if the Item with given ID can have any children. If the Container also implements the Managed interface, the items created with newItem can have children by default.

getChildren(Object)

Parameters

itemId

ID of the Item whose children the caller is interested in

return

An unmodifiable collection containing the IDs of all other Items that are children in the container hierarchy

Description copied from interface: getChildren

Gets the IDs of all Items that are children of the specified Item. The returned collection is unmodifiable.

getParent(Object)

Parameters

itemId

ID of the Item whose parent the caller wishes to find out.

return

the ID of the parent Item. Will be null if the specified Item is a root element.

Description copied from interface: getParent

Gets the ID of the parent Item of the specified Item.

hasChildren(Object)

Parameters

itemId

ID of the Item whose leaf status is to be tested

return

true if the specified Item is a leaf, false if not

Description copied from interface: hasChildren

Tests if the Item specified with itemId has any child Items, that is, is it a leaf Item. The getChildren(java.lang.Object) method always returns null for leaf Items.

Note that being a leaf does not imply whether or not an Item is allowed to have children.

.

isRoot(Object)

Parameters

itemId

ID of the Item whose root status is to be tested

return

true if the specified Item is a root, false if not

Description copied from interface: isRoot

Tests if the Item specified with itemId is a root Item. The hierarchical container can have more than one root and must have at least one unless it is empty. The getParent(java.lang.Object) method always returns null for root Items.

removeAllItems()

removeItem(Object)

rootItemIds()

Parameters

return

An unmodifiable collection containing IDs of all root elements of the container

Description copied from interface: rootItemIds

Gets the IDs of all Items in the container that don't have a parent. Such items are called root Items. The returned collection is unmodifiable.

setChildrenAllowed(Object, boolean)

Parameters

itemId

ID of the Item in the container whose child capability is to be set

childrenAllowed

boolean value specifying if the Item can have children or not

return

true if the operation succeeded, false if not

Sets the given Item's capability to have children. If the Item identified with itemId already has children and areChildrenAllowed is false this method fails and false is returned; the children must be first explicitly removed with setParent(java.lang.Object, java.lang.Object) or removeItem(java.lang.Object) .

setParent(Object, Object)

Parameters

itemId

ID of the item to be set as the child of the Item identified with newParentId

newParentId

ID of the Item that's to be the new parent of the Item identified with itemId

return

true if the operation succeeded, false if not

Sets the parent of an Item. The new parent item must exist and be able to have children. ( canHaveChildren(newParentId) == true ). It is also possible to detach a node from the hierarchy (and thus make it root) by setting the parent null .