public class SourceHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<Source>, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
SourceHandle()
Zero-argument constructor.
|
SourceHandle(Source content)
Initializes the handle with a transform source for the content.
|
Modifier and Type | Method and Description |
---|---|
void |
fromBuffer(byte[] buffer)
Sets the content of the handle by copying from a byte array buffer
encoded in UTF-8.
|
Source |
get()
Returns the transform source that produces the content.
|
Transformer |
getTransformer()
Returns a transformer for modifying the content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a SourceHandle instance for a Transformer Source.
|
void |
set(Source content)
Assigns a transform source that produces the content.
|
void |
setFormat(Format format)
Restricts the format to XML.
|
void |
setTransformer(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.
|
String |
toString()
Buffers the transform source and returns the buffer as a string.
|
void |
transform(Result result)
Transforms the source for the content output to the result.
|
SourceHandle |
with(Source content)
Assigns a transform source that produces the content and returns
the handle as a fluent convenience.
|
SourceHandle |
withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
SourceHandle |
withTransformer(Transformer transformer)
Specifies a transformer for modifying 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, setByteLength, setMimetype
public SourceHandle()
public SourceHandle(Source content)
content
- a transform sourcepublic static ContentHandleFactory newFactory()
public Transformer getTransformer()
public void setTransformer(Transformer transformer)
transformer
- the transformerpublic SourceHandle withTransformer(Transformer transformer)
transformer
- the transformerpublic Source get()
get
in interface ContentHandle<Source>
public void set(Source content)
set
in interface ContentHandle<Source>
content
- the transform sourcepublic SourceHandle with(Source content)
content
- the transform sourcepublic void transform(Result result)
result
- the receiver of the transform outputpublic void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<InputStream,OutputStreamSender>
format
- the format of the contentpublic SourceHandle withMimetype(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 String toString()
public void write(OutputStream out) throws IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentIOException
Copyright © 2013-2015 MarkLogic Corporation.