public class SourceHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<javax.xml.transform.Source>, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle, java.io.Closeable
A Source Handle represents XML content as a transform source for reading or transforms a source into a result for writing.
Always call close()
when finished with this handle to release the resources.
UNKNOWN_LENGTH
Constructor and Description |
---|
SourceHandle()
Zero-argument constructor.
|
SourceHandle(javax.xml.transform.Source content)
Initializes the handle with a transform source for the content.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Always call close() when finished with this handle -- it closes the underlying InputStream.
|
void |
fromBuffer(byte[] buffer)
Sets the content of the handle by copying from a byte array buffer
encoded in UTF-8.
|
javax.xml.transform.Source |
get()
Returns the transform source that produces the content.
|
javax.xml.transform.Transformer |
getTransformer()
Returns a transformer for modifying the content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a SourceHandle instance for a Transformer Source.
|
protected java.lang.Class<java.io.InputStream> |
receiveAs() |
protected void |
receiveContent(java.io.InputStream content) |
protected OutputStreamSender |
sendContent() |
void |
set(javax.xml.transform.Source content)
Assigns a transform source that produces the content.
|
void |
setFormat(Format format)
Restricts the format to XML.
|
void |
setTransformer(javax.xml.transform.Transformer transformer)
Specifies a transformer for modifying the content.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer
encoded in UTF-8.
|
java.lang.String |
toString()
Buffers the transform source and returns the buffer as a string.
|
void |
transform(javax.xml.transform.Result result)
Transforms the source for the content output to the result.
|
SourceHandle |
with(javax.xml.transform.Source content)
Assigns a transform source that produces the content and returns
the handle as a fluent convenience.
|
SourceHandle |
withMimetype(java.lang.String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
SourceHandle |
withTransformer(javax.xml.transform.Transformer transformer)
Specifies a transformer for modifying the content and returns the handle
as a fluent convenience.
|
void |
write(java.io.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, setServerTimestamp
public SourceHandle()
public SourceHandle(javax.xml.transform.Source content)
content
- a transform sourcepublic static ContentHandleFactory newFactory()
public javax.xml.transform.Transformer getTransformer()
public void setTransformer(javax.xml.transform.Transformer transformer)
transformer
- the transformerpublic SourceHandle withTransformer(javax.xml.transform.Transformer transformer)
transformer
- the transformerpublic javax.xml.transform.Source get()
get
in interface ContentHandle<javax.xml.transform.Source>
public void set(javax.xml.transform.Source content)
set
in interface ContentHandle<javax.xml.transform.Source>
content
- the transform sourcepublic SourceHandle with(javax.xml.transform.Source content)
content
- the transform sourcepublic void transform(javax.xml.transform.Result result)
result
- the receiver of the transform outputpublic void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<java.io.InputStream,OutputStreamSender>
format
- the format of the contentpublic SourceHandle withMimetype(java.lang.String mimetype)
mimetype
- the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandle
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.Class<java.io.InputStream> receiveAs()
receiveAs
in class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected void receiveContent(java.io.InputStream content)
receiveContent
in class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected OutputStreamSender sendContent()
sendContent
in class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
public void write(java.io.OutputStream out) throws java.io.IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentjava.io.IOException
- if io problems arisepublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
Copyright © 2013-2018 MarkLogic Corporation.