|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.cache.document.SessionNode
@ThreadSafe public class SessionNode
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 |
---|
public SessionNode(NodeKey key, boolean isNew)
Method Detail |
---|
protected final SessionNode.ChangedChildren changedChildren()
protected final Set<Name> removedProperties()
protected final ConcurrentMap<Name,Property> changedProperties()
protected final NodeKey newParent()
public final boolean isNew()
MutableCachedNode
isNew
in interface MutableCachedNode
public final boolean isPropertyNew(SessionCache cache, Name propertyName)
MutableCachedNode
true
if MutableCachedNode.isNew()
returns true
.
isPropertyNew
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullpropertyName
- the name of the property; may not be null
MutableCachedNode.isPropertyModified(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name)
,
MutableCachedNode.isNew()
public final boolean isPropertyModified(SessionCache cache, Name propertyName)
MutableCachedNode
isPropertyModified
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullpropertyName
- the name of the property; may not be null
MutableCachedNode.isPropertyNew(org.modeshape.jcr.cache.SessionCache, org.modeshape.jcr.value.Name)
public boolean hasChanges()
MutableCachedNode
hasChanges
in interface MutableCachedNode
public void lock(boolean sessionScoped)
MutableCachedNode
lock
in interface MutableCachedNode
sessionScoped
- true if the lock should be limited in scope to the lifetime of the session, or false otherwisepublic void unlock()
MutableCachedNode
unlock
in interface MutableCachedNode
public SessionNode.LockChange getLockChange()
protected MutableChildReferences appended(boolean createIfMissing)
protected SessionNode.MixinChanges mixinChanges(boolean createIfMissing)
protected SessionNode.ReferrerChanges referrerChanges(boolean createIfMissing)
protected final WritableSessionCache writableSession(NodeCache cache)
protected final AbstractSessionCache session(NodeCache cache)
protected final WorkspaceCache workspace(NodeCache cache)
protected CachedNode nodeInWorkspace(AbstractSessionCache session)
session
- the session; may not be null
public NodeKey getParentKey(NodeCache cache)
CachedNode
getParentKey
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public NodeKey getParentKeyInAnyWorkspace(NodeCache cache)
CachedNode
getParentKeyInAnyWorkspace
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
protected CachedNode parent(AbstractSessionCache session)
protected SessionNode.ChangedAdditionalParents additionalParents()
public Set<NodeKey> getAdditionalParentKeys(NodeCache cache)
CachedNode
primary parent
) under which this node
appears.
getAdditionalParentKeys
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public boolean hasOnlyChangesToAdditionalParents()
MutableCachedNode
hasOnlyChangesToAdditionalParents
in interface MutableCachedNode
public boolean isAtOrBelow(NodeCache cache, Path path)
CachedNode
additional parents
, a node has multiple effective paths.
isAtOrBelow
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be nullpath
- the path to be used for comparison; may not be null
public NodeKey getKey()
CachedNode
getKey
in interface CachedNode
public Name getName(NodeCache cache)
CachedNode
getName
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
CachedNode.getSegment(NodeCache)
,
CachedNode.getPath(NodeCache)
public Path.Segment getSegment(NodeCache cache)
CachedNode
getSegment
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
CachedNode.getName(NodeCache)
,
CachedNode.getPath(NodeCache)
protected final Path.Segment getSegment(NodeCache cache, CachedNode parent)
cache
- the cacheparent
- the parent node
NodeNotFoundInParentException
- if the node doesn't exist in the referenced parentpublic Path getPath(NodeCache cache)
CachedNode
getPath
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
CachedNode.getName(NodeCache)
,
CachedNode.getSegment(NodeCache)
public Path getPath(PathCache pathCache) throws NodeNotFoundException
CachedNode
getPath
in interface CachedNode
pathCache
- the cache of paths that can be used to compute the path for any node; may not be null
NodeNotFoundInParentException
- if this node no longer exists inside the parent node (and perhaps in no other parent)
NodeNotFoundException
- if this node no longer existsCachedNode.getName(NodeCache)
,
CachedNode.getSegment(NodeCache)
public Name getPrimaryType(NodeCache cache)
CachedNode
getPrimaryType
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public boolean hasChangedPrimaryType()
MutableCachedNode
hasChangedPrimaryType
in interface MutableCachedNode
public Set<Name> getMixinTypes(NodeCache cache)
CachedNode
getMixinTypes
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public void addMixin(SessionCache cache, Name mixinName)
MutableCachedNode
addMixin
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullmixinName
- the name of the mixin to be removed; may not be nullpublic void removeMixin(SessionCache cache, Name mixinName)
MutableCachedNode
removeMixin
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullmixinName
- the name of the mixin to be removed; may not be nullpublic SessionNode.MixinChanges getMixinChanges()
public Set<Name> getAddedMixins(SessionCache cache)
MutableCachedNode
getAddedMixins
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be null
public Set<NodeKey> getReferrers(NodeCache cache, CachedNode.ReferenceType type)
CachedNode
getReferrers
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be nulltype
- the flag specifying whether nodes with REFERENCE properties and/or WEAK reference properties should be included
in the result; may not be null
protected SessionNode.ReferrerChanges getReferrerChanges()
public void addReferrer(SessionCache cache, NodeKey referrerKey, CachedNode.ReferenceType type)
MutableCachedNode
addReferrer
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullreferrerKey
- the key for the node that has a new reference to this node; may not be nulltype
- the reference type; may not be nullpublic void removeReferrer(SessionCache cache, NodeKey referrerKey, CachedNode.ReferenceType type)
MutableCachedNode
removeReferrer
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullreferrerKey
- the key for the node that no longer has a reference to this node; may not be nulltype
- the reference type; may not be nullpublic int getPropertyCount(NodeCache cache)
CachedNode
getPropertyCount
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public boolean hasProperties(NodeCache cache)
CachedNode
hasProperties
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public boolean hasProperty(Name name, NodeCache cache)
CachedNode
hasProperty
in interface CachedNode
name
- the name of the propertycache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public Property getProperty(Name name, NodeCache cache)
CachedNode
getProperty
in interface CachedNode
name
- the name of the propertycache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
protected final boolean isPropertyRemoved(Name name)
public Iterator<Property> getProperties(NodeCache cache)
CachedNode
getProperties
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public Iterator<Property> getProperties(Collection<?> namePatterns, NodeCache cache)
CachedNode
getProperties
in interface CachedNode
namePatterns
- the regex patterns or string literals describing the namescache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public void setProperty(SessionCache cache, Property property)
MutableCachedNode
setProperty
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullproperty
- the property; may not be nullprotected void removeAllReferences(SessionCache cache)
protected void addOrRemoveReferrers(SessionCache cache, Property property, boolean add)
public void setPropertyIfUnchanged(SessionCache cache, Property property)
MutableCachedNode
setPropertyIfUnchanged
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullproperty
- the property; may not be nullpublic void setProperties(SessionCache cache, Iterable<Property> properties)
MutableCachedNode
setProperties
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullproperties
- the properties to be set; may not be nullpublic void setProperties(SessionCache cache, Iterator<Property> properties)
MutableCachedNode
setProperties
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullproperties
- the iterator over the properties to be set; may not be nullpublic void removeProperty(SessionCache cache, Name name)
MutableCachedNode
removeProperty
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullname
- the name of the property to be removed; may not be nullpublic void removeAllProperties(SessionCache cache)
MutableCachedNode
removeAllProperties
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullpublic ChildReferences getChildReferences(NodeCache cache)
CachedNode
getChildReferences
in interface CachedNode
cache
- the cache to which this node belongs, required in case this node needs to use the cache; may not be null
public MutableCachedNode createChild(SessionCache cache, NodeKey key, Name name, Property firstProperty, Property... additionalProperties)
MutableCachedNode
createChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the new node; may not be nullname
- the name for the new node; may not be nullfirstProperty
- the first property; may not be nulladditionalProperties
- the properties that should be set on the node; may be null or empty, and any null property
references will be ignored
public MutableCachedNode createChild(SessionCache cache, NodeKey key, Name name, Iterable<Property> properties)
MutableCachedNode
createChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the new node; may not be nullname
- the name for the new node; may not be nullproperties
- the properties that should be set on the node; may be null or empty, and any null property references
will be ignored
public void removeChild(SessionCache cache, NodeKey key)
MutableCachedNode
removeChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the child that is to be removed; may not be nullpublic void moveChild(SessionCache cache, NodeKey key, MutableCachedNode newParent, Name newName)
MutableCachedNode
moveChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the child that is to be removed; may not be nullnewParent
- the new parent for the node; may not be null and may not be this nodenewName
- the new name for the node, or null if the existing name is to be usedprotected SessionNode removeChildFromNode(AbstractSessionCache session, NodeKey key)
public void reorderChild(SessionCache cache, NodeKey key, NodeKey nextNode)
MutableCachedNode
reorderChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the child that is to be removed; may not be nullnextNode
- 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 parentspublic void renameChild(SessionCache cache, NodeKey key, Name newName)
MutableCachedNode
renameChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullkey
- the key for the child that is to be removed; may not be nullnewName
- the new name for the node; may not be nullpublic boolean linkChild(SessionCache cache, NodeKey childKey, Name name)
MutableCachedNode
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.
linkChild
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullchildKey
- the key for the child that is to be removed; may not be nullname
- the name for the (linked) node, or null if the existing name is to be used
public String getEtag(SessionCache cache)
MutableCachedNode
getEtag
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be null
public Map<NodeKey,NodeKey> deepCopy(SessionCache cache, CachedNode sourceNode, SessionCache sourceCache)
MutableCachedNode
deepCopy
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullsourceNode
- the node from which to copy the properties and children; may not be nullsourceCache
- the cache in which the source node belongs; may not be null
public void deepClone(SessionCache cache, CachedNode sourceNode, SessionCache sourceCache)
MutableCachedNode
deepClone
in interface MutableCachedNode
cache
- the cache to which this node belongs; may not be nullsourceNode
- the node from which to copy the properties and children; may not be nullsourceCache
- the cache in which the source node belongs; may not be nullpublic Set<NodeKey> removedChildren()
MutableCachedNode
removedChildren
in interface MutableCachedNode
Set<NodeKey
>
, never nullpublic Set<NodeKey> getChangedReferrerNodes()
MutableCachedNode
getChangedReferrerNodes
in interface MutableCachedNode
NodeKey
instances, never null.public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
public String getString(NamespaceRegistry registry)
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |