Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.connector.base
Class PathNode

    java.lang.Object
      org.modeshape.graph.connector.base.PathNode

All Implemented Interfaces:
  Serializable, Cloneable, Node

    public class PathNode

extends Object
implements Node, Serializable, Cloneable

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

See Also:
  Serialized Form

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

### changes

    protected transient PathNode.Changes changes

  The changes made to this object, making it unfrozen

Constructor Detail

### PathNode

    public PathNode(UUID uuid,
                    Path parent,
                    Path.Segment name,
                    Map<Name,Property> properties,
                    List<Path.Segment> children)

  Create a new node instance.

  Parameters:
    `uuid` - the UUID of the node; may be null
    `parent` - the path to the parent node; may be null only if the name is null
    `name` - the name of this node, relative to the parent
    `properties` - the unmodifiable map of properties; may be null or empty
    `children` - the unmodifiable list of child segments; may be null or empty

### PathNode

    protected PathNode(UUID uuid,
                       Path parent,
                       Path.Segment name,
                       Map<Name,Property> properties,
                       List<Path.Segment> children,
                       int version)

  Create a new node instance.

  Parameters:
    `uuid` - the UUID of the node; may be null
    `parent` - the path to the parent node; may be null only if the name is null
    `name` - the name of this node, relative to the parent
    `properties` - the unmodifiable map of properties; may be null or empty
    `children` - the unmodifiable list of child segments; may be null or empty
    `version` - the version number

### PathNode

    public PathNode(UUID uuid,
                    Path parent,
                    Path.Segment name,
                    Iterable<Property> properties,
                    List<Path.Segment> children)

  Create a new node instance.

  Parameters:
    `uuid` - the UUID of the node; may be null
    `parent` - the path to the parent node; may be null only if the name is null
    `name` - the name of this node, relative to the parent
    `properties` - the properties that are to be copied into the new node; may be null or empty
    `children` - the unmodifiable list of child segments; may be null or empty

### PathNode

    public PathNode(UUID uuid)

  Create a root node with the supplied UUID.

  Parameters:
    `uuid` - the UUID of the root node; may not be null

Method Detail

### getVersion

    public int getVersion()

  Get the version number of this node.

  Returns:
    the version number

### getUuid

    public UUID getUuid()

  Returns the UUID for this node

  Specified by:
    `getUuid` in interface `Node`
  Returns:
    the UUID for this node
  See Also:
    `Node.getUuid()`

### getName

    public Path.Segment getName()

  Returns the name of this node along with its SNS index within its parent's children

  Specified by:
    `getName` in interface `Node`
  Returns:
    the name of this node along with its SNS index within its parent's children, or null for the root node
  See Also:
    `Node.getName()`

### getParent

    public Path getParent()

  Returns:
    parent

### getProperties

    public Map<Name,Property> getProperties()

  Returns properties of this node.

  Specified by:
    `getProperties` in interface `Node`
  Returns:
    an immutable map of properties keyed by their name.
  See Also:
    `Node.getProperties()`

### getProperty

    public Property getProperty(Name name)

  Returns the property with the supplied name.

  Specified by:
    `getProperty` in interface `Node`
  Parameters:
    `name` - the name of the property
  Returns:
    the property, or null if this node has no such property
  See Also:
    `Node.getProperty(org.modeshape.graph.property.Name)`

### getChildren

    public List<Path.Segment> getChildren()

  Returns:
    children

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

### clone

    public PathNode clone()

  This method never clones the `changes`.

  Overrides:
    `clone` in class `Object`
  See Also:
    `Object.clone()`

### hasChanges

    protected boolean hasChanges()

  Determine if this node has any unsaved changes.

  Returns:
    true if there are unsaved changes, or false otherwise

### newChanges

    protected PathNode.Changes newChanges()

  Create the `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.

  Returns:
    the changes object.

### freeze

    public PathNode freeze()

  Return the frozen node with all internal state reflective of any changes. If this node has no changes, this method simply returns this same node. Otherwise, this method creates a new node that has no changes and that mirrors this node's current state, and this new node will have an incremented `version` number.

  Returns:
    the unfrozen node; never null

### withParent

    public PathNode withParent(Path parent)

  Create a copy of this node except using the supplied path.

  Parameters:
    `parent` - sets parent to the specified value.
  Returns:
    the new path node; never null

### withName

    public PathNode withName(Path.Segment name)

  Create a copy of this node except using the supplied name.

  Parameters:
    `name` - sets name to the specified value.
  Returns:
    the new path node; never null

### withChild

    public PathNode withChild(Path.Segment child)

  Create a copy of this node except adding the supplied node at the end of the existing children.

  Parameters:
    `child` - the segment of the child that is to be added; may not be null
  Returns:
    the new path node; never null

### withChild

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

  Parameters:
    `index` - the index at which the child is to appear
    `child` - the segment of the child that is to be added at the end of the existing children
  Returns:
    the new path node; never null

### withoutChild

    public PathNode withoutChild(Path.Segment child)

  Create a copy of this node except without the supplied child node.

  Parameters:
    `child` - the segment of the child that is to be removed; may not be null
  Returns:
    the new path node; never null

### withoutChildren

    public PathNode withoutChildren()

  Create a copy of this node except with none of the children.

  Returns:
    the new path node; never null

### withProperties

    public PathNode withProperties(Iterable<Property> propertiesToSet,
                                   Iterable<Name> propertiesToRemove,
                                   boolean removeAllExisting)

  Create a copy of this node except with the changes to the properties.

  Parameters:
    `propertiesToSet` - the properties that are to be set; may be null if no properties are to be set
    `propertiesToRemove` - the names of the properties that are to be removed; may be null if no properties are to be removed
    `removeAllExisting` - true if all existing properties should be removed
  Returns:
    the unfrozen path node; never null

### withProperty

    public PathNode withProperty(Property property)

  Create a copy of this node except with the new property.

  Parameters:
    `property` - the property to set
  Returns:
    this path node

### withoutProperty

    public PathNode withoutProperty(Name propertyName)

  Create a copy of this node except without the new property.

  Parameters:
    `propertyName` - the name of the property that is to be removed
  Returns:
    this path node, or this node if the named properties does not exist on this node

### withoutProperties

    public PathNode withoutProperties()

  Create a copy of this node without any properties

  Returns:
    this path node, or this node if this node has no properties

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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