Class AbstractMutableTree
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.tree.impl.AbstractTree
-
- org.apache.jackrabbit.oak.plugins.tree.impl.AbstractMutableTree
-
- All Implemented Interfaces:
Tree
- Direct Known Subclasses:
NodeBuilderTree
public abstract class AbstractMutableTree extends AbstractTree
AbstractMutableTree
extendsAbstractTree
with implementations for most write methods ofTree
. Furthermore it handles the ordering of siblings.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.jackrabbit.oak.api.Tree
Tree.Status
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.oak.api.Tree
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description AbstractMutableTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Tree
addChild(@NotNull String name)
Add a child with the givenname
.boolean
orderBefore(@Nullable String name)
Orders thisTree
before the sibling tree with the givenname
.boolean
remove()
Remove this tree instance.void
removeProperty(@NotNull String name)
Remove the property with the given name.void
setOrderableChildren(boolean enable)
Changes the nature of this tree such that the order of the children is kept stable.<T> void
setProperty(@NotNull String name, T value)
Set a property state<T> void
setProperty(@NotNull String name, T value, @NotNull Type<T> type)
Set a property statevoid
setProperty(@NotNull PropertyState property)
Set a property stateprotected void
updateChildOrder(boolean force)
Updates the child order to match any added or removed child nodes that are not yet reflected in theTreeConstants.OAK_CHILD_ORDER
property.-
Methods inherited from class org.apache.jackrabbit.oak.plugins.tree.impl.AbstractTree
buildPath, createChild, exists, getChild, getChildNames, getChildren, getChildrenCount, getInternalNodeNames, getNodeBuilder, getNodeState, getParent, getParentOrNull, getPath, getProperties, getProperty, getPropertyCount, getPropertyStatus, getStatus, hasChild, hasOrderableChildren, hasProperty, isHidden, isRoot, toString
-
-
-
-
Method Detail
-
remove
public boolean remove()
Description copied from interface:Tree
Remove this tree instance. This operation never succeeds for the root tree.- Returns:
true
if the node was removed;false
otherwise.
-
addChild
@NotNull public @NotNull Tree addChild(@NotNull @NotNull String name) throws IllegalArgumentException
Description copied from interface:Tree
Add a child with the givenname
. Does nothing if such a child already exists.- Parameters:
name
- name of the child. A valid name does not start with a colon, is not empty and does not contain a forward slash.- Returns:
- the
Tree
instance of the child with the givenname
. - Throws:
IllegalArgumentException
- ifname
is not valid.
-
setOrderableChildren
public void setOrderableChildren(boolean enable)
Description copied from interface:Tree
Changes the nature of this tree such that the order of the children is kept stable. The expected behavior is as follows:- Calling
setOrderableChildren(true)
on a tree the first time will stabilize the order of existing children. Any subsequentTree.addChild(String)
call is guaranteed to insert the new tree and the end of the child list. - Calling
setOrderableChildren(true)
on a tree that already has its children ordered has no effect. - Calling
setOrderableChildren(false)
on a tree that doesn't have ordered children has not effect - Calling
setOrderableChildren(false)
on a tree with ordered children will remove the necessity to keep the child list stable. The order of children uponTree.getChildren()
is subsequently undefined.
Calling
Tree.orderBefore(String)
on a tree, implicitly enables orderable children on the parent tree.- Parameters:
enable
- Enable (or disable) orderable children for this tree.
- Calling
-
updateChildOrder
protected void updateChildOrder(boolean force)
Updates the child order to match any added or removed child nodes that are not yet reflected in theTreeConstants.OAK_CHILD_ORDER
property. If theforce
flag is set, the child order is set in any case, otherwise only if the node already is orderable.- Parameters:
force
- whether to add child order information if it doesn't exist
-
orderBefore
public boolean orderBefore(@Nullable @Nullable String name)
Description copied from interface:Tree
Orders thisTree
before the sibling tree with the givenname
. Calling this method for the first time on thisTree
or any of its siblings will persist the current order of siblings and maintain it from this point on.- Parameters:
name
- the name of the sibling node where this tree is ordered before. This tree will become the last sibling ifname
isnull
.- Returns:
false
if there is no sibling with the givenname
or no reordering was performed;true
otherwise.
-
setProperty
public void setProperty(@NotNull @NotNull PropertyState property)
Description copied from interface:Tree
Set a property state- Parameters:
property
- The property state to set
-
setProperty
public <T> void setProperty(@NotNull @NotNull String name, @NotNull T value) throws IllegalArgumentException
Description copied from interface:Tree
Set a property state- Type Parameters:
T
- The type of this property. Must be one ofString, Blob, byte[], Long, Integer, Double, Boolean, BigDecimal
- Parameters:
name
- The name of this property. A valid name does not start with a colon, is not empty and does not contain a forward slash.value
- The value of this property- Throws:
IllegalArgumentException
- ifT
is not one of the above types or ifname
is not valid.
-
setProperty
public <T> void setProperty(@NotNull @NotNull String name, @NotNull T value, @NotNull @NotNull Type<T> type) throws IllegalArgumentException
Description copied from interface:Tree
Set a property state- Type Parameters:
T
- The type of this property.- Parameters:
name
- The name of this property. A valid name does not start with a colon, is not empty and does not contain a forward slash.value
- The value of this propertytype
- The type of this property.- Throws:
IllegalArgumentException
- ifname
is not valid.
-
-