com.marklogic.xcc

## Interface ResultItem

- All Superinterfaces:
    XdmItem, XdmValue

      public interface ResultItem
      extends XdmItem

  An `XdmItem` that is a member of a `ResultSequence`. The values associated with ResultItem instances may be transient. ResultItem wraps an `XdmItem` instance and also implements the `XdmItem` interface. Invoking the methods of the `XdmItem` interface are passed through to the contained instance.

  Because a `ResultSequence` may be streaming, the contained `XdmItem` may be have been partially consumed. Use the `isFetchable()` method to determine if it is safe to access the value.

  See Also:
    `com.marklogic.xcc.types`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cache()` If this item is not already cached, read it fully from the result stream so that it is buffered in memory.
    `java.lang.String` | `getDocumentURI()` Returns the URI of the document represented by this ResultItem, as returned by xdmp:node-uri($node).
    `int` | `getIndex()` The position (zero-based) of this ResultItem in its containing `ResultSequence`.
    `XdmItem` | `getItem()` Returns the actual `XdmItem` value wrapped by this ResultItem.
    `java.lang.String` | `getNodePath()` Returns the path of the node represented by this ResultItem, as returned by xdmp:path($node, false()).
    `boolean` | `isFetchable()` Indicates if the value of this ResultItem may be fetched.

    - ### Methods inherited from interface com.marklogic.xcc.types.XdmItem

      `asInputStream, asReader, getItemType, isCached, writeTo, writeTo`

    - ### Methods inherited from interface com.marklogic.xcc.types.XdmValue

      `asString, getValueType`

- - ### Method Detail

    - #### getDocumentURI

          java.lang.String getDocumentURI()

      Returns the URI of the document represented by this ResultItem, as returned by xdmp:node-uri($node).

      Returns null for non-node items and constructed nodes.

    - #### getNodePath

          java.lang.String getNodePath()

      Returns the path of the node represented by this ResultItem, as returned by xdmp:path($node, false()).

      Returns null for non-node items.

    - #### getItem

          XdmItem getItem()

      Returns the actual `XdmItem` value wrapped by this ResultItem. The instance returned may be tested with `instanceof`.
      Returns:
        an instance of `XdmItem`.

    - #### getIndex

          int getIndex()

      The position (zero-based) of this ResultItem in its containing `ResultSequence`.
      Returns:
        This ResultItem's positional index.

    - #### isFetchable

          boolean isFetchable()

      Indicates if the value of this ResultItem may be fetched. For large values that are streamed, this method will return false after `XdmItem.asInputStream()` or `XdmItem.asReader()` is called.
      Returns:
        true if the XdmItem may be fetched, false if not. This will always be true if isCached() is true. It will also always be true immediately after `ResultSequence.next()` is called and returns this `XdmItem`.

    - #### cache

          void cache()

      If this item is not already cached, read it fully from the result stream so that it is buffered in memory. If the item is already cached, this is a no-op.
      Throws:
        `StreamingResultException` - If an IOException ocurrs reading the result data.

Copyright © 2025 MarkLogic Corporation. All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com