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 of Tree. Furthermore it handles hides hidden items.
  • Constructor Details

    • AbstractTree

      public AbstractTree()
  • Method Details

    • 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 the TreeConstants.OAK_CHILD_ORDER property is set.
      Returns:
      the list of child names.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isRoot

      public boolean isRoot()
      Specified by:
      isRoot in interface Tree
      Returns:
      true iff this is the root
    • getPath

      @NotNull public @NotNull String getPath()
      Specified by:
      getPath in interface Tree
      Returns:
      the absolute path of this Tree instance from its Root.
    • buildPath

      protected void buildPath(@NotNull @NotNull StringBuilder sb)
    • getStatus

      @NotNull public @NotNull Tree.Status getStatus()
      Description copied from interface: Tree
      Get the Status of this tree instance.
      Specified by:
      getStatus in interface Tree
      Returns:
      The status 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.
      Specified by:
      exists in interface Tree
      Returns:
      true if this tree exists, false otherwise.
    • getParent

      @NotNull public @NotNull AbstractTree getParent()
      Specified by:
      getParent in interface Tree
      Returns:
      the possibly non existent parent of this Tree.
    • getChild

      @NotNull public @NotNull Tree getChild(@NotNull @NotNull String name) throws IllegalArgumentException
      Description copied from interface: Tree
      Get a possibly non existing child of this Tree.
      Specified by:
      getChild in interface Tree
      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 interface Tree
      Parameters:
      name - The name of the property state.
      Returns:
      the property state with the given name or null 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 interface Tree
      Parameters:
      name - The name of the property state
      Returns:
      true if and only if a property with the given name 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 interface Tree
      Returns:
      The number of accessible properties.
    • getPropertyStatus

      @Nullable public @Nullable Tree.Status getPropertyStatus(@NotNull @NotNull String name)
      Description copied from interface: Tree
      Get the Status of a property state or null.
      Specified by:
      getPropertyStatus in interface Tree
      Parameters:
      name - The name of the property state.
      Returns:
      The status of the property state with the given name or null 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 returned Iterable has snapshot semantics. That is, it reflect the state of this Tree 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 interface Tree
      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 this Tree instance exists. If no child exists or an existing child isn't accessible this method returns false.
      Specified by:
      hasChild in interface Tree
      Parameters:
      name - The name of the child
      Returns:
      true if and only if a child with the given name exists and is accessible for the current content session.
    • getChildrenCount

      public long getChildrenCount(long max)
      Description copied from interface: Tree
      Determine the number of children of this Tree 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 interface Tree
      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 this Tree instance. The returned Iterable has snapshot semantics. That is, it reflect the state of this Tree 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 interface Tree
      Returns:
      An Iterable for all accessible children