org.jboss.dna.jcr.cache
Class ImmutableChildren

java.lang.Object
  extended by org.jboss.dna.jcr.cache.ImmutableChildren
All Implemented Interfaces:
Iterable<ChildNode>, Children
Direct Known Subclasses:
ChangedChildren

@Immutable
public class ImmutableChildren
extends Object
implements Children

An immutable implementation of Children.


Constructor Summary
ImmutableChildren(UUID parentUuid)
           
ImmutableChildren(UUID parentUuid, Iterable<Location> children)
           
 
Method Summary
 ChildNode getChild(Path.Segment segment)
          Get the child given the path segment.
 ChildNode getChild(UUID uuid)
          Get the child with the given UUID.
 Iterator<ChildNode> getChildren(Name name)
          Get the same-name-sibling children that all share the supplied name, in order of increasing SNS index.
 int getCountOfSameNameSiblingsWithName(Name name)
          Get the number of same-name-siblings that all share the supplied name.
 UUID getParentUuid()
          The UUID of the parent node.
 Iterator<ChildNode> iterator()
          
 int size()
          Get the number of children.
 String toString()
          
 ChangedChildren with(Name newChildName, UUID newChildUuid, PathFactory pathFactory)
          Create another Children object that is equivalent to this node but with the supplied child added.
 ChangedChildren without(UUID childUuid, PathFactory pathFactory)
          Create another Children object that is equivalent to this node but without the supplied child.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImmutableChildren

public ImmutableChildren(UUID parentUuid,
                         Iterable<Location> children)

ImmutableChildren

public ImmutableChildren(UUID parentUuid)
Method Detail

size

public int size()
Get the number of children.

Specified by:
size in interface Children
Returns:
the number of children
See Also:
Children.size()

iterator

public Iterator<ChildNode> iterator()

Specified by:
iterator in interface Iterable<ChildNode>
See Also:
Iterable.iterator()

getParentUuid

public UUID getParentUuid()
The UUID of the parent node.

Specified by:
getParentUuid in interface Children
Returns:
the parent node's UUID
See Also:
Children.getParentUuid()

getChild

public ChildNode getChild(UUID uuid)
Get the child with the given UUID.

Specified by:
getChild in interface Children
Parameters:
uuid - the UUID of the child node
Returns:
the child node, or null if there is no child with the supplied UUID
See Also:
Children.getChild(java.util.UUID)

getChild

public ChildNode getChild(Path.Segment segment)
Get the child given the path segment.

Specified by:
getChild in interface Children
Parameters:
segment - the path segment for the child, which includes the name and one-based same-name-sibling index; may not be null
Returns:
the information for the child node, or null if no such child existed
See Also:
Children.getChild(org.jboss.dna.graph.property.Path.Segment)

getChildren

public Iterator<ChildNode> getChildren(Name name)
Get the same-name-sibling children that all share the supplied name, in order of increasing SNS index.

Specified by:
getChildren in interface Children
Parameters:
name - the name for the children; may not be null
Returns:
the children with the supplied name; never null
See Also:
Children.getChildren(org.jboss.dna.graph.property.Name)

getCountOfSameNameSiblingsWithName

public int getCountOfSameNameSiblingsWithName(Name name)
Get the number of same-name-siblings that all share the supplied name.

Specified by:
getCountOfSameNameSiblingsWithName in interface Children
Parameters:
name - the name for the children; may not be null
Returns:
the number of same-name-siblings with the supplied name
See Also:
Children.getCountOfSameNameSiblingsWithName(org.jboss.dna.graph.property.Name)

with

public ChangedChildren with(Name newChildName,
                            UUID newChildUuid,
                            PathFactory pathFactory)
Create another Children object that is equivalent to this node but with the supplied child added.

Parameters:
newChildName - the name of the new child; may not be null
newChildUuid - the UUID of the new child; may not be null
pathFactory - the factory that can be used to create Path and/or Path.Segment instances.
Returns:
the new Children object; never null
See Also:
InternalChildren.with(org.jboss.dna.graph.property.Name, java.util.UUID, org.jboss.dna.graph.property.PathFactory)

without

public ChangedChildren without(UUID childUuid,
                               PathFactory pathFactory)
Create another Children object that is equivalent to this node but without the supplied child.

Parameters:
childUuid - the UUID of the child to be removed; may not be null
pathFactory - the factory that can be used to create Path and/or Path.Segment instances.
Returns:
the new Children object; never null
See Also:
InternalChildren.without(java.util.UUID, org.jboss.dna.graph.property.PathFactory)

toString

public String toString()

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


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