com.marklogic.xcc.types

## Interface XdmItem

- All Superinterfaces:
    XdmValue
  All Known Subinterfaces:
    ArrayNode, BooleanNode, CtsBox, CtsCircle, CtsPoint, CtsPolygon, JSArray, JSNull, JSObject, JsonItem, NullNode, NumberNode, ObjectNode, ResultItem, XdmAtomic, XdmAttribute, XdmBinary, XdmComment, XdmDocument, XdmElement, XdmNode, XdmProcessingInstruction, XdmText, XSAnyURI, XSBase64Binary, XSBoolean, XSDate, XSDateTime, XSDayTimeDuration, XSDecimal, XSDouble, XSDuration, XSFloat, XSGDay, XSGMonth, XSGMonthDay, XSGYear, XSGYearMonth, XSHexBinary, XSInteger, XSQName, XSString, XSTime, XSUntypedAtomic, XSYearMonthDuration

      public interface XdmItem
      extends XdmValue

  Interface for item values (values that may be a member of a sequence).

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.io.InputStream` | `asInputStream()` Return a java.io.InputStream for this item.
    `java.io.Reader` | `asReader()` Return a java.io.Reader for this item.
    `ItemType` | `getItemType()` The `ItemType` instance corresponding to the type of this item.
    `boolean` | `isCached()` Indicates whether this item's value is buffered in memory.
    `void` | `writeTo(java.io.OutputStream outputStream)` Write the value of this item to the provided `OutputStream` object.
    `void` | `writeTo(java.io.Writer writer)` Write the value of this item to the provided `Writer` object.

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

      `asString, getValueType`

- - ### Method Detail

    - #### getItemType

          ItemType getItemType()

      The `ItemType` instance corresponding to the type of this item.
      Returns:
        An instance of `ItemType` that represent the XML Schema type of this value.

    - #### asReader

          java.io.Reader asReader()

      Return a java.io.Reader for this item.
      Returns:
        A Reader instance from which this value may be read. For most types, the characters read will be equivalent to those returned by `XdmValue.asString()`.
      Throws:
        `java.lang.UnsupportedOperationException` - If the underlying value object cannot be represented as a character stream.

    - #### asInputStream

          java.io.InputStream asInputStream()

      Return a java.io.InputStream for this item.
      Returns:
        An InputStream instance from which this value may be read as a byte stream. Note that most simple types (xs:integer, xs:duration, etc) may not be represented as a byte stream. For string types (xs:string, xs:QName, etc) the byte stream will be UTF-8 encoded).
      Throws:
        `java.lang.UnsupportedOperationException` - If the underlying value object cannot be represented as a byte stream.

    - #### writeTo

          void writeTo(java.io.Writer writer)
                throws java.io.IOException

      Write the value of this item to the provided `Writer` object. The `Reader` returned by the method `asReader()` will be used as the value source.
      Parameters:
        `writer` - A client-provided, open `Writer` object to which the value will be written. The `Writer` will not be closed by this method.
      Throws:
        `java.io.IOException`

    - #### writeTo

          void writeTo(java.io.OutputStream outputStream)
                throws java.io.IOException

      Write the value of this item to the provided `OutputStream` object. The `InputStream` returned by the method `asInputStream()` will be as the value source.
      Parameters:
        `outputStream` - A Client-provided, open `OutputStream` object to which the value will be written. The `OutputStream` will not be closed by this method.
      Throws:
        `java.io.IOException`

    - #### isCached

          boolean isCached()

      Indicates whether this item's value is buffered in memory. If so it is safe to call any of the accessor methods (`XdmValue.asString()`, `asInputStream()` or `asReader()`) and to call them repeatedly.

      Normally this method will only return false for `ResultItem` instances which are members of a streaming `ResultSequence`s. However, even such instances may be indicate thstt they are cached if, for example, `XdmValue.asString()` is the first method invoked. Doing so will buffer the value which can then be reused for subsequent invocations of `asReader()` or `asInputStream()`.

      Returns:
        true if the value is buffered and may be retrieved repeatedly, false if not.

Copyright © 2025 MarkLogic Corporation

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