|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.session.GraphSession.Node<Payload,PropertyPayload>
@NotThreadSafe public static class GraphSession.Node<Payload,PropertyPayload>
Constructor Summary | |
---|---|
GraphSession.Node(GraphSession<Payload,PropertyPayload> cache,
GraphSession.Node<Payload,PropertyPayload> parent,
GraphSession.NodeId nodeId,
Location location)
|
Method Summary | |
---|---|
void |
clearChanges()
Clear any transient changes that have been accumulated in this node. |
void |
cloneNode()
Clone this node (and all nodes below it). |
boolean |
containsChangesWithExternalDependencies()
This method determines whether this node, or any nodes below it, contain changes that depend on nodes that are outside of this branch. |
void |
copyTo(GraphSession.Node<Payload,PropertyPayload> parent)
Copy this node (and all nodes below it) and place the copy under the supplied parent location. |
GraphSession.Node<Payload,PropertyPayload> |
createChild(Name name)
Create a new child node with the supplied name. |
GraphSession.Node<Payload,PropertyPayload> |
createChild(Name name,
Collection<Property> idProperties)
Create a new child node with the supplied name and multiple initial identification properties. |
GraphSession.Node<Payload,PropertyPayload> |
createChild(Name name,
Collection<Property> idProperties,
Property... remainingProperties)
Create a new child node with the supplied name and multiple initial properties. |
GraphSession.Node<Payload,PropertyPayload> |
createChild(Name name,
Property... properties)
Create a new child node with the supplied name and multiple initial properties. |
void |
destroy()
Remove this node from it's parent and destroy it's contents. |
boolean |
equals(Object obj)
|
GraphSession.Node<Payload,PropertyPayload> |
getChild(Name name,
int sns)
Get the child with the supplied name and SNS index. |
GraphSession.Node<Payload,PropertyPayload> |
getChild(Path.Segment segment)
Get the child with the supplied segment. |
GraphSession.Node<Payload,PropertyPayload> |
getChildAfter(GraphSession.Node<Payload,PropertyPayload> child)
Get the child node that immediately follows the supplied child. |
Iterable<GraphSession.Node<Payload,PropertyPayload>> |
getChildren()
Get an iterator over the children. |
Iterable<GraphSession.Node<Payload,PropertyPayload>> |
getChildren(Name name)
Get an iterator over the children that have the supplied name. |
int |
getChildrenCount()
Get the number of children. |
int |
getChildrenCount(Name name)
Get the number of children that have the same supplied name. |
long |
getExpirationTimeInMillis()
Get the time when this node expires. |
GraphSession.Node<Payload,PropertyPayload> |
getFirstChild(Name name)
Get the first child matching the name and lowest SNS index |
Location |
getLocation()
Get the current location for this node. |
Name |
getName()
Get the name of this node, without any same-name-sibling index. |
GraphSession.NodeId |
getNodeId()
|
Location |
getOriginalLocation()
Get the original location for this node prior to making any transient changes. |
GraphSession.Node<Payload,PropertyPayload> |
getParent()
Get this node's parent node. |
Path |
getPath()
Get the current path to this node. |
Payload |
getPayload()
|
Collection<GraphSession.PropertyInfo<PropertyPayload>> |
getProperties()
Get the information for each of the properties on this node. |
GraphSession.PropertyInfo<PropertyPayload> |
getProperty(Name name)
Get from this node the property with the supplied name. |
int |
getPropertyCount()
Get the number of properties owned by this node. |
Set<Name> |
getPropertyNames()
Get the names of the properties on this node. |
Path.Segment |
getSegment()
Get the path segment for this node. |
GraphSession<Payload,PropertyPayload> |
getSession()
Get the session to which this node belongs. |
GraphSession.StructureSnapshot<PropertyPayload> |
getSnapshot(boolean pathsOnly)
Obtain a snapshot of the structure below this node. |
String |
getString(NamespaceRegistry registry)
Utility method to obtain a string representation that uses the namespace prefixes where appropriate. |
boolean |
hasChild(Name name,
int sns)
Determine whether this node has a child with the supplied name and SNS index. |
boolean |
hasChild(Path.Segment segment)
Determine whether this node has a child with the supplied name and SNS index. |
int |
hashCode()
|
boolean |
isAtOrBelow(GraphSession.Node<Payload,PropertyPayload> other)
|
boolean |
isChanged(boolean recursive)
Determine whether this node has been marked as having changes. |
boolean |
isExpired()
Determine if this node's information has expired. |
boolean |
isLeaf()
Determine if this node is a leaf node with no children. |
boolean |
isLoaded()
Determine if this node is loaded and usable. |
boolean |
isNew()
Determine whether this node has been created since the last save. |
boolean |
isRoot()
|
boolean |
isStale()
Determine whether this node is stale because it was dropped from the cache. |
protected void |
load()
Method that causes the information for this node to be read from the store and loaded into the cache |
void |
loadedWith(List<Location> children,
Map<Name,GraphSession.PropertyInfo<PropertyPayload>> properties,
DateTime expirationTime)
Define the persistent child information that this node is to be populated with. |
void |
loadedWith(Map<Name,GraphSession.PropertyInfo<PropertyPayload>> properties)
Define the persistent property information that this node is to be populated with. |
void |
markAsChanged()
Mark this node as having changes. |
protected void |
markAsChangedBelow()
|
void |
markAsCopied()
|
void |
markAsNew()
Mark this node has having been created and not yet saved. |
void |
moveTo(GraphSession.Node<Payload,PropertyPayload> parent)
Move this node from its current location so that is is a child of the supplied parent. |
void |
moveTo(GraphSession.Node<Payload,PropertyPayload> parent,
Name newNodeName)
Move this node from its current location so that is is a child of the supplied parent, renaming the node in the process. |
protected void |
moveTo(GraphSession.Node<Payload,PropertyPayload> parent,
Name newNodeName,
boolean useBatch)
Move this node from its current location so that is is a child of the supplied parent. |
void |
onCachedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
Visit all loaded and unloaded nodes in the cache. |
void |
onChangedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
Visit all changed nodes in the cache. |
void |
onLoadedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
Visit all nodes in the cache that are already loaded |
void |
orderChildBefore(Path.Segment childToBeMoved,
Path.Segment before)
Move the specified child to be located immediately before the other supplied node. |
protected void |
recomputeChangedBelow()
|
protected boolean |
refreshPhase1(GraphSession.RefreshState<Payload,PropertyPayload> refreshState)
Phase 1 of the process of refreshing the cached content while retaining changes. |
protected void |
refreshPhase2(GraphSession.RefreshState<Payload,PropertyPayload> refreshState,
Results persistentInfoForRefreshedNodes)
Phase 2 of the process of refreshing the cached content while retaining changes. |
protected void |
remove()
Remove this node from it's parent. |
protected void |
remove(boolean markParentAsChanged)
Remove this node from it's parent. |
GraphSession.PropertyInfo<PropertyPayload> |
removeProperty(Name name)
Remove a property from this node. |
void |
rename(Name newNodeName)
Rename this node to have a different name. |
void |
setPayload(Payload payload)
|
GraphSession.PropertyInfo<PropertyPayload> |
setProperty(Property property,
boolean isMultiValued,
PropertyPayload payload)
Set the supplied property information on this node. |
void |
setUuid(UUID uuid)
|
protected void |
synchronizeWithNewlyPersistedNode(Location newChild)
This method is used to adjust the existing children by adding a child that was recently added to the persistent store (via clone or copy). |
String |
toString()
|
protected void |
unload()
Utility method to unload this cached node. |
protected void |
updateLocation(Path.Segment segment)
Reconstruct the location object for this node, given the information at the parent. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GraphSession.Node(GraphSession<Payload,PropertyPayload> cache, GraphSession.Node<Payload,PropertyPayload> parent, GraphSession.NodeId nodeId, Location location)
Method Detail |
---|
public GraphSession<Payload,PropertyPayload> getSession()
public final long getExpirationTimeInMillis()
Long.MAX_VALUE
if there is no expiration or if the node has not been loadedisExpired()
,
isLoaded()
public final boolean isExpired()
public final boolean isLoaded()
protected final void load() throws RepositorySourceException
AccessControlException
- if the caller does not have the permission to perform the operation
RepositorySourceException
- if there is a problem reading the storeprotected final void unload()
protected final boolean refreshPhase1(GraphSession.RefreshState<Payload,PropertyPayload> refreshState)
changed
state
, and the supplied RefreshState tracks which nodes must be
refreshed
in
phase 2
; all other nodes are able to be unloaded in
phase 2
.
refreshState
- the holder of the information about which nodes are to be unloaded or refreshed; may not be null
#refreshPhase2(RefreshState, Results)
protected final void refreshPhase2(GraphSession.RefreshState<Payload,PropertyPayload> refreshState, Results persistentInfoForRefreshedNodes)
refreshState
- persistentInfoForRefreshedNodes
- #refreshPhase1(RefreshState)
public void loadedWith(List<Location> children, Map<Name,GraphSession.PropertyInfo<PropertyPayload>> properties, DateTime expirationTime)
This method is intended to be called by the GraphSession.Operations#materialize(org.modeshape.graph.Node, Node)
, and should not be called by other components.
children
- the children for this node; may not be nullproperties
- the properties for this node; may not be nullexpirationTime
- the time that this cached information expires, or null if there is no expirationpublic void loadedWith(Map<Name,GraphSession.PropertyInfo<PropertyPayload>> properties)
properties
- the properties for this node; may not be nullprotected void updateLocation(Path.Segment segment)
segment
- the path segment for this node; may be null only when this node is the root nodeprotected void synchronizeWithNewlyPersistedNode(Location newChild)
newChild
- the new child that was addedpublic final boolean isChanged(boolean recursive)
recursive
- true if the nodes under this node should be checked, or false if only this node should be checked
public final boolean isNew()
changed
.
public boolean containsChangesWithExternalDependencies()
public void clearChanges()
markAsChanged()
public final void markAsChanged()
clearChanges()
,
markAsNew()
public final void markAsCopied()
public final void markAsNew()
clearChanges()
,
markAsChanged()
protected final void markAsChangedBelow()
protected final void recomputeChangedBelow()
public void moveTo(GraphSession.Node<Payload,PropertyPayload> parent)
parent
- the new parent for this node; may not be null
RepositorySourceException
- if the parent node is to be loaded but a problem is encountered while doing so
IllegalArgumentException
- if this is the root nodepublic void moveTo(GraphSession.Node<Payload,PropertyPayload> parent, Name newNodeName)
parent
- the new parent for this node; may not be nullnewNodeName
- the new name for the node, or null if the node should keep the same name
RepositorySourceException
- if the parent node is to be loaded but a problem is encountered while doing so
IllegalArgumentException
- if this is the root nodeprotected void moveTo(GraphSession.Node<Payload,PropertyPayload> parent, Name newNodeName, boolean useBatch)
parent
- the new parent for this node; may not be nullnewNodeName
- the new name for the node, or null if the node should keep the same nameuseBatch
- true if this operation should be performed using the session's current batch operation and executed
upon GraphSession.save()
, or false if the move should be performed immediately
ValidationException
- if the supplied parent node is a decendant of this node
RepositorySourceException
- if the parent node is to be loaded but a problem is encountered while doing so
IllegalArgumentException
- if this is the root node
AccessControlException
- if the caller does not have the permission to perform the operationpublic void rename(Name newNodeName)
newNodeName
- public void copyTo(GraphSession.Node<Payload,PropertyPayload> parent)
parent
- the new parent for the new copy; may not be null
RepositorySourceException
- if the parent node is to be loaded but a problem is encountered while doing so
IllegalArgumentException
- if the parent is null, or if this is the root node
AccessControlException
- if the caller does not have the permission to perform the operationpublic void cloneNode()
parent
, and will be given the appropriate same-name-sibling index.
This is equivalent to calling node.copyTo(node.getParent())
IllegalArgumentException
- if this is the root nodepublic void orderChildBefore(Path.Segment childToBeMoved, Path.Segment before) throws PathNotFoundException
childToBeMoved
- the path segment specifying the child that is to be movedbefore
- the path segment of the node before which the childToBeMoved
should be placed, or null if the
child should be moved to the end
PathNotFoundException
- if the childToBeMoved
or before
segments do not specify an
existing child
IllegalArgumentException
- if either segment is null or does not specify an existing nodeprotected void remove()
protected void remove(boolean markParentAsChanged)
markParentAsChanged
- true if the parent should be marked as being changed (i.e., when changes are initiated from
within this session), or false otherwise (i.e., when changes are made to reflect the persistent state)public void destroy()
AccessControlException
- if the caller does not have the permission to perform the operationpublic final boolean isRoot()
public boolean isStale()
public GraphSession.Node<Payload,PropertyPayload> getParent()
public final GraphSession.NodeId getNodeId()
public Name getName()
public final Path.Segment getSegment()
path segment
for this node.
public final Path getPath()
public final Location getLocation()
public final void setUuid(UUID uuid)
public final Location getOriginalLocation()
public GraphSession.Node<Payload,PropertyPayload> createChild(Name name)
name
- the name of the new child node
IllegalArgumentException
- if the name is null
RepositorySourceException
- if this node must be loaded but doing so results in a problempublic GraphSession.Node<Payload,PropertyPayload> createChild(Name name, Property... properties)
name
- the name of the new child nodeproperties
- the (non-identification) properties for the new node
IllegalArgumentException
- if the name or properties are null
ValidationException
- if the new node is not valid as a child
RepositorySourceException
- if this node must be loaded but doing so results in a problempublic GraphSession.Node<Payload,PropertyPayload> createChild(Name name, Collection<Property> idProperties)
name
- the name of the new child nodeidProperties
- the identification properties for the new node
IllegalArgumentException
- if the name or properties are null
ValidationException
- if the new node is not valid as a child
RepositorySourceException
- if this node must be loaded but doing so results in a problempublic GraphSession.Node<Payload,PropertyPayload> createChild(Name name, Collection<Property> idProperties, Property... remainingProperties)
name
- the name of the new child nodeidProperties
- the identification properties for the new noderemainingProperties
- the remaining (non-identification) properties for the new node
IllegalArgumentException
- if the name or properties are null
ValidationException
- if the new node is not valid as a child
RepositorySourceException
- if this node must be loaded but doing so results in a problempublic boolean hasChild(Path.Segment segment)
segment
- the segment of the child
RepositorySourceException
- if there is a problem loading this node's information from the storepublic boolean hasChild(Name name, int sns)
name
- the name of the childsns
- the same-name-sibling index; must be 1 or more
RepositorySourceException
- if there is a problem loading this node's information from the storepublic GraphSession.Node<Payload,PropertyPayload> getChild(Path.Segment segment)
segment
- the segment of the child
PathNotFoundException
- if the children have been loaded and the child does not exist
RepositorySourceException
- if there is a problem loading this node's information from the storepublic GraphSession.Node<Payload,PropertyPayload> getFirstChild(Name name)
name
- the name of the child
PathNotFoundException
- if the children have been loaded and the child does not exist
RepositorySourceException
- if there is a problem loading this node's information from the storepublic GraphSession.Node<Payload,PropertyPayload> getChild(Name name, int sns)
name
- the name of the childsns
- the same-name-sibling index; must be 1 or more
PathNotFoundException
- if the children have been loaded and the child does not exist
RepositorySourceException
- if there is a problem loading this node's information from the storepublic Iterable<GraphSession.Node<Payload,PropertyPayload>> getChildren(Name name)
name
- the of the child nodes to be returned; may not be null
RepositorySourceException
- if there is a problem loading this node's information from the storepublic Iterable<GraphSession.Node<Payload,PropertyPayload>> getChildren()
RepositorySourceException
- if there is a problem loading this node's information from the storepublic GraphSession.Node<Payload,PropertyPayload> getChildAfter(GraphSession.Node<Payload,PropertyPayload> child)
child
- the existing child; must be a child of this node
public int getChildrenCount()
RepositorySourceException
- if there is a problem loading this node's information from the storepublic int getChildrenCount(Name name)
name
- the name of the children to count
RepositorySourceException
- if there is a problem loading this node's information from the storepublic boolean isLeaf()
RepositorySourceException
- if there is a problem loading this node's information from the storepublic GraphSession.PropertyInfo<PropertyPayload> getProperty(Name name)
name
- the property name; may not be null
public GraphSession.PropertyInfo<PropertyPayload> setProperty(Property property, boolean isMultiValued, PropertyPayload payload)
property
- the new property; may not be nullisMultiValued
- true if the property is multi-valuedpayload
- the optional payload for this property; may be null
AccessControlException
- if the caller does not have the permission to perform the operationpublic GraphSession.PropertyInfo<PropertyPayload> removeProperty(Name name)
name
- the name of the property to be removed; may not be null
public Set<Name> getPropertyNames()
public Collection<GraphSession.PropertyInfo<PropertyPayload>> getProperties()
public int getPropertyCount()
public boolean isAtOrBelow(GraphSession.Node<Payload,PropertyPayload> other)
public Payload getPayload()
public void setPayload(Payload payload)
payload
- Sets payload to the specified value.public final int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public String getString(NamespaceRegistry registry)
registry
- the namespace registry, or null if no prefixes should be used
public String toString()
toString
in class Object
Object.toString()
public void onLoadedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
visitor
- the visitor; may not be nullpublic void onCachedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
visitor
- the visitor; may not be nullpublic void onChangedNodes(GraphSession.NodeVisitor<Payload,PropertyPayload> visitor)
visitor
- the visitor; may not be nullpublic GraphSession.StructureSnapshot<PropertyPayload> getSnapshot(boolean pathsOnly)
pathsOnly
- true if the snapshot should only include paths, or false if the entire locations should be included
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |