Package net.sf.saxon.event

## Class SequenceCollector

- java.lang.Object
- - net.sf.saxon.event.SequenceReceiver
  - - net.sf.saxon.event.SequenceWriter
    - - net.sf.saxon.event.SequenceCollector

- All Implemented Interfaces:
    `javax.xml.transform.Result`, `Receiver`

      public final class SequenceCollector
      extends SequenceWriter

  This receiver is used when writing a sequence of atomic values and nodes, that is, when xsl:variable is used with content and an "as" attribute. The receiver builds the sequence and provides access to it. Note that the event sequence can include calls such as startElement and endElement that require trees to be built. If nodes such as attributes and text nodes are received while an element is being constructed, the nodes are added to the tree. Otherwise, "orphan" nodes (nodes with no parent) are created and added directly to the sequence.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.event.SequenceReceiver

      `pipelineConfiguration, previousAtomic, systemId`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SequenceCollector​(PipelineConfiguration pipe)` | Create a new SequenceOutputter
    `SequenceCollector​(PipelineConfiguration pipe, int estimatedSize)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static Outputter` | `allocateSequenceOutputter​(XPathContext context, HostLanguage hostLang)` | Allocate a SequenceCollector.
    `Item` | `getFirstItem()` | Get the first item in the sequence that has been built
    `java.util.List<Item>` | `getList()` | Get the list containing the sequence of items
    `Sequence` | `getSequence()` | Get the sequence that has been built
    `SequenceIterator` | `iterate()` | Get an iterator over the sequence of items that has been constructed
    `void` | `reset()` | Clear the contents of the SequenceCollector and make it available for reuse
    `void` | `write​(Item item)` | Method to be supplied by subclasses: output one item in the sequence.

    - ### Methods inherited from class net.sf.saxon.event.SequenceWriter

      `append, characters, close, comment, endDocument, endElement, getTreeModel, processingInstruction, setTreeModel, setUnparsedEntity, startDocument, startElement, usesTypeAnnotations`

    - ### Methods inherited from class net.sf.saxon.event.SequenceReceiver

      `append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, open, setPipelineConfiguration, setSystemId`

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

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

- - ### Constructor Detail

    - #### SequenceCollector

          public SequenceCollector​(PipelineConfiguration pipe)

      Create a new SequenceOutputter
      Parameters:
        `pipe` - the pipeline configuration

    - #### SequenceCollector

          public SequenceCollector​(PipelineConfiguration pipe,
                                   int estimatedSize)

  - ### Method Detail

    - #### allocateSequenceOutputter

          public static Outputter allocateSequenceOutputter​(XPathContext context,
                                                            HostLanguage hostLang)

      Allocate a SequenceCollector. Used from generated bytecode.
      Parameters:
        `context` - dynamic XPath context
        `hostLang` - host language (XSLT/XQuery)
      Returns:
        the allocated SequenceOutputter

    - #### reset

          public void reset()

      Clear the contents of the SequenceCollector and make it available for reuse

    - #### write

          public void write​(Item item)

      Method to be supplied by subclasses: output one item in the sequence.
      Specified by:
        `write` in class `SequenceWriter`
      Parameters:
        `item` - the item to be written to the sequence

    - #### getSequence

          public Sequence getSequence()

      Get the sequence that has been built
      Returns:
        the value (sequence of items) that have been written to this SequenceOutputter

    - #### iterate

          public SequenceIterator iterate()

      Get an iterator over the sequence of items that has been constructed
      Returns:
        an iterator over the items that have been written to this SequenceOutputter

    - #### getList

          public java.util.List<Item> getList()

      Get the list containing the sequence of items
      Returns:
        the list of items that have been written to this SequenceOutputter

    - #### getFirstItem

          public Item getFirstItem()

      Get the first item in the sequence that has been built
      Returns:
        the first item in the list of items that have been written to this SequenceOutputter; or null if the list is empty.