ModeShape Distribution 3.0.0.Beta4

org.modeshape.jcr.cache.document
Class SessionNode

java.lang.Object
  extended by org.modeshape.jcr.cache.document.SessionNode
All Implemented Interfaces:
CachedNode, MutableCachedNode

@ThreadSafe
public class SessionNode
extends Object
implements MutableCachedNode

A node used within a session when that node has (or may have) transient (unsaved) changes. This node is an extension of a CachedNode, and thus can be used as a regular cached node. All transient changes are captured as a delta on top of the underlying workspace node, and so any changes to the workspace node (made by other sessions' save operations) are immediately reflected.


Nested Class Summary
protected static class SessionNode.ChangedAdditionalParents
           
protected static class SessionNode.ChangedChildren
          The representation of the changes made to the child references of this node.
protected  class SessionNode.DeepClone
           
protected  class SessionNode.DeepCopy
           
protected static class SessionNode.InsertedChildReferences
           
protected static class SessionNode.Insertions
           
static class SessionNode.LockChange
           
protected static class SessionNode.MixinChanges
           
protected static class SessionNode.ReferrerChanges
           
 
Nested classes/interfaces inherited from interface org.modeshape.jcr.cache.CachedNode
CachedNode.ReferenceType
 
Constructor Summary
SessionNode(NodeKey key, boolean isNew)
           
 
Method Summary
protected  SessionNode.ChangedAdditionalParents additionalParents()
           
 void addMixin(SessionCache cache, Name mixinName)
          Add the supplied mixin type if not already an explicitly referenced.
protected  void addOrRemoveReferrers(SessionCache cache, Property property, boolean add)
           
 void addReferrer(SessionCache cache, NodeKey referrerKey, CachedNode.ReferenceType type)
          Adds to this node a reference with the given type from the node with the supplied key to this node.
protected  MutableChildReferences appended(boolean createIfMissing)
           
protected  SessionNode.ChangedChildren changedChildren()
           
protected  ConcurrentMap<Name,Property> changedProperties()
           
 MutableCachedNode createChild(SessionCache cache, NodeKey key, Name name, Iterable<Property> properties)
          Create a new node as a child of this node with the supplied name and properties.
 MutableCachedNode createChild(SessionCache cache, NodeKey key, Name name, Property firstProperty, Property... additionalProperties)
          Create a new node as a child of this node with the supplied name and properties.
 void deepClone(SessionCache cache, CachedNode sourceNode, SessionCache sourceCache)
          Clones into this node all the properties and children (deep clone) from the given source node.
 Map<NodeKey,NodeKey> deepCopy(SessionCache cache, CachedNode sourceNode, SessionCache sourceCache)
          Copies into this node all the properties and children (deep copy) from the given source node.
 boolean equals(Object obj)
           
 Set<Name> getAddedMixins(SessionCache cache)
          Get the set of mixin names that were added to this node but not yet saved.
 Set<NodeKey> getAdditionalParentKeys(NodeCache cache)
          Get the keys for all of the nodes (other than the primary parent) under which this node appears.
 Set<NodeKey> getChangedReferrerNodes()
          Returns a set with all the referencing nodes (nodes which are referring this node) which have changed.
 ChildReferences getChildReferences(NodeCache cache)
          Get the set of child references for this node.
 String getEtag(SessionCache cache)
          Compute an ETag value for this node.
 NodeKey getKey()
          Get the key for the node.
 SessionNode.LockChange getLockChange()
           
 SessionNode.MixinChanges getMixinChanges()
           
 Set<Name> getMixinTypes(NodeCache cache)
          Get the set of mixin types for this node.
 Name getName(NodeCache cache)
          Get the name for this node, without any same-name-sibiling (SNS) index.
 NodeKey getParentKey(NodeCache cache)
          Get the node key for this node's primary parent within this workspace.
 NodeKey getParentKeyInAnyWorkspace(NodeCache cache)
          Get the node key for this node's primary parent in any workspace.
 Path getPath(NodeCache cache)
          Get the path to this node.
 Path getPath(PathCache pathCache)
          Get the path to this node.
 Name getPrimaryType(NodeCache cache)
          Get the primary type for this node.
 Iterator<Property> getProperties(Collection<?> namePatterns, NodeCache cache)
          Get an iterator over all of the properties of this node that have names matching at least one of the supplied patterns.
 Iterator<Property> getProperties(NodeCache cache)
          Get an iterator over all of the node's properties.
 Property getProperty(Name name, NodeCache cache)
          Get the property with the given name.
 int getPropertyCount(NodeCache cache)
          Determine the number of properties that this node contains.
protected  SessionNode.ReferrerChanges getReferrerChanges()
           
 Set<NodeKey> getReferrers(NodeCache cache, CachedNode.ReferenceType type)
          Get the keys of the nodes that have JCR REFERENCE and/or WEAK_REFERENCE properties pointing to this node.
 Path.Segment getSegment(NodeCache cache)
          Get the path segment for this node.
protected  Path.Segment getSegment(NodeCache cache, CachedNode parent)
          Get the segment for this node.
 String getString(NamespaceRegistry registry)
           
 boolean hasChangedPrimaryType()
          Return whether the primary type for the node has changed.
 boolean hasChanges()
          Return whether this node has changes.
 int hashCode()
           
 boolean hasOnlyChangesToAdditionalParents()
          Return whether this node contains only changes to the additional parents.
 boolean hasProperties(NodeCache cache)
          Determine if the node contains one or more properties.
 boolean hasProperty(Name name, NodeCache cache)
          Determine if the node contains a property with the specified name.
 boolean isAtOrBelow(NodeCache cache, Path path)
          Determine if this node is effectively at or below the supplied path.
 boolean isNew()
          Return whether this node was created since last saved.
 boolean isPropertyModified(SessionCache cache, Name propertyName)
          Return whether the property with the supplied name was modified since the session was last saved.
 boolean isPropertyNew(SessionCache cache, Name propertyName)
          Return whether the property with the supplied name was created since the session was last saved.
protected  boolean isPropertyRemoved(Name name)
           
 boolean linkChild(SessionCache cache, NodeKey childKey, Name name)
          Link the existing node with the supplied key to be appended as a child of this node.
 void lock(boolean sessionScoped)
          Lock this node.
protected  SessionNode.MixinChanges mixinChanges(boolean createIfMissing)
           
 void moveChild(SessionCache cache, NodeKey key, MutableCachedNode newParent, Name newName)
          Remove the node from being a child of this node and append it as a child of the supplied node.
protected  NodeKey newParent()
           
protected  CachedNode nodeInWorkspace(AbstractSessionCache session)
          Get the CachedNode within the workspace cache.
protected  CachedNode parent(AbstractSessionCache session)
           
protected  SessionNode.ReferrerChanges referrerChanges(boolean createIfMissing)
           
 void removeAllProperties(SessionCache cache)
          Remove all of the properties from this node.
protected  void removeAllReferences(SessionCache cache)
           
 void removeChild(SessionCache cache, NodeKey key)
          Remove the node from being a child of this node.
protected  SessionNode removeChildFromNode(AbstractSessionCache session, NodeKey key)
           
 Set<NodeKey> removedChildren()
          Returns a set with the keys of the children which have been removed for this node.
protected  Set<Name> removedProperties()
           
 void removeMixin(SessionCache cache, Name mixinName)
          Remove the supplied mixin type if already an explicitly referenced.
 void removeProperty(SessionCache cache, Name name)
          Remove the property with the given name.
 void removeReferrer(SessionCache cache, NodeKey referrerKey, CachedNode.ReferenceType type)
          Remove from this node a reference with the given type from the node with the supplied key to this node.
 void renameChild(SessionCache cache, NodeKey key, Name newName)
          Renames the child node.
 void reorderChild(SessionCache cache, NodeKey key, NodeKey nextNode)
          Remove the node from being a child of this node and append it as a child before the supplied node.
protected  AbstractSessionCache session(NodeCache cache)
           
 void setProperties(SessionCache cache, Iterable<Property> properties)
          Set the properties on this node.
 void setProperties(SessionCache cache, Iterator<Property> properties)
          Set the properties on this node.
 void setProperty(SessionCache cache, Property property)
          Set the property with the given name.
 void setPropertyIfUnchanged(SessionCache cache, Property property)
          Set the given property only if it has not been set previously and therefore appear as changed.
 String toString()
           
 void unlock()
          Unlock this node.
protected  WorkspaceCache workspace(NodeCache cache)
           
protected  WritableSessionCache writableSession(NodeCache cache)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionNode

public SessionNode(NodeKey key,
                   boolean isNew)
Method Detail

changedChildren

protected final SessionNode.ChangedChildren changedChildren()

removedProperties

protected final Set<Name> removedProperties()

changedProperties

protected final ConcurrentMap<Name,Property> changedProperties()

newParent

protected final NodeKey newParent()

isNew

public final boolean isNew()
Description copied from interface: MutableCachedNode
Return whether this node was created since last saved.

Specified by:
isNew in interface MutableCachedNode
Returns:
true if this node was created since the session was last saved, or false otherwise

isPropertyNew

public final boolean isPropertyNew(SessionCache cache,
                                   Name propertyName)
Description copied from interface: MutableCachedNode
Return whether the property with the supplied name was created since the session was last saved. This method will always return true if MutableCachedNode.isNew() returns true.

Specified by:
isPropertyNew in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
propertyName - the name of the property; may not be null
Returns:
true if this node contains a property that was created since the session was last saved, or false otherwise
See Also:
MutableCachedNode.isPropertyModified(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name), MutableCachedNode.isNew()

isPropertyModified

public final boolean isPropertyModified(SessionCache cache,
                                        Name propertyName)
Description copied from interface: MutableCachedNode
Return whether the property with the supplied name was modified since the session was last saved.

Specified by:
isPropertyModified in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
propertyName - the name of the property; may not be null
Returns:
true if this node contains a property that was created since the session was last saved, or false otherwise
See Also:
MutableCachedNode.isPropertyNew(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name)

hasChanges

public boolean hasChanges()
Description copied from interface: MutableCachedNode
Return whether this node has changes.

Specified by:
hasChanges in interface MutableCachedNode
Returns:
true if this node has changes, or false otherwise

lock

public void lock(boolean sessionScoped)
Description copied from interface: MutableCachedNode
Lock this node.

Specified by:
lock in interface MutableCachedNode
Parameters:
sessionScoped - true if the lock should be limited in scope to the lifetime of the session, or false otherwise

unlock

public void unlock()
Description copied from interface: MutableCachedNode
Unlock this node.

Specified by:
unlock in interface MutableCachedNode

getLockChange

public SessionNode.LockChange getLockChange()

appended

protected MutableChildReferences appended(boolean createIfMissing)

mixinChanges

protected SessionNode.MixinChanges mixinChanges(boolean createIfMissing)

referrerChanges

protected SessionNode.ReferrerChanges referrerChanges(boolean createIfMissing)

writableSession

protected final WritableSessionCache writableSession(NodeCache cache)

session

protected final AbstractSessionCache session(NodeCache cache)

workspace

protected final WorkspaceCache workspace(NodeCache cache)

nodeInWorkspace

protected CachedNode nodeInWorkspace(AbstractSessionCache session)
Get the CachedNode within the workspace cache.

Parameters:
session - the session; may not be null
Returns:
the workspace cache's node, or null if this node is new

getParentKey

public NodeKey getParentKey(NodeCache cache)
Description copied from interface: CachedNode
Get the node key for this node's primary parent within this workspace.

Specified by:
getParentKey in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the parent's key; null if this is the root node or it has been removed from the document by someone else

getParentKeyInAnyWorkspace

public NodeKey getParentKeyInAnyWorkspace(NodeCache cache)
Description copied from interface: CachedNode
Get the node key for this node's primary parent in any workspace.

Specified by:
getParentKeyInAnyWorkspace in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the parent's key; null if this is the root node or it has been removed from the document by someone else

parent

protected CachedNode parent(AbstractSessionCache session)

additionalParents

protected SessionNode.ChangedAdditionalParents additionalParents()

getAdditionalParentKeys

public Set<NodeKey> getAdditionalParentKeys(NodeCache cache)
Description copied from interface: CachedNode
Get the keys for all of the nodes (other than the primary parent) under which this node appears.

Specified by:
getAdditionalParentKeys in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the immutable set of keys to the additional parents, excluding the primary parent

hasOnlyChangesToAdditionalParents

public boolean hasOnlyChangesToAdditionalParents()
Description copied from interface: MutableCachedNode
Return whether this node contains only changes to the additional parents.

Specified by:
hasOnlyChangesToAdditionalParents in interface MutableCachedNode
Returns:
true if this node contains only added or removed additional parents.

isAtOrBelow

public boolean isAtOrBelow(NodeCache cache,
                           Path path)
Description copied from interface: CachedNode
Determine if this node is effectively at or below the supplied path. Note that because of additional parents, a node has multiple effective paths.

Specified by:
isAtOrBelow in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
path - the path to be used for comparison; may not be null
Returns:
true if this node can be considered at or below the supplied path; or false otherwise

getKey

public NodeKey getKey()
Description copied from interface: CachedNode
Get the key for the node.

Specified by:
getKey in interface CachedNode
Returns:
the node's key; never null

getName

public Name getName(NodeCache cache)
Description copied from interface: CachedNode
Get the name for this node, without any same-name-sibiling (SNS) index.

Specified by:
getName in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the name; never null, but the root node will have a zero-length name
See Also:
CachedNode.getSegment(NodeCache), CachedNode.getPath(NodeCache)

getSegment

public Path.Segment getSegment(NodeCache cache)
Description copied from interface: CachedNode
Get the path segment for this node. The segment consists of a name and a same-name-sibling (SNS) index.

Specified by:
getSegment in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the segment; never null, but the root node will have a zero-length name
See Also:
CachedNode.getName(NodeCache), CachedNode.getPath(NodeCache)

getSegment

protected final Path.Segment getSegment(NodeCache cache,
                                        CachedNode parent)
Get the segment for this node.

Parameters:
cache - the cache
parent - the parent node
Returns:
the segment
Throws:
NodeNotFoundInParentException - if the node doesn't exist in the referenced parent

getPath

public Path getPath(NodeCache cache)
Description copied from interface: CachedNode
Get the path to this node.

Specified by:
getPath in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the node's path; never null with at least one segment for all nodes except the root node
See Also:
CachedNode.getName(NodeCache), CachedNode.getSegment(NodeCache)

getPath

public Path getPath(PathCache pathCache)
             throws NodeNotFoundException
Description copied from interface: CachedNode
Get the path to this node.

Specified by:
getPath in interface CachedNode
Parameters:
pathCache - the cache of paths that can be used to compute the path for any node; may not be null
Returns:
the node's path; never null with at least one segment for all nodes except the root node
Throws:
NodeNotFoundInParentException - if this node no longer exists inside the parent node (and perhaps in no other parent)
NodeNotFoundException - if this node no longer exists
See Also:
CachedNode.getName(NodeCache), CachedNode.getSegment(NodeCache)

getPrimaryType

public Name getPrimaryType(NodeCache cache)
Description copied from interface: CachedNode
Get the primary type for this node.

Specified by:
getPrimaryType in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the primary type name; never null

hasChangedPrimaryType

public boolean hasChangedPrimaryType()
Description copied from interface: MutableCachedNode
Return whether the primary type for the node has changed.

Specified by:
hasChangedPrimaryType in interface MutableCachedNode
Returns:
true if the primary type for the node has changed, or false otherwise

getMixinTypes

public Set<Name> getMixinTypes(NodeCache cache)
Description copied from interface: CachedNode
Get the set of mixin types for this node.

Specified by:
getMixinTypes in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the immutable list of mixin type names; never null but possibly empty

addMixin

public void addMixin(SessionCache cache,
                     Name mixinName)
Description copied from interface: MutableCachedNode
Add the supplied mixin type if not already an explicitly referenced.

Specified by:
addMixin in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
mixinName - the name of the mixin to be removed; may not be null

removeMixin

public void removeMixin(SessionCache cache,
                        Name mixinName)
Description copied from interface: MutableCachedNode
Remove the supplied mixin type if already an explicitly referenced.

Specified by:
removeMixin in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
mixinName - the name of the mixin to be removed; may not be null

getMixinChanges

public SessionNode.MixinChanges getMixinChanges()

getAddedMixins

public Set<Name> getAddedMixins(SessionCache cache)
Description copied from interface: MutableCachedNode
Get the set of mixin names that were added to this node but not yet saved.

Specified by:
getAddedMixins in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
Returns:
the newly-added mixin type names; never null but possibly empty

getReferrers

public Set<NodeKey> getReferrers(NodeCache cache,
                                 CachedNode.ReferenceType type)
Description copied from interface: CachedNode
Get the keys of the nodes that have JCR REFERENCE and/or WEAK_REFERENCE properties pointing to this node.

Specified by:
getReferrers in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
type - the flag specifying whether nodes with REFERENCE properties and/or WEAK reference properties should be included in the result; may not be null
Returns:
the set of keys to the nodes that have a reference to this node; never null but possibly empty

getReferrerChanges

protected SessionNode.ReferrerChanges getReferrerChanges()

addReferrer

public void addReferrer(SessionCache cache,
                        NodeKey referrerKey,
                        CachedNode.ReferenceType type)
Description copied from interface: MutableCachedNode
Adds to this node a reference with the given type from the node with the supplied key to this node.

Specified by:
addReferrer in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
referrerKey - the key for the node that has a new reference to this node; may not be null
type - the reference type; may not be null

removeReferrer

public void removeReferrer(SessionCache cache,
                           NodeKey referrerKey,
                           CachedNode.ReferenceType type)
Description copied from interface: MutableCachedNode
Remove from this node a reference with the given type from the node with the supplied key to this node.

Specified by:
removeReferrer in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
referrerKey - the key for the node that no longer has a reference to this node; may not be null
type - the reference type; may not be null

getPropertyCount

public int getPropertyCount(NodeCache cache)
Description copied from interface: CachedNode
Determine the number of properties that this node contains.

Specified by:
getPropertyCount in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the number of properties; never negative

hasProperties

public boolean hasProperties(NodeCache cache)
Description copied from interface: CachedNode
Determine if the node contains one or more properties.

Specified by:
hasProperties in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
true if the node has at least one property, or false otherwise

hasProperty

public boolean hasProperty(Name name,
                           NodeCache cache)
Description copied from interface: CachedNode
Determine if the node contains a property with the specified name.

Specified by:
hasProperty in interface CachedNode
Parameters:
name - the name of the property
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
true if the node has the named property, or false otherwise

getProperty

public Property getProperty(Name name,
                            NodeCache cache)
Description copied from interface: CachedNode
Get the property with the given name.

Specified by:
getProperty in interface CachedNode
Parameters:
name - the name of the property
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the property, or null if the property does not exist on this node

isPropertyRemoved

protected final boolean isPropertyRemoved(Name name)

getProperties

public Iterator<Property> getProperties(NodeCache cache)
Description copied from interface: CachedNode
Get an iterator over all of the node's properties.

Specified by:
getProperties in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the property iterator; never null but possibly empty

getProperties

public Iterator<Property> getProperties(Collection<?> namePatterns,
                                        NodeCache cache)
Description copied from interface: CachedNode
Get an iterator over all of the properties of this node that have names matching at least one of the supplied patterns.

Specified by:
getProperties in interface CachedNode
Parameters:
namePatterns - the regex patterns or string literals describing the names
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the property iterator; never null but possibly empty

setProperty

public void setProperty(SessionCache cache,
                        Property property)
Description copied from interface: MutableCachedNode
Set the property with the given name.

Specified by:
setProperty in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
property - the property; may not be null

removeAllReferences

protected void removeAllReferences(SessionCache cache)

addOrRemoveReferrers

protected void addOrRemoveReferrers(SessionCache cache,
                                    Property property,
                                    boolean add)

setPropertyIfUnchanged

public void setPropertyIfUnchanged(SessionCache cache,
                                   Property property)
Description copied from interface: MutableCachedNode
Set the given property only if it has not been set previously and therefore appear as changed.

Specified by:
setPropertyIfUnchanged in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
property - the property; may not be null

setProperties

public void setProperties(SessionCache cache,
                          Iterable<Property> properties)
Description copied from interface: MutableCachedNode
Set the properties on this node.

Specified by:
setProperties in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
properties - the properties to be set; may not be null

setProperties

public void setProperties(SessionCache cache,
                          Iterator<Property> properties)
Description copied from interface: MutableCachedNode
Set the properties on this node.

Specified by:
setProperties in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
properties - the iterator over the properties to be set; may not be null

removeProperty

public void removeProperty(SessionCache cache,
                           Name name)
Description copied from interface: MutableCachedNode
Remove the property with the given name.

Specified by:
removeProperty in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
name - the name of the property to be removed; may not be null

removeAllProperties

public void removeAllProperties(SessionCache cache)
Description copied from interface: MutableCachedNode
Remove all of the properties from this node.

Specified by:
removeAllProperties in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null

getChildReferences

public ChildReferences getChildReferences(NodeCache cache)
Description copied from interface: CachedNode
Get the set of child references for this node. Note that each child reference will need to be resolved by the caller.

Specified by:
getChildReferences in interface CachedNode
Parameters:
cache - the cache to which this node belongs, required in case this node needs to use the cache; may not be null
Returns:
the representation of the children of this node; never null but possibly empty

createChild

public MutableCachedNode createChild(SessionCache cache,
                                     NodeKey key,
                                     Name name,
                                     Property firstProperty,
                                     Property... additionalProperties)
Description copied from interface: MutableCachedNode
Create a new node as a child of this node with the supplied name and properties.

Specified by:
createChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the new node; may not be null
name - the name for the new node; may not be null
firstProperty - the first property; may not be null
additionalProperties - the properties that should be set on the node; may be null or empty, and any null property references will be ignored
Returns:
the new child node

createChild

public MutableCachedNode createChild(SessionCache cache,
                                     NodeKey key,
                                     Name name,
                                     Iterable<Property> properties)
Description copied from interface: MutableCachedNode
Create a new node as a child of this node with the supplied name and properties.

Specified by:
createChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the new node; may not be null
name - the name for the new node; may not be null
properties - the properties that should be set on the node; may be null or empty, and any null property references will be ignored
Returns:
the new child node

removeChild

public void removeChild(SessionCache cache,
                        NodeKey key)
Description copied from interface: MutableCachedNode
Remove the node from being a child of this node. NOTE: THIS METHOD DOES NOT DELETE THE NODE

Specified by:
removeChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the child that is to be removed; may not be null

moveChild

public void moveChild(SessionCache cache,
                      NodeKey key,
                      MutableCachedNode newParent,
                      Name newName)
Description copied from interface: MutableCachedNode
Remove the node from being a child of this node and append it as a child of the supplied node.

Specified by:
moveChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the child that is to be removed; may not be null
newParent - the new parent for the node; may not be null and may not be this node
newName - the new name for the node, or null if the existing name is to be used

removeChildFromNode

protected SessionNode removeChildFromNode(AbstractSessionCache session,
                                          NodeKey key)

reorderChild

public void reorderChild(SessionCache cache,
                         NodeKey key,
                         NodeKey nextNode)
Description copied from interface: MutableCachedNode
Remove the node from being a child of this node and append it as a child before the supplied node.

Specified by:
reorderChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the child that is to be removed; may not be null
nextNode - the key for the node before which the node should be moved; may be null if the node should be moved to the end of the parents

renameChild

public void renameChild(SessionCache cache,
                        NodeKey key,
                        Name newName)
Description copied from interface: MutableCachedNode
Renames the child node.

Specified by:
renameChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
key - the key for the child that is to be removed; may not be null
newName - the new name for the node; may not be null

linkChild

public boolean linkChild(SessionCache cache,
                         NodeKey childKey,
                         Name name)
Description copied from interface: MutableCachedNode
Link the existing node with the supplied key to be appended as a child of this node. After this method, the referenced node is considered a child of this node as well as a child of its original parent(s).

The link can be removed by simply removing the linked child from the parent, and this works whether or not the parent is the original parent or an additional parent.

Specified by:
linkChild in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
childKey - the key for the child that is to be removed; may not be null
name - the name for the (linked) node, or null if the existing name is to be used
Returns:
true if the link was created, or false if the link already existed as a child of this node

getEtag

public String getEtag(SessionCache cache)
Description copied from interface: MutableCachedNode
Compute an ETag value for this node.

Specified by:
getEtag in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
Returns:
an ETag value; never null but possibly empty

deepCopy

public Map<NodeKey,NodeKey> deepCopy(SessionCache cache,
                                     CachedNode sourceNode,
                                     SessionCache sourceCache)
Description copied from interface: MutableCachedNode
Copies into this node all the properties and children (deep copy) from the given source node.

Specified by:
deepCopy in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
sourceNode - the node from which to copy the properties and children; may not be null
sourceCache - the cache in which the source node belongs; may not be null
Returns:
a [source key -> target key] which represents the node correspondence after the copy operation.

deepClone

public void deepClone(SessionCache cache,
                      CachedNode sourceNode,
                      SessionCache sourceCache)
Description copied from interface: MutableCachedNode
Clones into this node all the properties and children (deep clone) from the given source node. Each cloned node will have the same identifier as the source node.

Specified by:
deepClone in interface MutableCachedNode
Parameters:
cache - the cache to which this node belongs; may not be null
sourceNode - the node from which to copy the properties and children; may not be null
sourceCache - the cache in which the source node belongs; may not be null

removedChildren

public Set<NodeKey> removedChildren()
Description copied from interface: MutableCachedNode
Returns a set with the keys of the children which have been removed for this node.

Specified by:
removedChildren in interface MutableCachedNode
Returns:
a Set<NodeKey>, never null

getChangedReferrerNodes

public Set<NodeKey> getChangedReferrerNodes()
Description copied from interface: MutableCachedNode
Returns a set with all the referencing nodes (nodes which are referring this node) which have changed.

Specified by:
getChangedReferrerNodes in interface MutableCachedNode
Returns:
the set of NodeKey instances, never null.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

getString

public String getString(NamespaceRegistry registry)

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.