public abstract class TreeLocation extends Object
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 and Description |
|---|
TreeLocation() |
| Modifier and Type | Method and Description |
|---|---|
static TreeLocation |
create(org.apache.jackrabbit.oak.api.Root root)
Equivalent to
create(root, "/") |
static TreeLocation |
create(org.apache.jackrabbit.oak.api.Root root,
String path)
Create a new
TreeLocation instance for the item
at the given path in root. |
static TreeLocation |
create(@NotNull org.apache.jackrabbit.oak.api.Tree tree)
Create a new
TreeLocation instance for a tree |
abstract boolean |
exists()
|
@NotNull TreeLocation |
getChild(String name)
Navigate to a child of the given
name. |
abstract @NotNull 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 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.
|
String |
toString() |
public static TreeLocation create(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree)
TreeLocation instance for a treepublic static TreeLocation create(org.apache.jackrabbit.oak.api.Root root, String path)
TreeLocation instance for the item
at the given path in root.public static TreeLocation create(org.apache.jackrabbit.oak.api.Root root)
create(root, "/")@NotNull public abstract @NotNull TreeLocation getParent()
TreeLocation for the parent of this location.public abstract boolean exists()
true if the underlying item is available and has not been disconnected.Tree.exists()@NotNull public abstract @NotNull String getName()
@NotNull public abstract @NotNull String getPath()
public abstract boolean remove()
true if the item was removed, false otherwise.@NotNull public @NotNull TreeLocation getChild(String name)
name.name - name of the child@Nullable public @Nullable org.apache.jackrabbit.oak.api.Tree getTree()
Tree for this TreeLocation.null.@Nullable public @Nullable org.apache.jackrabbit.oak.api.PropertyState getProperty()
PropertyState for this TreeLocation.null.Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.