ModeShape Distribution 3.2.0.Final

org.modeshape.jcr.cache
Interface MutableCachedNode

All Superinterfaces:
CachedNode
All Known Implementing Classes:
SessionNode

public interface MutableCachedNode
extends CachedNode


Nested Class Summary
static interface MutableCachedNode.NodeChanges
          Interface which exposes all the changes that have occurred on a MutableCachedNode instance
 
Nested classes/interfaces inherited from interface org.modeshape.jcr.cache.CachedNode
CachedNode.ReferenceType
 
Method Summary
 void addMixin(SessionCache cache, Name mixinName)
          Add the supplied mixin type if not already an explicitly referenced.
 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.
 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.
 Set<Name> getAddedMixins(SessionCache cache)
          Get the set of mixin names that were added to this node but not yet saved.
 Set<NodeKey> getChangedReferrerNodes()
          Returns a set with all the referencing nodes (nodes which are referring this node) which have changed.
 String getEtag(SessionCache cache)
          Compute an ETag value for this node.
 MutableCachedNode.NodeChanges getNodeChanges()
          Returns an object encapsulating all the different changes that this session node contains.
 boolean hasChangedPrimaryType()
          Return whether the primary type for the node has changed.
 boolean hasChanges()
          Return whether this node has changes, including property-related changes and other changes not related to properties.
 boolean hasIndexRelatedChanges()
          Return whether this node has any changes that affect the indexes.
 boolean hasNonPropertyChanges()
          Return whether this node has changes unrelated to properties.
 boolean hasOnlyChangesToAdditionalParents()
          Return whether this node contains only changes to the additional parents.
 boolean hasPropertyChanges()
          Return whether this node has changes in the properties.
 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.
 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.
 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.
 void removeAllProperties(SessionCache cache)
          Remove all of the properties from this node.
 void removeChild(SessionCache cache, NodeKey key)
          Remove the node from being a child of this node.
 Set<NodeKey> removedChildren()
          Deprecated. use MutableCachedNode.NodeChanges.removedChildren()
 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.
 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.
 void setQueryable(boolean queryable)
          Sets a flag indicating if this node should be queryable or not.
 void setReference(SessionCache cache, Property property, SessionCache systemCache)
          Sets a property of type reference in the case when there's an active system cache and the property is a reference towards a transient node from the system cache.
 void unlock()
          Unlock this node.
 
Methods inherited from interface org.modeshape.jcr.cache.CachedNode
getAdditionalParentKeys, getChildReferences, getKey, getMixinTypes, getName, getParentKey, getParentKeyInAnyWorkspace, getPath, getPath, getPrimaryType, getProperties, getProperties, getProperty, getPropertyCount, getReferrers, getSegment, hasProperties, hasProperty, isAtOrBelow, isQueryable
 

Method Detail

isNew

boolean isNew()
Return whether this node was created since last saved.

Returns:
true if this node was created since the session was last saved, or false otherwise

isPropertyNew

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

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:
isPropertyModified(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name), isNew()

isPropertyModified

boolean isPropertyModified(SessionCache cache,
                           Name propertyName)
Return whether the property with the supplied name was modified since the session was last saved.

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:
isPropertyNew(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name)

hasChanges

boolean hasChanges()
Return whether this node has changes, including property-related changes and other changes not related to properties. This is equivalent to calling hasNonPropertyChanges() || hasPropertyChanges().

Returns:
true if this node has changes, or false otherwise
See Also:
hasNonPropertyChanges(), hasPropertyChanges()

hasNonPropertyChanges

boolean hasNonPropertyChanges()
Return whether this node has changes unrelated to properties.

Returns:
true if this node has changes unrelated to properties, or false otherwise
See Also:
hasChanges(), hasPropertyChanges()

hasPropertyChanges

boolean hasPropertyChanges()
Return whether this node has changes in the properties.

Returns:
true if this node has added, removed, or changed properties, or false otherwise
See Also:
hasChanges(), hasNonPropertyChanges()

hasIndexRelatedChanges

boolean hasIndexRelatedChanges()
Return whether this node has any changes that affect the indexes.

Returns:
true if this node has added, removed, changed properties, a new parent or if it is new.
See Also:
hasChanges(), hasNonPropertyChanges(), hasPropertyChanges()

lock

void lock(boolean sessionScoped)
Lock this node.

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

unlock

void unlock()
Unlock this node.


setProperty

void setProperty(SessionCache cache,
                 Property property)
Set the property with the given name.

Parameters:
cache - the cache to which this node belongs; may not be null
property - the property; may not be null
Throws:
NodeNotFoundException - if this node no longer exists

setReference

void setReference(SessionCache cache,
                  Property property,
                  SessionCache systemCache)
Sets a property of type reference in the case when there's an active system cache and the property is a reference towards a transient node from the system cache.

Parameters:
cache - the cache to which this node belongs; may not be null
property - the property; may not be null
systemCache - an existing system cache which contains transient nodes towards which the property points.
Throws:
NodeNotFoundException - if this node no longer exists

setPropertyIfUnchanged

void setPropertyIfUnchanged(SessionCache cache,
                            Property property)
Set the given property only if it has not been set previously and therefore appear as changed.

Parameters:
cache - the cache to which this node belongs; may not be null
property - the property; may not be null
Throws:
NodeNotFoundException - if this node no longer exists

setProperties

void setProperties(SessionCache cache,
                   Iterable<Property> properties)
Set the properties on this node.

Parameters:
cache - the cache to which this node belongs; may not be null
properties - the properties to be set; may not be null
Throws:
NodeNotFoundException - if this node no longer exists

setProperties

void setProperties(SessionCache cache,
                   Iterator<Property> properties)
Set the properties on this node.

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
Throws:
NodeNotFoundException - if this node no longer exists

removeAllProperties

void removeAllProperties(SessionCache cache)
Remove all of the properties from this node.

Parameters:
cache - the cache to which this node belongs; may not be null
Throws:
NodeNotFoundException - if this node no longer exists

removeProperty

void removeProperty(SessionCache cache,
                    Name name)
Remove the property with the given name.

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
Throws:
NodeNotFoundException - if this node no longer exists

addMixin

void addMixin(SessionCache cache,
              Name mixinName)
Add the supplied mixin type if not already an explicitly referenced.

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

void removeMixin(SessionCache cache,
                 Name mixinName)
Remove the supplied mixin type if already an explicitly referenced.

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

getAddedMixins

Set<Name> getAddedMixins(SessionCache cache)
Get the set of mixin names that were added to this node but not yet saved.

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

hasChangedPrimaryType

boolean hasChangedPrimaryType()
Return whether the primary type for the node has changed.

Returns:
true if the primary type for the node has changed, or false otherwise

createChild

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.

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

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.

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

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

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
Throws:
NodeNotFoundException - if the node does not exist as a child of this node

moveChild

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.

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
Throws:
NodeNotFoundException - if the node does not exist as a child of this node

linkChild

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. 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.

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
Throws:
NodeNotFoundException - if the node does not exist

reorderChild

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.

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
Throws:
NodeNotFoundException - if the node does not exist as a child of this node

renameChild

void renameChild(SessionCache cache,
                 NodeKey key,
                 Name newName)
Renames the child node.

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
Throws:
NodeNotFoundException - if the node does not exist as a child of this node

addReferrer

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.

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

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.

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

getEtag

String getEtag(SessionCache cache)
Compute an ETag value for this node.

Parameters:
cache - the cache to which this node belongs; may not be null
Returns:
an ETag value; never null but possibly empty

deepCopy

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.

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

void deepClone(SessionCache cache,
               CachedNode sourceNode,
               SessionCache sourceCache)
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.

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

@Deprecated
Set<NodeKey> removedChildren()
Deprecated. use MutableCachedNode.NodeChanges.removedChildren()

Returns a set with the keys of the children which have been removed for this node.

Returns:
a Set<NodeKey>, never null

getChangedReferrerNodes

Set<NodeKey> getChangedReferrerNodes()
Returns a set with all the referencing nodes (nodes which are referring this node) which have changed.

Returns:
the set of NodeKey instances, never null.

hasOnlyChangesToAdditionalParents

boolean hasOnlyChangesToAdditionalParents()
Return whether this node contains only changes to the additional parents.

Returns:
true if this node contains only added or removed additional parents.

setQueryable

void setQueryable(boolean queryable)
Sets a flag indicating if this node should be queryable or not.

Parameters:
queryable - a boolean.

getNodeChanges

MutableCachedNode.NodeChanges getNodeChanges()
Returns an object encapsulating all the different changes that this session node contains.

Returns:
a non-null MutableCachedNode.NodeChanges object.

ModeShape Distribution 3.2.0.Final

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