public interface Tree
ContentRepository
tree at the time the instance was acquired from a ContentSession
.
Tree instances may become invalid over time due to garbage collection of
old content, at which point an outdated snapshot will start throwing
IllegalStateException
s to indicate that the snapshot is no
longer available.
Tree
are generally unordered. That is, the
sequence of the children returned by getChildren()
may change over
time as this Tree
is modified either directly or through some other
session. Calling orderBefore(String)
will persist the current order
and maintain the order as new children are added or removed. In this case a
new child will be inserted after the last child as seen by getChildren()
.
NodeState
interface. However, since instances of this class are mutable return
values may change between invocations.
All tree instances created in the context of a content session become invalid
after the content session is closed. Any method called on an invalid tree instance
will throw an InvalidStateException
.
Tree
instances may become non existing after a call to
Root.refresh()
, Root.rebase()
or Root.commit()
.
Any write access to non existing Tree
instances will cause an
InvalidStateException
.
ContentSession
instance from which
the containing Root
was obtained.
The getChild(String)
method is special in that it never
returns a null
value, even if the named tree does not exist.
Instead a client should use the exists()
method on the returned
tree to check whether that tree exists.
The iterability of a tree is a related to existence. A node
state is iterable if it is included in the return values of the
getChildrenCount(long)
and getChildren()
methods. An iterable
node is guaranteed to exist, though not all existing nodes are necessarily
iterable.
Furthermore, a non-existing node is guaranteed to contain no properties or iterable child nodes. It can, however contain non-iterable children. Such scenarios are typically the result of access control restrictions.
Modifier and Type | Interface and Description |
---|---|
static class |
Tree.Status
Status of an item in a
Tree |
Modifier and Type | Field and Description |
---|---|
static Tree[] |
EMPTY_ARRAY
Empty array of trees.
|
Modifier and Type | Method and Description |
---|---|
@NotNull Tree |
addChild(@NotNull java.lang.String name)
Add a child with the given
name . |
boolean |
exists()
Determine whether this tree has been removed or does not exist otherwise (e.g.
|
@NotNull Tree |
getChild(@NotNull java.lang.String name)
Get a possibly non existing child of this
Tree . |
@NotNull java.lang.Iterable<Tree> |
getChildren()
All accessible children of this
Tree instance. |
long |
getChildrenCount(long max)
Determine the number of children of this
Tree instance taking
access restrictions into account. |
@NotNull java.lang.String |
getName() |
@NotNull Tree |
getParent() |
@NotNull java.lang.String |
getPath() |
@NotNull java.lang.Iterable<? extends PropertyState> |
getProperties()
All accessible property states.
|
@Nullable PropertyState |
getProperty(@NotNull java.lang.String name)
Get a property state
|
long |
getPropertyCount()
Determine the number of properties accessible to the current content session.
|
@Nullable Tree.Status |
getPropertyStatus(@NotNull java.lang.String name)
Get the
Status of a property state or null . |
@NotNull Tree.Status |
getStatus()
Get the
Status of this tree instance. |
boolean |
hasChild(@NotNull java.lang.String name)
Determine if a child of this
Tree instance exists. |
boolean |
hasProperty(@NotNull java.lang.String name)
Determine if a property state exists and is accessible.
|
boolean |
isRoot() |
boolean |
orderBefore(@Nullable java.lang.String name)
Orders this
Tree before the sibling tree with the given
name . |
boolean |
remove()
Remove this tree instance.
|
void |
removeProperty(@NotNull java.lang.String name)
Remove the property with the given name.
|
void |
setOrderableChildren(boolean enable)
Changes the nature of this tree such that the order of the children
is kept stable.
|
void |
setProperty(@NotNull PropertyState property)
Set a property state
|
<T> void |
setProperty(@NotNull java.lang.String name,
T value)
Set a property state
|
<T> void |
setProperty(@NotNull java.lang.String name,
T value,
@NotNull Type<T> type)
Set a property state
|
static final Tree[] EMPTY_ARRAY
@NotNull @NotNull java.lang.String getName()
Tree
instance.boolean isRoot()
true
iff this is the root@NotNull @NotNull java.lang.String getPath()
Tree
instance from its Root
.@NotNull @NotNull Tree.Status getStatus()
Status
of this tree instance.boolean exists()
true
if this tree exists, false
otherwise.@NotNull @NotNull Tree getParent()
Tree
.java.lang.IllegalStateException
- if called on the root tree.@Nullable @Nullable PropertyState getProperty(@NotNull @NotNull java.lang.String name)
name
- The name of the property state.name
or null
if no such property state exists or the property is not accessible.@Nullable @Nullable Tree.Status getPropertyStatus(@NotNull @NotNull java.lang.String name)
Status
of a property state or null
.name
- The name of the property state.name
or null
in no such property state exists or if the name refers
to a property that is not accessible.boolean hasProperty(@NotNull @NotNull java.lang.String name)
name
- The name of the property statetrue
if and only if a property with the given name
exists and is accessible.long getPropertyCount()
@NotNull @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
Iterable
has snapshot
semantics. That is, it reflect the state of this Tree
instance at
the time of the call. Later changes to this instance are no visible to
iterators obtained from the returned iterable.Iterable
for all accessible property states.@NotNull @NotNull Tree getChild(@NotNull @NotNull java.lang.String name) throws java.lang.IllegalArgumentException
Tree
.name
- The name of the child to retrieve.name
.java.lang.IllegalArgumentException
- if the given name is invalidboolean hasChild(@NotNull @NotNull java.lang.String name)
Tree
instance exists. If no child
exists or an existing child isn't accessible this method returns false
.name
- The name of the childtrue
if and only if a child with the given name
exists and is accessible for the current content session.long getChildrenCount(long max)
Tree
instance taking
access restrictions into account.
If an implementation does know the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).
max
- the maximum value@NotNull @NotNull java.lang.Iterable<Tree> getChildren()
Tree
instance. The returned
Iterable
has snapshot semantics. That is, it reflect the state of
this Tree
instance at the time of the call. Later changes to this
instance are not visible to iterators obtained from the returned iterable.Iterable
for all accessible childrenboolean remove()
true
if the node was removed; false
otherwise.@NotNull @NotNull Tree addChild(@NotNull @NotNull java.lang.String name) throws java.lang.IllegalArgumentException
name
. Does nothing if such a child
already exists.name
- name of the child. A valid name does not start with a colon,
is not empty and does not contain a forward slash.Tree
instance of the child with the given name
.java.lang.IllegalArgumentException
- if name
is not valid.void setOrderableChildren(boolean enable)
setOrderableChildren(true)
on a tree
the first time will stabilize the order of existing children. Any
subsequent addChild(String)
call is guaranteed to insert
the new tree and the end of the child list.setOrderableChildren(true)
on a tree
that already has its children ordered has no effect.setOrderableChildren(false)
on a tree that
doesn't have ordered children has not effectsetOrderableChildren(false)
on a tree
with ordered children will remove the necessity to keep the child
list stable. The order of children upon getChildren()
is
subsequently undefined.
Calling orderBefore(String)
on a tree, implicitly enables
orderable children on the parent tree.
enable
- Enable (or disable) orderable children for this tree.boolean orderBefore(@Nullable @Nullable java.lang.String name)
Tree
before the sibling tree with the given
name
. Calling this method for the first time on this
Tree
or any of its siblings will persist the current order
of siblings and maintain it from this point on.name
- the name of the sibling node where this tree is ordered
before. This tree will become the last sibling if
name
is null
.false
if there is no sibling with the given
name
or no reordering was performed;
true
otherwise.java.lang.IllegalArgumentException
- if the given name is invalidvoid setProperty(@NotNull @NotNull PropertyState property)
property
- The property state to setjava.lang.IllegalArgumentException
- if property
has a non valid name. A valid name
does not start with a colon, is not empty and does not contain a forward slash.<T> void setProperty(@NotNull @NotNull java.lang.String name, @NotNull T value) throws java.lang.IllegalArgumentException
T
- The type of this property. Must be one of String, Blob, byte[], Long, Integer, Double, Boolean, BigDecimal
name
- The name of this property. A valid name does not start with a colon,
is not empty and does not contain a forward slash.value
- The value of this propertyjava.lang.IllegalArgumentException
- if T
is not one of the above types or
if name
is not valid.<T> void setProperty(@NotNull @NotNull java.lang.String name, @NotNull T value, @NotNull @NotNull Type<T> type) throws java.lang.IllegalArgumentException
T
- The type of this property.name
- The name of this property. A valid name does not start with a colon,
is not empty and does not contain a forward slash.value
- The value of this propertytype
- The type of this property.java.lang.IllegalArgumentException
- if name
is not valid.void removeProperty(@NotNull @NotNull java.lang.String name)
name
does not exist.name
- The name of the propertyCopyright © 2010 - 2020 Adobe. All Rights Reserved