org.jboss.dna.jcr.cache
Class ChildNode

java.lang.Object
  extended by org.jboss.dna.jcr.cache.ChildNode

@Immutable
public final class ChildNode
extends Object

The representation of a child node. This is an immutable representation of a child node within the collection of its siblings as the collection appeared at some point in time. This should be used as a guide to determine how long to hold onto references.

For example, adding and removing children may affect the same-name-sibling index of the children, so these kinds of operations will result in the replacement of old ChildObject instances. Therefore, clients should generally find the ChildNode instances in a Children container, use the ChildNode objects quickly, then discard their references.

There may be times when a client does wish to keep a representation of a ChildNode as it appeared at some moment in time, and so it may want to hold onto references to ChildNode objects for longer durations. This is fine, as long as it is understood that at some point the referenced ChildNode may no longer represent the current state.


Constructor Summary
ChildNode(UUID uuid, Path.Segment segment)
           
 
Method Summary
 boolean equals(Object obj)
          
 Name getName()
          Get the name of the node.
 Path.Segment getSegment()
          Get the path segment for this node.
 int getSnsIndex()
          Get the same-name-sibling index of the node.
 UUID getUuid()
          Get the UUID of the node.
 int hashCode()
          
 String toString()
          
 ChildNode with(Path.Segment newSegment)
          Obtain a new instance that uses the same UUID but the supplied path segment.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChildNode

public ChildNode(UUID uuid,
                 Path.Segment segment)
Method Detail

getUuid

public UUID getUuid()
Get the UUID of the node.

Returns:
the node's UUID; never null

getSegment

public Path.Segment getSegment()
Get the path segment for this node.

Returns:
the path segment; never null

getName

public Name getName()
Get the name of the node.

Returns:
the node's current name; never null

getSnsIndex

public int getSnsIndex()
Get the same-name-sibling index of the node.

Returns:
the node's SNS index; always positive

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

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

with

public ChildNode with(Path.Segment newSegment)
Obtain a new instance that uses the same UUID but the supplied path segment.

Parameters:
newSegment - the new segment; may not be null
Returns:
the new instance; never null


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