Class TreeLocation

java.lang.Object
org.apache.jackrabbit.oak.plugins.tree.TreeLocation

public abstract class TreeLocation extends Object
A TreeLocation denotes a location inside a tree.

It can either refer to a inner node (that is a Tree), to a leaf (that is a PropertyState) or to an invalid location which refers to neither of the former. TreeLocation instances provide methods for navigating trees such that navigation always results in new TreeLocation instances. Navigation never fails. Errors are deferred until the underlying item itself is accessed. That is, if a TreeLocation points to an item which does not exist or is unavailable otherwise (i.e. due to access control restrictions) accessing the tree will return null at this point.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull TreeLocation
    create(@NotNull org.apache.jackrabbit.oak.api.Root root)
    Equivalent to create(root, "/")
    static @NotNull TreeLocation
    create(@NotNull org.apache.jackrabbit.oak.api.Root root, @NotNull String path)
    Create a new TreeLocation instance for the item at the given path in root.
    static @NotNull TreeLocation
    create(@NotNull org.apache.jackrabbit.oak.api.Tree tree)
    Create a new TreeLocation instance for a tree
    abstract boolean
    Determine whether the underlying Tree or PropertyState for this TreeLocation is available.
    @NotNull TreeLocation
    Navigate to a child of the given name.
    abstract @NotNull String
    The name of this location
    abstract @NotNull TreeLocation
    Navigate to the parent or an invalid location for the root of the hierarchy.
    abstract @NotNull String
    The path of this location
    @Nullable org.apache.jackrabbit.oak.api.PropertyState
    Get the underlying PropertyState for this TreeLocation.
    @Nullable org.apache.jackrabbit.oak.api.Tree
    Get the underlying Tree for this TreeLocation.
    abstract boolean
    Remove the underlying item.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TreeLocation

      public TreeLocation()
  • Method Details

    • create

      @NotNull public static @NotNull TreeLocation create(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree)
      Create a new TreeLocation instance for a tree
    • create

      @NotNull public static @NotNull TreeLocation create(@NotNull @NotNull org.apache.jackrabbit.oak.api.Root root, @NotNull @NotNull String path)
      Create a new TreeLocation instance for the item at the given path in root.
    • create

      @NotNull public static @NotNull TreeLocation create(@NotNull @NotNull org.apache.jackrabbit.oak.api.Root root)
      Equivalent to create(root, "/")
    • getParent

      @NotNull public abstract @NotNull TreeLocation getParent()
      Navigate to the parent or an invalid location for the root of the hierarchy.
      Returns:
      a TreeLocation for the parent of this location.
    • exists

      public abstract boolean exists()
      Determine whether the underlying Tree or PropertyState for this TreeLocation is available.
      Returns:
      true if the underlying item is available and has not been disconnected.
      See Also:
      • Tree.exists()
    • getName

      @NotNull public abstract @NotNull String getName()
      The name of this location
      Returns:
      name
    • getPath

      @NotNull public abstract @NotNull String getPath()
      The path of this location
      Returns:
      path
    • remove

      public abstract boolean remove()
      Remove the underlying item.
      Returns:
      true if the item was removed, false otherwise.
    • getChild

      @NotNull public @NotNull TreeLocation getChild(String name)
      Navigate to a child of the given name.
      Parameters:
      name - name of the child
      Returns:
      this default implementation return a non existing location
    • getTree

      @Nullable public @Nullable org.apache.jackrabbit.oak.api.Tree getTree()
      Get the underlying Tree for this TreeLocation.
      Returns:
      this default implementation return null.
    • getProperty

      @Nullable public @Nullable org.apache.jackrabbit.oak.api.PropertyState getProperty()
      Get the underlying PropertyState for this TreeLocation.
      Returns:
      this default implementation return null.
    • toString

      public String toString()
      Overrides:
      toString in class Object