org.apache.jackrabbit.oak.jcr.delegate
Class NodeDelegate

java.lang.Object
  extended by org.apache.jackrabbit.oak.jcr.delegate.ItemDelegate
      extended by org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate
Direct Known Subclasses:
VersionDelegate, VersionHistoryDelegate

public class NodeDelegate
extends ItemDelegate

NodeDelegate serve as internal representations of Nodes. 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.


Field Summary
 
Fields inherited from class org.apache.jackrabbit.oak.jcr.delegate.ItemDelegate
sessionDelegate
 
Constructor Summary
NodeDelegate(SessionDelegate sessionDelegate, org.apache.jackrabbit.oak.api.Tree tree)
           
 
Method Summary
 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)
           
 
Methods inherited from class org.apache.jackrabbit.oak.jcr.delegate.ItemDelegate
checkAlive, checkUpdate, save, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeDelegate

public NodeDelegate(SessionDelegate sessionDelegate,
                    org.apache.jackrabbit.oak.api.Tree tree)
Method Detail

getName

@Nonnull
public String getName()
Description copied from class: ItemDelegate
Get the name of this item

Specified by:
getName in class ItemDelegate
Returns:
oak name of this item

getPath

@Nonnull
public String getPath()
Description copied from class: ItemDelegate
Get the path of this item

Specified by:
getPath in class ItemDelegate
Returns:
oak path of this item

getParent

@CheckForNull
public NodeDelegate getParent()
Description copied from class: ItemDelegate
Get the parent of this item or null.

Specified by:
getParent in class ItemDelegate
Returns:
parent of this item or null for root or if the parent is not accessible.

exists

public boolean exists()
Description copied from class: ItemDelegate
Determine whether the underlying item exists

Specified by:
exists in class ItemDelegate
Returns:
true the underlying tree exists, false otherwise.

getStatus

@CheckForNull
public org.apache.jackrabbit.oak.api.Tree.Status getStatus()
Description copied from class: ItemDelegate
Get the status of this item.

Specified by:
getStatus in class ItemDelegate
Returns:
Tree.Status of this item or null if not available.

getIdentifier

@Nonnull
public String getIdentifier()
                     throws javax.jcr.InvalidItemStateException
Throws:
javax.jcr.InvalidItemStateException

isProtected

public boolean isProtected()
                    throws javax.jcr.InvalidItemStateException
Specified by:
isProtected in class ItemDelegate
Throws:
javax.jcr.InvalidItemStateException

isRoot

public boolean isRoot()
               throws javax.jcr.InvalidItemStateException
Determine whether this is the root node

Returns:
true iff this is the root node
Throws:
javax.jcr.InvalidItemStateException

getPropertyCount

public long getPropertyCount()
                      throws javax.jcr.InvalidItemStateException
Get the number of properties of the node

Returns:
number of properties of the node
Throws:
javax.jcr.InvalidItemStateException

getPropertyOrNull

@CheckForNull
public PropertyDelegate getPropertyOrNull(String relPath)
                                   throws javax.jcr.RepositoryException
Get a property

Parameters:
relPath - oak path
Returns:
property at the path given by relPath or null if no such property exists
Throws:
javax.jcr.RepositoryException

getProperty

@Nonnull
public PropertyDelegate getProperty(String relPath)
                             throws javax.jcr.RepositoryException
Get a property. In contrast to 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.

Parameters:
relPath - oak path
Returns:
property at the path given by relPath.
Throws:
javax.jcr.RepositoryException

getProperties

@Nonnull
public Iterator<PropertyDelegate> getProperties()
                                         throws javax.jcr.InvalidItemStateException
Get the properties of the node

Returns:
properties of the node
Throws:
javax.jcr.InvalidItemStateException

getChildCount

public long getChildCount(long max)
                   throws javax.jcr.InvalidItemStateException
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). 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).

Parameters:
max - the maximum value
Returns:
number of child nodes of the node
Throws:
javax.jcr.InvalidItemStateException

getChild

@CheckForNull
public NodeDelegate getChild(String relPath)
                      throws javax.jcr.RepositoryException
Get child node

Parameters:
relPath - oak path
Returns:
node at the path given by relPath or null if no such node exists
Throws:
javax.jcr.RepositoryException

getChildren

@Nonnull
public Iterator<NodeDelegate> getChildren()
                                   throws javax.jcr.InvalidItemStateException
Returns an iterator for traversing all the children of this node. If the node is orderable then the iterator will return child nodes in the specified order. Otherwise the ordering of the iterator is undefined.

Returns:
child nodes of the node
Throws:
javax.jcr.InvalidItemStateException

orderBefore

public void orderBefore(String source,
                        String target)
                 throws javax.jcr.ItemNotFoundException,
                        javax.jcr.InvalidItemStateException
Throws:
javax.jcr.ItemNotFoundException
javax.jcr.InvalidItemStateException

canAddMixin

public boolean canAddMixin(String typeName)
                    throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

addMixin

public void addMixin(String typeName)
              throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

removeMixin

public void removeMixin(String typeName)
                 throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

setMixins

public void setMixins(Set<String> mixinNames)
               throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

updateMixins

public void updateMixins(Set<String> addMixinNames,
                         Set<String> removedOakMixinNames)
                  throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

setProperty

@Nonnull
public PropertyDelegate setProperty(org.apache.jackrabbit.oak.api.PropertyState propertyState,
                                            boolean exactTypeMatch,
                                            boolean setProtected)
                             throws javax.jcr.RepositoryException
Set a property

Returns:
the set property
Throws:
javax.jcr.RepositoryException

addChild

@CheckForNull
public NodeDelegate addChild(String name,
                                          String typeName)
                      throws javax.jcr.RepositoryException
Add a child node

Parameters:
name - Oak name of the new child node
typeName - Oak name of the type of the new child node, or null if a default type should be used
Returns:
the added node or null if such a node already exists
Throws:
javax.jcr.RepositoryException

remove

public boolean remove()
               throws javax.jcr.InvalidItemStateException
Remove this node. This operation never succeeds for the root node.

Specified by:
remove in class ItemDelegate
Returns:
true if the node was removed; false otherwise.
Throws:
javax.jcr.InvalidItemStateException

setOrderableChildren

public void setOrderableChildren(boolean enable)
                          throws javax.jcr.InvalidItemStateException
Enables or disabled orderable children on the underlying tree.

Parameters:
enable - whether to enable or disable orderable children.
Throws:
javax.jcr.InvalidItemStateException

isLocked

public boolean isLocked()
Checks whether this node is locked, either directly or through a deep lock on an ancestor.

Returns:
whether this node is locked

getLock

public NodeDelegate getLock()

holdsLock

public boolean holdsLock(boolean deep)
Checks whether this node holds a lock.

Parameters:
deep - if true, only check for deep locks
Returns:
whether this node holds a lock

getLockOwner

public String getLockOwner()

isLockOwner

public boolean isLockOwner(String user)

lock

public void lock(boolean isDeep)
          throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

unlock

public void unlock()
            throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

toString

public String toString()
Overrides:
toString in class Object

getTree

@Nonnull
public org.apache.jackrabbit.oak.api.Tree getTree()
                                           throws javax.jcr.InvalidItemStateException
Throws:
javax.jcr.InvalidItemStateException


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.