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
AbstractTree
provides 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 void
buildPath(@NotNull StringBuilder sb)
protected abstract @NotNull AbstractTree
createChild(@NotNull String name)
Factory method for creating child treesboolean
exists()
Determine whether this tree has been removed or does not exist otherwise (e.g.@NotNull Tree
getChild(@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_ORDER
property is set.@NotNull Iterable<Tree>
getChildren()
All accessible children of thisTree
instance.long
getChildrenCount(long max)
Determine the number of children of thisTree
instance taking access restrictions into account.protected @NotNull String[]
getInternalNodeNames()
protected abstract @NotNull NodeBuilder
getNodeBuilder()
@NotNull NodeState
getNodeState()
@NotNull AbstractTree
getParent()
protected abstract @Nullable AbstractTree
getParentOrNull()
@NotNull String
getPath()
@NotNull Iterable<? extends PropertyState>
getProperties()
All accessible property states.@Nullable PropertyState
getProperty(@NotNull String name)
Get a property statelong
getPropertyCount()
Determine the number of properties accessible to the current content session.@Nullable Tree.Status
getPropertyStatus(@NotNull String name)
Get theStatus
of a property state ornull
.@NotNull Tree.Status
getStatus()
Get theStatus
of this tree instance.boolean
hasChild(@NotNull String name)
Determine if a child of thisTree
instance exists.protected boolean
hasOrderableChildren()
boolean
hasProperty(@NotNull String name)
Determine if a property state exists and is accessible.protected boolean
isHidden(@NotNull String name)
Determine whether an item should be hidden.boolean
isRoot()
String
toString()
-
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
null
for the root
-
getNodeBuilder
@NotNull protected abstract @NotNull NodeBuilder getNodeBuilder()
- Returns:
- The
NodeBuilder
for 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:
true
if the item is hidden,false
otherwise.
-
getInternalNodeNames
@NotNull protected @NotNull String[] getInternalNodeNames()
-
getNodeState
@NotNull public @NotNull NodeState getNodeState()
- Returns:
- the underlying
NodeState
of this tree
-
hasOrderableChildren
protected boolean hasOrderableChildren()
- Returns:
true
if this tree has orderable children;false
otherwise.
-
getChildNames
@NotNull protected @NotNull Iterable<String> getChildNames()
Returns the list of child names considering its ordering when theTreeConstants.OAK_CHILD_ORDER
property 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:Tree
Get theStatus
of this tree instance.
-
exists
public boolean exists()
Description copied from interface:Tree
Determine 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:Tree
Get a possibly non existing child of thisTree
.- Specified by:
getChild
in 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:Tree
Get a property state- Specified by:
getProperty
in interfaceTree
- Parameters:
name
- The name of the property state.- Returns:
- the property state with the given
name
ornull
if no such property state exists or the property is not accessible.
-
hasProperty
public boolean hasProperty(@NotNull @NotNull String name)
Description copied from interface:Tree
Determine if a property state exists and is accessible.- Specified by:
hasProperty
in interfaceTree
- Parameters:
name
- The name of the property state- Returns:
true
if and only if a property with the givenname
exists and is accessible.
-
getPropertyCount
public long getPropertyCount()
Description copied from interface:Tree
Determine the number of properties accessible to the current content session.- Specified by:
getPropertyCount
in interfaceTree
- Returns:
- The number of accessible properties.
-
getPropertyStatus
@Nullable public @Nullable Tree.Status getPropertyStatus(@NotNull @NotNull String name)
Description copied from interface:Tree
Get theStatus
of a property state ornull
.- Specified by:
getPropertyStatus
in interfaceTree
- Parameters:
name
- The name of the property state.- Returns:
- The status of the property state with the given
name
ornull
in 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:Tree
All accessible property states. The returnedIterable
has snapshot semantics. That is, it reflect the state of thisTree
instance at the time of the call. Later changes to this instance are no visible to iterators obtained from the returned iterable.- Specified by:
getProperties
in interfaceTree
- Returns:
- An
Iterable
for all accessible property states.
-
hasChild
public boolean hasChild(@NotNull @NotNull String name)
Description copied from interface:Tree
Determine if a child of thisTree
instance 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:Tree
Determine the number of children of thisTree
instance 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:
getChildrenCount
in interfaceTree
- Parameters:
max
- the maximum value- Returns:
- the number of accessible children.
-
getChildren
@NotNull public @NotNull Iterable<Tree> getChildren()
Description copied from interface:Tree
All accessible children of thisTree
instance. The returnedIterable
has snapshot semantics. That is, it reflect the state of thisTree
instance at the time of the call. Later changes to this instance are not visible to iterators obtained from the returned iterable.- Specified by:
getChildren
in interfaceTree
- Returns:
- An
Iterable
for all accessible children
-
-