org.modeshape.jcr.cache.document

## Class SessionChildReferences

- java.lang.Object
- - org.modeshape.jcr.cache.document.AbstractChildReferences
  - - org.modeshape.jcr.cache.document.SessionChildReferences

- All Implemented Interfaces:
    Iterable<ChildReference>, ChildReferences

      @ThreadSafe
      public class SessionChildReferences
      extends AbstractChildReferences

  A `ChildReferences` implementation that projects a single, changeable view of the child references of a node, allowing child references to be added to the end of the persisted state. This view always reflects the view's changes on top of the current persisted list of child references, even when the persisted state is changed by other sessions.

  For example, consider a node A that has two children, B and C. If a `SessionChildReferences` instance is created for A, then it includes `ChildReference` for nodes B and C. If a new child node, D, is created and appended to the list, the MutableChildReferences object will show three children: B, C and D. Before these changes are saved, however, another client adds to node A a new node, E, and persists those changes. At that instant, the MutableChildReferences will see four children for node A: the persisted children B, C and E, plus the transient node D that has not yet been saved.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.cache.document.AbstractChildReferences

      `AbstractChildReferences.ChildReferenceWithNameIterator`

    - ### Nested classes/interfaces inherited from interface org.modeshape.jcr.cache.ChildReferences

      `ChildReferences.BasicContext, ChildReferences.Changes, ChildReferences.ChildInsertions, ChildReferences.Context, ChildReferences.NoChanges, ChildReferences.NoContext, ChildReferences.NoSnsIndexesContext, ChildReferences.SingleNameContext, ChildReferences.WithChanges`

  - ### Field Summary

    - ### Fields inherited from interface org.modeshape.jcr.cache.ChildReferences

      `UNKNOWN_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionChildReferences(ChildReferences persisted, MutableChildReferences appended, SessionNode.ChangedChildren changedChildren)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Iterator<ChildReference>` | `createIterator(ChildReferences.Context context)`
    `protected Iterator<ChildReference>` | `createIterator(Name name, ChildReferences.Context context)`
    `Iterator<NodeKey>` | `getAllKeys()` Get the keys for all of the children.
    `ChildReference` | `getChild(Name name, int snsIndex, ChildReferences.Context context)` Look for the child reference that has the given name and SNS index.
    `ChildReference` | `getChild(NodeKey key)` Look for the child reference that has the node key.
    `ChildReference` | `getChild(NodeKey key, ChildReferences.Context context)` Look for the child reference that has the node key.
    `int` | `getChildCount(Name name)` Return the number of nodes that have the supplied name.
    `boolean` | `hasChild(NodeKey key)` Determine if this contains a reference to the specified child.
    `Iterator<ChildReference>` | `iterator(ChildReferences.Context context)` Get an iterator over all child references in this collection, but base the SNS indexes upon those already consumed.
    `Iterator<ChildReference>` | `iterator(Name name, ChildReferences.Context context)` Get an iterator over all of the children that have same name matching the supplied value.
    `long` | `size()` Get the total number of child references for the node, including all subsequent blocks of ChildReferences.
    `StringBuilder` | `toString(StringBuilder sb)`

    - ### Methods inherited from class org.modeshape.jcr.cache.document.AbstractChildReferences

      `contextSensitiveIterator, getChild, getChild, getChild, isEmpty, iterator, iterator, iterator, iterator, iterator, supportsGetChildReferenceByKey, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SessionChildReferences

          public SessionChildReferences(ChildReferences persisted,
                                MutableChildReferences appended,
                                SessionNode.ChangedChildren changedChildren)

  - ### Method Detail

    - #### size

          public long size()

      Description copied from interface: `ChildReferences`
      Get the total number of child references for the node, including all subsequent blocks of ChildReferences.
      Returns:
        the total number of children, or `ChildReferences.UNKNOWN_SIZE`

    - #### getChildCount

          public int getChildCount(Name name)

      Description copied from interface: `ChildReferences`
      Return the number of nodes that have the supplied name. If there are no siblings with the same supplied name, this method will return 1; otherwise it will return the number of same-name-siblings.
      Parameters:
        `name` - the name
      Returns:
        the number of siblings with the supplied name; never negative

    - #### getChild

          public ChildReference getChild(Name name,
                                int snsIndex,
                                ChildReferences.Context context)

      Description copied from interface: `ChildReferences`
      Look for the child reference that has the given name and SNS index.
      Parameters:
        `name` - the name for the node
        `snsIndex` - the same-name-sibling index; must be positive
        `context` - the context in which the child should be evaluated; may be null if there is no context
      Returns:
        the child reference, or null if there is no such child

    - #### hasChild

          public boolean hasChild(NodeKey key)

      Description copied from interface: `ChildReferences`
      Determine if this contains a reference to the specified child.
      Parameters:
        `key` - the node key of the child
      Returns:
        true if there is a child reference, or false if there is none

    - #### getChild

          public ChildReference getChild(NodeKey key)

      Description copied from interface: `ChildReferences`
      Look for the child reference that has the node key.
      Parameters:
        `key` - the node key of the child
      Returns:
        the child reference, or null if there is no such child

    - #### getChild

          public ChildReference getChild(NodeKey key,
                                ChildReferences.Context context)

      Description copied from interface: `ChildReferences`
      Look for the child reference that has the node key.
      Parameters:
        `key` - the node key of the child
        `context` - the context in which the child should be evaluated; may be null if there is no context
      Returns:
        the child reference, or null if there is no such child

    - #### iterator

          public Iterator<ChildReference> iterator(Name name,
                                          ChildReferences.Context context)

      Description copied from interface: `ChildReferences`
      Get an iterator over all of the children that have same name matching the supplied value. This essentially returns an iterator over all of the same-name-siblings.
      Specified by:
        `iterator` in interface `ChildReferences`
      Overrides:
        `iterator` in class `AbstractChildReferences`
      Parameters:
        `name` - the name of the same-name-sibling nodes; may not be null
        `context` - the context in which the child should be evaluated; may be null if there is no context
      Returns:
        the iterator; never null

    - #### createIterator

          protected Iterator<ChildReference> createIterator(Name name,
                                                ChildReferences.Context context)

    - #### iterator

          public Iterator<ChildReference> iterator(ChildReferences.Context context)

      Description copied from class: `AbstractChildReferences`
      Get an iterator over all child references in this collection, but base the SNS indexes upon those already consumed.
      Specified by:
        `iterator` in interface `ChildReferences`
      Overrides:
        `iterator` in class `AbstractChildReferences`
      Parameters:
        `context` - the context in which the child should be evaluated; may be null if there is no context
      Returns:
        the iterator over all references; never null

    - #### createIterator

          protected Iterator<ChildReference> createIterator(ChildReferences.Context context)

    - #### getAllKeys

          public Iterator<NodeKey> getAllKeys()

      Description copied from interface: `ChildReferences`
      Get the keys for all of the children. The resulting iterator is lazy where possible, but it may be an expensive call if there are large numbers of children.
      Returns:
        the iterator over the keys; never null

    - #### toString

          public StringBuilder toString(StringBuilder sb)

      Specified by:
        `toString` in class `AbstractChildReferences`

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