Class TreeLocation


  • public abstract class TreeLocation
    extends java.lang.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
      TreeLocation()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      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 java.lang.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 exists()
      Determine whether the underlying Tree or PropertyState for this TreeLocation is available.
      @NotNull TreeLocation getChild​(java.lang.String name)
      Navigate to a child of the given name.
      abstract @NotNull java.lang.String getName()
      The name of this location
      abstract @NotNull TreeLocation getParent()
      Navigate to the parent or an invalid location for the root of the hierarchy.
      abstract @NotNull java.lang.String getPath()
      The path of this location
      @Nullable org.apache.jackrabbit.oak.api.PropertyState getProperty()
      Get the underlying PropertyState for this TreeLocation.
      @Nullable org.apache.jackrabbit.oak.api.Tree getTree()
      Get the underlying Tree for this TreeLocation.
      abstract boolean remove()
      Remove the underlying item.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • TreeLocation

        public TreeLocation()
    • Method Detail

      • 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 java.lang.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 java.lang.String getName()
        The name of this location
        Returns:
        name
      • getPath

        @NotNull
        public abstract @NotNull java.lang.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​(java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object