|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.connector.base.PathNode
public class PathNode
A Node
implementation used by the path-based connector (see PathWorkspace
and PathTransaction
), which
stores all node state in a tree of content, where a specific path exists to each node in the tree.
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 PathTransaction
maintains an unfrozen, changed instance within it transactional state, and always puts the
frozen
, read-only representation inside the
Nested Class Summary | |
---|---|
protected class |
PathNode.Changes
|
Field Summary | |
---|---|
protected PathNode.Changes |
changes
The changes made to this object, making it unfrozen |
Constructor Summary | |
---|---|
|
PathNode(UUID uuid)
Create a root node with the supplied UUID. |
|
PathNode(UUID uuid,
Path parent,
Path.Segment name,
Iterable<Property> properties,
List<Path.Segment> children)
Create a new node instance. |
|
PathNode(UUID uuid,
Path parent,
Path.Segment name,
Map<Name,Property> properties,
List<Path.Segment> children)
Create a new node instance. |
protected |
PathNode(UUID uuid,
Path parent,
Path.Segment name,
Map<Name,Property> properties,
List<Path.Segment> children,
int version)
Create a new node instance. |
Method Summary | |
---|---|
PathNode |
clone()
This method never clones the changes . |
boolean |
equals(Object obj)
|
PathNode |
freeze()
Return the frozen node with all internal state reflective of any changes. |
List<Path.Segment> |
getChildren()
|
Path.Segment |
getName()
Returns the name of this node along with its SNS index within its parent's children |
Path |
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 PathNode.Changes |
newChanges()
Create the PathNode.Changes implementation. |
String |
toString()
|
PathNode |
withChild(int index,
Path.Segment child)
Create a copy of this node except adding the supplied node into the existing children at the specified index. |
PathNode |
withChild(Path.Segment child)
Create a copy of this node except adding the supplied node at the end of the existing children. |
PathNode |
withName(Path.Segment name)
Create a copy of this node except using the supplied name. |
PathNode |
withoutChild(Path.Segment child)
Create a copy of this node except without the supplied child node. |
PathNode |
withoutChildren()
Create a copy of this node except with none of the children. |
PathNode |
withoutProperties()
Create a copy of this node without any properties |
PathNode |
withoutProperty(Name propertyName)
Create a copy of this node except without the new property. |
PathNode |
withParent(Path parent)
Create a copy of this node except using the supplied path. |
PathNode |
withProperties(Iterable<Property> propertiesToSet,
Iterable<Name> propertiesToRemove,
boolean removeAllExisting)
Create a copy of this node except with the changes to the properties. |
PathNode |
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 PathNode.Changes changes
Constructor Detail |
---|
public PathNode(UUID uuid, Path parent, Path.Segment name, Map<Name,Property> properties, List<Path.Segment> children)
uuid
- the UUID of the node; may be nullparent
- the path to the parent node; may be null only if the name is nullname
- the name of this node, relative to the parentproperties
- the unmodifiable map of properties; may be null or emptychildren
- the unmodifiable list of child segments; may be null or emptyprotected PathNode(UUID uuid, Path parent, Path.Segment name, Map<Name,Property> properties, List<Path.Segment> children, int version)
uuid
- the UUID of the node; may be nullparent
- the path to the parent node; may be null only if the name is nullname
- the name of this node, relative to the parentproperties
- the unmodifiable map of properties; may be null or emptychildren
- the unmodifiable list of child segments; may be null or emptyversion
- the version numberpublic PathNode(UUID uuid, Path parent, Path.Segment name, Iterable<Property> properties, List<Path.Segment> children)
uuid
- the UUID of the node; may be nullparent
- the path to the parent node; may be null only if the name is nullname
- the name of this node, relative to the parentproperties
- the properties that are to be copied into the new node; may be null or emptychildren
- the unmodifiable list of child segments; may be null or emptypublic PathNode(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 Path getParent()
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 List<Path.Segment> getChildren()
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
Object.toString()
public PathNode clone()
This method never clones the changes
.
clone
in class Object
Object.clone()
protected boolean hasChanges()
protected PathNode.Changes newChanges()
PathNode.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 PathNode freeze()
version
number.
public PathNode withParent(Path parent)
parent
- sets parent to the specified value.
public PathNode withName(Path.Segment name)
name
- sets name to the specified value.
public PathNode withChild(Path.Segment child)
child
- the segment of the child that is to be added; may not be null
public PathNode withChild(int index, Path.Segment child)
index
- the index at which the child is to appearchild
- the segment of the child that is to be added at the end of the existing children
public PathNode withoutChild(Path.Segment child)
child
- the segment of the child that is to be removed; may not be null
public PathNode withoutChildren()
public PathNode 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 PathNode withProperty(Property property)
property
- the property to set
public PathNode withoutProperty(Name propertyName)
propertyName
- the name of the property that is to be removed
public PathNode withoutProperties()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |