net.sf.saxon.om

## Class AbstractItem

- java.lang.Object
- - net.sf.saxon.om.AbstractItem

- All Implemented Interfaces:
    PullEvent, GroundedValue, Item, Sequence
  Direct Known Subclasses:
    AbstractFunctionItem, AtomicValue, ImmutableMap, ObjectValue, SingletonMap

      public abstract class AbstractItem
      extends Object
      implements Item, GroundedValue

  Abstract superclass for items

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractItem()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getLength()` Get the size of the value (the number of items)
    `Item` | `head()` Get the first item in the sequence.
    `Item` | `itemAt(int n)` Get the n'th item in the value, counting from 0
    `SequenceIterator<? extends Item>` | `iterate()` Get an iterator over all the items in the sequence
    `GroundedValue` | `reduce()` Reduce the sequence to its simplest form.
    `GroundedValue` | `subsequence(int start, int length)` Get a subsequence of the value

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

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

    - ### Methods inherited from interface net.sf.saxon.om.Item

      `getStringValue, getStringValueCS`

    - ### Methods inherited from interface net.sf.saxon.om.GroundedValue

      `effectiveBooleanValue, getStringValue, getStringValueCS`

- - ### Constructor Detail

    - #### AbstractItem

          public AbstractItem()

  - ### Method Detail

    - #### itemAt

          public Item itemAt(int n)

      Get the n'th item in the value, counting from 0
      Specified by:
        `itemAt` in interface `GroundedValue`
      Parameters:
        `n` - the index of the required item, with 0 representing the first item in the sequence
      Returns:
        the n'th item if it exists, or null otherwise

    - #### subsequence

          public final GroundedValue subsequence(int start,
                                  int length)

      Get a subsequence of the value
      Specified by:
        `subsequence` in interface `GroundedValue`
      Parameters:
        `start` - the index of the first item to be included in the result, counting from zero. A negative value is taken as zero. If the value is beyond the end of the sequence, an empty sequence is returned
        `length` - the number of items to be included in the result. Specify Integer.MAX_VALUE to get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence is returned. If the value goes off the end of the sequence, the result returns items up to the end of the sequence
      Returns:
        the required subsequence. If min is

    - #### getLength

          public final int getLength()

      Get the size of the value (the number of items)
      Specified by:
        `getLength` in interface `GroundedValue`
      Returns:
        the number of items in the sequence

    - #### head

          public Item head()
                    throws XPathException

      Get the first item in the sequence.
      Specified by:
        `head` in interface `Sequence`
      Returns:
        the first item in the sequence if there is one, or null if the sequence is empty
      Throws:
        `XPathException` - in the situation where the sequence is evaluated lazily, and evaluation of the first item causes a dynamic error.

    - #### iterate

          public SequenceIterator<? extends Item> iterate()
                                                   throws XPathException

      Get an iterator over all the items in the sequence
      Specified by:
        `iterate` in interface `Sequence`
      Returns:
        an iterator over all the items
      Throws:
        `XPathException` - in the situation where the sequence is evaluated lazily, and constructing an iterator over the items causes a dynamic error.

    - #### reduce

          public GroundedValue reduce()

      Reduce the sequence to its simplest form. If the value is an empty sequence, the result will be EmptySequence.getInstance(). If the value is a single atomic value, the result will be an instance of AtomicValue. If the value is a single item of any other kind, the result will be an instance of SingletonItem. Otherwise, the result will typically be unchanged.
      Specified by:
        `reduce` in interface `GroundedValue`
      Returns:
        the simplified sequence

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.