Class TreeLocation
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.tree.TreeLocation
-
public abstract class TreeLocation extends Object
ATreeLocation
denotes a location inside a tree.It can either refer to a inner node (that is a
Tree
), to a leaf (that is aPropertyState
) 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 newTreeLocation
instances. Navigation never fails. Errors are deferred until the underlying item itself is accessed. That is, if aTreeLocation
points to an item which does not exist or is unavailable otherwise (i.e. due to access control restrictions) accessing the tree will returnnull
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 Root root)
Equivalent tocreate(root, "/")
static @NotNull TreeLocation
create(@NotNull Root root, @NotNull String path)
Create a newTreeLocation
instance for the item at the givenpath
inroot
.static @NotNull TreeLocation
create(@NotNull Tree tree)
Create a newTreeLocation
instance for atree
abstract boolean
exists()
@NotNull TreeLocation
getChild(String name)
Navigate to a child of the givenname
.abstract @NotNull String
getName()
The name of this locationabstract @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 PropertyState
getProperty()
Get the underlyingPropertyState
for thisTreeLocation
.@Nullable Tree
getTree()
Get the underlyingTree
for thisTreeLocation
.abstract boolean
remove()
Remove the underlying item.String
toString()
-
-
-
Method Detail
-
create
@NotNull public static @NotNull TreeLocation create(@NotNull @NotNull Tree tree)
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
@NotNull public static @NotNull TreeLocation create(@NotNull @NotNull Root root)
Equivalent tocreate(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()
- 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 givenname
.- Parameters:
name
- name of the child- Returns:
- this default implementation return a non existing location
-
getTree
@Nullable public @Nullable Tree getTree()
Get the underlyingTree
for thisTreeLocation
.- Returns:
- this default implementation return
null
.
-
getProperty
@Nullable public @Nullable PropertyState getProperty()
Get the underlyingPropertyState
for thisTreeLocation
.- Returns:
- this default implementation return
null
.
-
-