|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.connector.base.MapNode
public class MapNode
A Node
implementation used by the hashed-based connector (see MapWorkspace
and MapTransaction
), which
stores all node state keyed by the node's hash (or identifier).
Strictly speaking, this class is not immutable or thread safe. However, the persisted state cannot be changed. Instead, any
changes made to the object are stored in a transient area and are made "persistable"via the freeze()
method.
The MapTransaction
maintains an unfrozen, changed instance within it transactional state, and always puts the
frozen
, read-only representation inside the
Nested Class Summary | |
---|---|
protected class |
MapNode.Changes
|
Field Summary | |
---|---|
protected MapNode.Changes |
changes
The changes made to this object, making it unfrozen |
Constructor Summary | |
---|---|
|
MapNode(UUID uuid)
Create a root node with the supplied UUID. |
|
MapNode(UUID uuid,
Path.Segment name,
UUID parent,
Iterable<Property> properties,
List<UUID> children)
Create a new node instance. |
|
MapNode(UUID uuid,
Path.Segment name,
UUID parent,
Map<Name,Property> properties,
List<UUID> children)
Create a new node instance. |
protected |
MapNode(UUID uuid,
Path.Segment name,
UUID parent,
Map<Name,Property> properties,
List<UUID> children,
int version)
Create a new node instance. |
Method Summary | |
---|---|
MapNode |
clone()
This method never clones the changes . |
boolean |
equals(Object obj)
|
MapNode |
freeze()
Return the frozen node with all internal state reflective of any changes. |
List<UUID> |
getChildren()
|
Path.Segment |
getName()
Returns the name of this node along with its SNS index within its parent's children |
UUID |
getParent()
|
Map<Name,Property> |
getProperties()
Returns properties of this node. |
Property |
getProperty(Name name)
Returns the property with the supplied name. |
UUID |
getUuid()
Returns the UUID for this node |
int |
getVersion()
Get the version number of this node. |
protected boolean |
hasChanges()
Determine if this node has any unsaved changes. |
int |
hashCode()
|
protected MapNode.Changes |
newChanges()
Create the MapNode.Changes implementation. |
String |
toString()
|
MapNode |
withChild(int index,
UUID child)
Create a copy of this node except adding the supplied node into the existing children at the specified index. |
MapNode |
withChild(UUID child)
Create a copy of this node except adding the supplied node at the end of the existing children. |
MapNode |
withName(Path.Segment name)
Create a copy of this node except using the supplied name. |
MapNode |
withoutChild(UUID child)
Create a copy of this node except without the supplied child node. |
MapNode |
withoutChildren()
Create a copy of this node except with none of the children. |
MapNode |
withoutProperties()
|
MapNode |
withoutProperty(Name propertyName)
Create a copy of this node except with the new property. |
MapNode |
withParent(UUID parent)
Create a copy of this node except using the supplied parent. |
MapNode |
withProperties(Iterable<Property> propertiesToSet,
Iterable<Name> propertiesToRemove,
boolean removeAllExisting)
Create a copy of this node except with the changes to the properties. |
MapNode |
withProperty(Property property)
Create a copy of this node except with the new property. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient MapNode.Changes changes
Constructor Detail |
---|
public MapNode(UUID uuid, Path.Segment name, UUID parent, Map<Name,Property> properties, List<UUID> children)
uuid
- the UUID of the node; may not be nullname
- the name of the node; may be null only if the parent is also nullparent
- the UUID of the parent node; may be null only if the name is nullproperties
- the unmodifiable map of properties; may be null or emptychildren
- the unmodificable list of child UUIDs; may be null or emptyprotected MapNode(UUID uuid, Path.Segment name, UUID parent, Map<Name,Property> properties, List<UUID> children, int version)
uuid
- the UUID of the node; may not be nullname
- the name of the node; may be null only if the parent is also nullparent
- the UUID of the parent node; may be null only if the name is nullproperties
- the unmodifiable map of properties; may be null or emptychildren
- the unmodificable list of child UUIDs; may be null or emptyversion
- the version numberpublic MapNode(UUID uuid, Path.Segment name, UUID parent, Iterable<Property> properties, List<UUID> children)
uuid
- the UUID of the node; may not be nullname
- the name of the node; may be null only if the parent is also nullparent
- the UUID of the parent node; may be null only if the name is nullproperties
- the properties that are to be copied into the new node; may be null or emptychildren
- the unmodificable list of child UUIDs; may be null or emptypublic MapNode(UUID uuid)
uuid
- the UUID of the root node; may not be nullMethod Detail |
---|
public int getVersion()
public UUID getUuid()
getUuid
in interface Node
Node.getUuid()
public Path.Segment getName()
getName
in interface Node
Node.getName()
public Map<Name,Property> getProperties()
getProperties
in interface Node
Node.getProperties()
public Property getProperty(Name name)
getProperty
in interface Node
name
- the name of the property
Node.getProperty(org.modeshape.graph.property.Name)
public UUID getParent()
public List<UUID> getChildren()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public String toString()
toString
in class Object
Object.toString()
public MapNode clone()
This method never clones the changes
.
clone
in class Object
Object.clone()
protected boolean hasChanges()
protected MapNode.Changes newChanges()
MapNode.Changes
implementation. Subclasses that require a specialized class should overwrite this method. Note
that this method does not modify any internal state; it should just instantiate and return the correct Changes class.
public MapNode freeze()
version
number.
public MapNode withParent(UUID parent)
parent
- Sets parent to the specified value.
public MapNode withName(Path.Segment name)
name
- Sets name to the specified value.
public MapNode withChild(UUID child)
child
- the UUID of the child that is to be added; may not be null
public MapNode withChild(int index, UUID child)
index
- the index at which the child is to appearchild
- the UUID of the child that is to be added at the end of the existing children
public MapNode withoutChild(UUID child)
child
- the UUID of the child that is to be removed; may not be null
public MapNode withoutChildren()
public MapNode withProperties(Iterable<Property> propertiesToSet, Iterable<Name> propertiesToRemove, boolean removeAllExisting)
propertiesToSet
- the properties that are to be set; may be null if no properties are to be setpropertiesToRemove
- the names of the properties that are to be removed; may be null if no properties are to be
removedremoveAllExisting
- true if all existing properties should be removed
public MapNode withProperty(Property property)
property
- the property to set
public MapNode withoutProperty(Name propertyName)
propertyName
- the name of the property that is to be removed
public MapNode withoutProperties()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |