ContentDescriptor
,
AbstractReadHandle
,
AbstractWriteHandle
,
BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
,
BufferableHandle
,
ContentHandle<javax.xml.transform.Source>
,
CtsQueryWriteHandle
,
DocumentMetadataReadHandle
,
DocumentMetadataWriteHandle
,
DocumentPatchHandle
,
QueryOptionsListReadHandle
,
QueryOptionsReadHandle
,
QueryOptionsWriteHandle
,
RuleListReadHandle
,
RuleReadHandle
,
RuleWriteHandle
,
SearchReadHandle
,
SPARQLResultsReadHandle
,
StreamingContentHandle<javax.xml.transform.Source,java.io.InputStream>
,
StructureReadHandle
,
StructureWriteHandle
,
TriplesReadHandle
,
TriplesWriteHandle
,
TuplesReadHandle
,
ValuesListReadHandle
,
ValuesReadHandle
,
XMLReadHandle
,
XMLWriteHandle
,
OutputStreamSender
,
java.io.Closeable
,
java.lang.AutoCloseable
public class SourceHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements OutputStreamSender, StreamingContentHandle<javax.xml.transform.Source,java.io.InputStream>, 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 | 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 | Description |
---|---|---|
javax.xml.transform.Source |
bytesToContent(byte[] buffer) |
Converts a byte serialization to the content
representation.
|
void |
close() |
Always call close() when finished with this
handle -- it closes the underlying InputStream.
|
byte[] |
contentToBytes(javax.xml.transform.Source content) |
Converts the content representation to
bytes.
|
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.
|
java.lang.Class<javax.xml.transform.Source> |
getContentClass() |
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
javax.xml.transform.Transformer |
getTransformer() |
Returns a transformer for modifying the
content.
|
javax.xml.transform.Source[] |
newArray(int length) |
Constructs an array for the handled content
representation
|
static ContentHandleFactory |
newFactory() |
Creates a factory to create a SourceHandle
instance for a Transformer Source.
|
SourceHandle |
newHandle() |
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
SourceHandle[] |
newHandleArray(int length) |
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
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.
|
javax.xml.transform.Source |
toContent(java.io.InputStream serialization) |
Converts the serialization to the content
representation.
|
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
newHandle,
resendableHandleFor
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait
resendableHandleFor
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 java.lang.Class<javax.xml.transform.Source> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<javax.xml.transform.Source>
public SourceHandle newHandle()
ContentHandle
newHandle
in interface BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
newHandle
in interface ContentHandle<javax.xml.transform.Source>
public SourceHandle[] newHandleArray(int length)
BufferableContentHandle
newHandleArray
in interface BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
length
- the number of positions in the arraypublic javax.xml.transform.Source[] newArray(int length)
ContentHandle
newArray
in interface ContentHandle<javax.xml.transform.Source>
length
- the size of the array (zero or more)public 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 javax.xml.transform.Source toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
serialization
- a serialization of the
contentpublic javax.xml.transform.Source bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
buffer
- the byte serializationpublic byte[] contentToBytes(javax.xml.transform.Source content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<javax.xml.transform.Source,java.io.InputStream>
content
- the contentpublic 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.lang.AutoCloseable
close
in
interface java.io.Closeable
Copyright © 2022 MarkLogic Corporation