XCC/J 3.2-9

com.marklogic.xcc.types
Interface XdmItem

All Superinterfaces:
XdmValue
All Known Subinterfaces:
ResultItem, XdmAtomic, XdmAttribute, XdmBinary, XdmComment, XdmDocument, XdmElement, XdmNode, XdmProcessingInstruction, XdmText, XDTDayTimeDuration, XDTUntypedAtomic, XDTYearMonthDuration, XSAnyURI, XSBase64Binary, XSBoolean, XSDate, XSDateTime, XSDecimal, XSDouble, XSDuration, XSFloat, XSGDay, XSGMonth, XSGMonthDay, XSGYear, XSGYearMonth, XSHexBinary, XSInteger, XSQName, XSString, XSTime

public interface XdmItem
extends XdmValue

Base class for XQuery item values (values that may be a member of a sequence).


Method Summary
 InputStream asInputStream()
          Return a java.io.InputStream for this item.
 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(OutputStream outputStream)
          Write the value of this item to the provided OutputStream object.
 void writeTo(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

public 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

public 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:
UnsupportedOperationException - If the underlying value object cannot be represented as a character stream.

asInputStream

public 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:
UnsupportedOperationException - If the underlying value object cannot be represented as a byte stream.

writeTo

public void writeTo(Writer writer)
             throws 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:
IOException

writeTo

public void writeTo(OutputStream outputStream)
             throws 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:
IOException

isCached

public 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 ResultSequences. 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.

XCC/J 3.2-9

Copyright © 2003-2008 Mark Logic Corporation, All Rights Reserved.

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