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 Detail

      • TreeLocation

        public TreeLocation()
    • Method Detail

      • create

        @NotNull
        public static @NotNull TreeLocation create​(@NotNull
                                                   @NotNull Tree tree)
        Create a new TreeLocation instance for a tree
      • create

        @NotNull
        public static @NotNull TreeLocation create​(@NotNull
                                                   @NotNull 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 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 Tree getTree()
        Get the underlying Tree for this TreeLocation.
        Returns:
        this default implementation return null.
      • getProperty

        @Nullable
        public @Nullable 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