public class NodeDelegate extends ItemDelegate
NodeDelegate
serve as internal representations of Node
s.
Most methods of this class throw an InvalidItemStateException
exception if the instance is stale. An instance is stale if the underlying
items does not exist anymore.sessionDelegate
Constructor and Description |
---|
NodeDelegate(SessionDelegate sessionDelegate,
org.apache.jackrabbit.oak.api.Tree tree) |
Modifier and Type | Method and Description |
---|---|
NodeDelegate |
addChild(String name,
String typeName)
Add a child node
|
void |
addMixin(String typeName) |
boolean |
canAddMixin(String typeName) |
boolean |
exists()
Determine whether the underlying item exists
|
NodeDelegate |
getChild(String relPath)
Get child node
|
long |
getChildCount(long max)
Get the number of child nodes
If an implementation does know the exact value, it returns it (even if
the value is higher than max).
|
Iterator<NodeDelegate> |
getChildren()
Returns an iterator for traversing all the children of this node.
|
String |
getIdentifier() |
NodeDelegate |
getLock() |
String |
getLockOwner() |
String |
getName()
Get the name of this item
|
NodeDelegate |
getParent()
Get the parent of this item or
null . |
String |
getPath()
Get the path of this item
|
Iterator<PropertyDelegate> |
getProperties()
Get the properties of the node
|
PropertyDelegate |
getProperty(String relPath)
Get a property.
|
long |
getPropertyCount()
Get the number of properties of the node
|
PropertyDelegate |
getPropertyOrNull(String relPath)
Get a property
|
org.apache.jackrabbit.oak.api.Tree.Status |
getStatus()
Get the status of this item.
|
org.apache.jackrabbit.oak.api.Tree |
getTree() |
boolean |
holdsLock(boolean deep)
Checks whether this node holds a lock.
|
boolean |
isLocked()
Checks whether this node is locked, either directly or through
a deep lock on an ancestor.
|
boolean |
isLockOwner(String user) |
boolean |
isProtected() |
boolean |
isRoot()
Determine whether this is the root node
|
void |
lock(boolean isDeep) |
void |
orderBefore(String source,
String target) |
boolean |
remove()
Remove this node.
|
void |
removeMixin(String typeName) |
void |
setMixins(Set<String> mixinNames) |
void |
setOrderableChildren(boolean enable)
Enables or disabled orderable children on the underlying tree.
|
PropertyDelegate |
setProperty(org.apache.jackrabbit.oak.api.PropertyState propertyState,
boolean exactTypeMatch,
boolean setProtected)
Set a property
|
String |
toString() |
void |
unlock() |
void |
updateMixins(Set<String> addMixinNames,
Set<String> removedOakMixinNames) |
checkAlive, checkUpdate, save, update
public NodeDelegate(SessionDelegate sessionDelegate, org.apache.jackrabbit.oak.api.Tree tree)
@Nonnull public String getName()
ItemDelegate
getName
in class ItemDelegate
@Nonnull public String getPath()
ItemDelegate
getPath
in class ItemDelegate
@CheckForNull public NodeDelegate getParent()
ItemDelegate
null
.getParent
in class ItemDelegate
null
for root or if the parent
is not accessible.public boolean exists()
ItemDelegate
exists
in class ItemDelegate
true
the underlying tree exists, false
otherwise.@CheckForNull public org.apache.jackrabbit.oak.api.Tree.Status getStatus()
ItemDelegate
getStatus
in class ItemDelegate
Tree.Status
of this item or null
if not available.@Nonnull public String getIdentifier() throws javax.jcr.InvalidItemStateException
javax.jcr.InvalidItemStateException
public boolean isProtected() throws javax.jcr.InvalidItemStateException
isProtected
in class ItemDelegate
javax.jcr.InvalidItemStateException
public boolean isRoot() throws javax.jcr.InvalidItemStateException
true
iff this is the root nodejavax.jcr.InvalidItemStateException
public long getPropertyCount() throws javax.jcr.InvalidItemStateException
javax.jcr.InvalidItemStateException
@CheckForNull public PropertyDelegate getPropertyOrNull(String relPath) throws javax.jcr.RepositoryException
relPath
- oak pathrelPath
or null
if
no such property existsjavax.jcr.RepositoryException
@Nonnull public PropertyDelegate getProperty(String relPath) throws javax.jcr.RepositoryException
getPropertyOrNull(String)
this
method never returns null
. In the case where no property exists
at the given path, the returned property delegate throws an
InvalidItemStateException
on access. See See OAK-395.relPath
- oak pathrelPath
.javax.jcr.RepositoryException
@Nonnull public Iterator<PropertyDelegate> getProperties() throws javax.jcr.InvalidItemStateException
javax.jcr.InvalidItemStateException
public long getChildCount(long max) throws javax.jcr.InvalidItemStateException
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 valuejavax.jcr.InvalidItemStateException
@CheckForNull public NodeDelegate getChild(String relPath) throws javax.jcr.RepositoryException
relPath
- oak pathrelPath
or null
if
no such node existsjavax.jcr.RepositoryException
@Nonnull public Iterator<NodeDelegate> getChildren() throws javax.jcr.InvalidItemStateException
javax.jcr.InvalidItemStateException
public void orderBefore(String source, String target) throws javax.jcr.ItemNotFoundException, javax.jcr.InvalidItemStateException
javax.jcr.ItemNotFoundException
javax.jcr.InvalidItemStateException
public boolean canAddMixin(String typeName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void addMixin(String typeName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void removeMixin(String typeName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void setMixins(Set<String> mixinNames) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void updateMixins(Set<String> addMixinNames, Set<String> removedOakMixinNames) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
@Nonnull public PropertyDelegate setProperty(org.apache.jackrabbit.oak.api.PropertyState propertyState, boolean exactTypeMatch, boolean setProtected) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
@CheckForNull public NodeDelegate addChild(String name, String typeName) throws javax.jcr.RepositoryException
name
- Oak name of the new child nodetypeName
- Oak name of the type of the new child node,
or null
if a default type should be usednull
if such a node already existsjavax.jcr.RepositoryException
public boolean remove() throws javax.jcr.InvalidItemStateException
remove
in class ItemDelegate
true
if the node was removed; false
otherwise.javax.jcr.InvalidItemStateException
public void setOrderableChildren(boolean enable) throws javax.jcr.InvalidItemStateException
enable
- whether to enable or disable orderable children.javax.jcr.InvalidItemStateException
public boolean isLocked()
public NodeDelegate getLock()
public boolean holdsLock(boolean deep)
deep
- if true
, only check for deep lockspublic String getLockOwner()
public boolean isLockOwner(String user)
public void lock(boolean isDeep) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void unlock() throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
@Nonnull public org.apache.jackrabbit.oak.api.Tree getTree() throws javax.jcr.InvalidItemStateException
javax.jcr.InvalidItemStateException
Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.