Class TreeLocation
java.lang.Object
org.apache.jackrabbit.oak.plugins.tree.TreeLocation
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull TreeLocation
Equivalent tocreate(root, "/")
static @NotNull TreeLocation
Create a newTreeLocation
instance for the item at the givenpath
inroot
.static @NotNull TreeLocation
Create a newTreeLocation
instance for atree
abstract boolean
exists()
@NotNull TreeLocation
Navigate to a child of the givenname
.abstract @NotNull String
getName()
The name of this locationabstract @NotNull TreeLocation
Navigate to the parent or an invalid location for the root of the hierarchy.abstract @NotNull String
getPath()
The path of this location@Nullable PropertyState
Get the underlyingPropertyState
for thisTreeLocation
.@Nullable Tree
getTree()
Get the underlyingTree
for thisTreeLocation
.abstract boolean
remove()
Remove the underlying item.toString()
-
Constructor Details
-
TreeLocation
public TreeLocation()
-
-
Method Details
-
create
Create a newTreeLocation
instance for atree
-
create
@NotNull public static @NotNull TreeLocation create(@NotNull @NotNull Root root, @NotNull @NotNull String path) Create a newTreeLocation
instance for the item at the givenpath
inroot
. -
create
Equivalent tocreate(root, "/")
-
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()- Returns:
true
if the underlying item is available and has not been disconnected.- See Also:
-
getName
The name of this location- Returns:
- name
-
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
Navigate to a child of the givenname
.- Parameters:
name
- name of the child- Returns:
- this default implementation return a non existing location
-
getTree
Get the underlyingTree
for thisTreeLocation
.- Returns:
- this default implementation return
null
.
-
getProperty
Get the underlyingPropertyState
for thisTreeLocation
.- Returns:
- this default implementation return
null
.
-
toString
-