Class AbstractTree
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.tree.impl.AbstractTree
-
- All Implemented Interfaces:
Tree
- Direct Known Subclasses:
AbstractMutableTree,ImmutableTree
public abstract class AbstractTree extends Object implements Tree
AbstractTreeprovides default implementations for most read methods ofTree. Furthermore it handles hides hidden items.
-
-
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 AbstractTree()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbuildPath(@NotNull StringBuilder sb)protected abstract @NotNull AbstractTreecreateChild(@NotNull String name)Factory method for creating child treesbooleanexists()Determine whether this tree has been removed or does not exist otherwise (e.g.@NotNull TreegetChild(@NotNull String name)Get a possibly non existing child of thisTree.protected @NotNull Iterable<String>getChildNames()Returns the list of child names considering its ordering when theTreeConstants.OAK_CHILD_ORDERproperty is set.@NotNull Iterable<Tree>getChildren()All accessible children of thisTreeinstance.longgetChildrenCount(long max)Determine the number of children of thisTreeinstance taking access restrictions into account.protected @NotNull String[]getInternalNodeNames()protected abstract @NotNull NodeBuildergetNodeBuilder()@NotNull NodeStategetNodeState()@NotNull AbstractTreegetParent()protected abstract @Nullable AbstractTreegetParentOrNull()@NotNull StringgetPath()@NotNull Iterable<? extends PropertyState>getProperties()All accessible property states.@Nullable PropertyStategetProperty(@NotNull String name)Get a property statelonggetPropertyCount()Determine the number of properties accessible to the current content session.@Nullable Tree.StatusgetPropertyStatus(@NotNull String name)Get theStatusof a property state ornull.@NotNull Tree.StatusgetStatus()Get theStatusof this tree instance.booleanhasChild(@NotNull String name)Determine if a child of thisTreeinstance exists.protected booleanhasOrderableChildren()booleanhasProperty(@NotNull String name)Determine if a property state exists and is accessible.protected booleanisHidden(@NotNull String name)Determine whether an item should be hidden.booleanisRoot()StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.oak.api.Tree
addChild, getName, orderBefore, remove, removeProperty, setOrderableChildren, setProperty, setProperty, setProperty
-
-
-
-
Method Detail
-
createChild
@NotNull protected abstract @NotNull AbstractTree createChild(@NotNull @NotNull String name) throws IllegalArgumentException
Factory method for creating child trees- Parameters:
name- name of the child tree- Returns:
- child tree of this tree with the given
name - Throws:
IllegalArgumentException- if the given name string is empty or contains the forward slash character
-
getParentOrNull
@Nullable protected abstract @Nullable AbstractTree getParentOrNull()
- Returns:
- the parent of this tree or
nullfor the root
-
getNodeBuilder
@NotNull protected abstract @NotNull NodeBuilder getNodeBuilder()
- Returns:
- The
NodeBuilderfor the underlying node state
-
isHidden
protected boolean isHidden(@NotNull @NotNull String name)Determine whether an item should be hidden. I.e. not exposed through this tree.- Parameters:
name- name of an item- Returns:
trueif the item is hidden,falseotherwise.
-
getInternalNodeNames
@NotNull protected @NotNull String[] getInternalNodeNames()
-
getNodeState
@NotNull public @NotNull NodeState getNodeState()
- Returns:
- the underlying
NodeStateof this tree
-
hasOrderableChildren
protected boolean hasOrderableChildren()
- Returns:
trueif this tree has orderable children;falseotherwise.
-
getChildNames
@NotNull protected @NotNull Iterable<String> getChildNames()
Returns the list of child names considering its ordering when theTreeConstants.OAK_CHILD_ORDERproperty is set.- Returns:
- the list of child names.
-
isRoot
public boolean isRoot()
-
getPath
@NotNull public @NotNull String getPath()
-
buildPath
protected void buildPath(@NotNull @NotNull StringBuilder sb)
-
getStatus
@NotNull public @NotNull Tree.Status getStatus()
Description copied from interface:TreeGet theStatusof this tree instance.
-
exists
public boolean exists()
Description copied from interface:TreeDetermine whether this tree has been removed or does not exist otherwise (e.g. caused by a refresh, rebase or commit) or is not visible due to access control restriction or does not exist at all.
-
getParent
@NotNull public @NotNull AbstractTree getParent()
-
getChild
@NotNull public @NotNull Tree getChild(@NotNull @NotNull String name) throws IllegalArgumentException
Description copied from interface:TreeGet a possibly non existing child of thisTree.- Specified by:
getChildin interfaceTree- Parameters:
name- The name of the child to retrieve.- Returns:
- The child with the given
name. - Throws:
IllegalArgumentException- if the given name is invalid
-
getProperty
@Nullable public @Nullable PropertyState getProperty(@NotNull @NotNull String name)
Description copied from interface:TreeGet a property state- Specified by:
getPropertyin interfaceTree- Parameters:
name- The name of the property state.- Returns:
- the property state with the given
nameornullif no such property state exists or the property is not accessible.
-
hasProperty
public boolean hasProperty(@NotNull @NotNull String name)Description copied from interface:TreeDetermine if a property state exists and is accessible.- Specified by:
hasPropertyin interfaceTree- Parameters:
name- The name of the property state- Returns:
trueif and only if a property with the givennameexists and is accessible.
-
getPropertyCount
public long getPropertyCount()
Description copied from interface:TreeDetermine the number of properties accessible to the current content session.- Specified by:
getPropertyCountin interfaceTree- Returns:
- The number of accessible properties.
-
getPropertyStatus
@Nullable public @Nullable Tree.Status getPropertyStatus(@NotNull @NotNull String name)
Description copied from interface:TreeGet theStatusof a property state ornull.- Specified by:
getPropertyStatusin interfaceTree- Parameters:
name- The name of the property state.- Returns:
- The status of the property state with the given
nameornullin no such property state exists or if the name refers to a property that is not accessible.
-
getProperties
@NotNull public @NotNull Iterable<? extends PropertyState> getProperties()
Description copied from interface:TreeAll accessible property states. The returnedIterablehas snapshot semantics. That is, it reflect the state of thisTreeinstance at the time of the call. Later changes to this instance are no visible to iterators obtained from the returned iterable.- Specified by:
getPropertiesin interfaceTree- Returns:
- An
Iterablefor all accessible property states.
-
hasChild
public boolean hasChild(@NotNull @NotNull String name)Description copied from interface:TreeDetermine if a child of thisTreeinstance exists. If no child exists or an existing child isn't accessible this method returnsfalse.
-
getChildrenCount
public long getChildrenCount(long max)
Description copied from interface:TreeDetermine the number of children of thisTreeinstance taking access restrictions into account.If an implementation does know the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).
- Specified by:
getChildrenCountin interfaceTree- Parameters:
max- the maximum value- Returns:
- the number of accessible children.
-
getChildren
@NotNull public @NotNull Iterable<Tree> getChildren()
Description copied from interface:TreeAll accessible children of thisTreeinstance. The returnedIterablehas snapshot semantics. That is, it reflect the state of thisTreeinstance at the time of the call. Later changes to this instance are not visible to iterators obtained from the returned iterable.- Specified by:
getChildrenin interfaceTree- Returns:
- An
Iterablefor all accessible children
-
-