public class XMLStreamReaderHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<XMLStreamReader>, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, Closeable
UNKNOWN_LENGTH| Constructor and Description |
|---|
XMLStreamReaderHandle()
Zero-argument constructor.
|
XMLStreamReaderHandle(XMLStreamReader content)
Initializes the handle with a StAX stream reader for the content.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the XMLStreamReader and the InputStream, if any, used to populate the XMLStreamReader.
|
void |
fromBuffer(byte[] buffer)
Sets the content of the handle by copying from a byte array buffer encoded in UTF-8.
|
XMLStreamReader |
get()
Returns an XML Stream Reader for for reading a resource from the database as a StAX pull stream.
|
XMLInputFactory |
getFactory()
Returns the factory for parsing StAX streams.
|
XMLResolver |
getResolver()
Returns the resolver for resolving references while parsing the event reader source.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create an XMLStreamReaderHandle instance for a StAX stream reader.
|
void |
set(XMLStreamReader content)
Assigns the stream reader for the content.
|
void |
setFactory(XMLInputFactory factory)
Specifies the factory for parsing StAX streams.
|
void |
setFormat(Format format)
Restricts the format to XML.
|
void |
setResolver(XMLResolver resolver)
Specifies the resolver for resolving references while parsing the event reader source.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer encoded in UTF-8.
|
String |
toString()
Buffers the StAX stream and returns the buffer as an XML string.
|
XMLStreamReaderHandle |
with(XMLStreamReader content)
Assigns an stream reader for the content and returns the handle as a fluent convenience.
|
XMLStreamReaderHandle |
withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle as a fluent convenience.
|
void |
write(OutputStream out)
Implements a callback to write content to the provided output stream for sending to the database server.
|
getByteLength, getFormat, getMimetype, getServerTimestamp, setByteLength, setMimetype, setServerTimestamppublic XMLStreamReaderHandle()
Zero-argument constructor.
public XMLStreamReaderHandle(XMLStreamReader content)
Initializes the handle with a StAX stream reader for the content.
content - a StAX stream readerpublic static ContentHandleFactory newFactory()
Creates a factory to create an XMLStreamReaderHandle instance for a StAX stream reader.
public XMLResolver getResolver()
Returns the resolver for resolving references while parsing the event reader source.
public void setResolver(XMLResolver resolver)
Specifies the resolver for resolving references while parsing the event reader source.
resolver - the reference resolverpublic XMLStreamReader get()
Returns an XML Stream Reader for for reading a resource from the database as a StAX pull stream.
When finished with the stream reader, call close() to release the response.
get in interface ContentHandle<XMLStreamReader>public void set(XMLStreamReader content)
Assigns the stream reader for the content.
set in interface ContentHandle<XMLStreamReader>content - a StAX stream readerpublic XMLStreamReaderHandle with(XMLStreamReader content)
Assigns an stream reader for the content and returns the handle as a fluent convenience.
content - a StAX stream readerpublic void setFormat(Format format)
Restricts the format to XML.
setFormat in interface ContentDescriptorsetFormat in class BaseHandle<InputStream,OutputStreamSender>format - the format of the contentpublic XMLStreamReaderHandle withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle as a fluent convenience.
mimetype - the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandleSets the content of the handle by copying from a byte array buffer encoded in UTF-8.
fromBuffer in interface BufferableHandlebuffer - the byte arraypublic byte[] toBuffer()
BufferableHandleCopies the content of the handle to a byte array buffer encoded in UTF-8.
toBuffer in interface BufferableHandlepublic void close()
Closes the XMLStreamReader and the InputStream, if any, used to populate the XMLStreamReader. This method or get().close() should always be called when finished with the stream reader.
close in interface Closeableclose in interface AutoCloseablepublic String toString()
Buffers the StAX stream and returns the buffer as an XML string.
public XMLInputFactory getFactory()
Returns the factory for parsing StAX streams.
public void setFactory(XMLInputFactory factory)
Specifies the factory for parsing StAX streams.
factory - the StAX factorypublic void write(OutputStream out) throws IOException
OutputStreamSenderImplements a callback to write content to the provided output stream for sending to the database server.
write in interface OutputStreamSenderout - the output stream receiving the contentIOException - if io problems ariseCopyright © 2013-2017 MarkLogic Corporation.