public class StringHandle extends BaseHandle<byte[],OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<String>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
StringHandle()
Zero-argument constructor.
|
StringHandle(String content)
Initializes the handle with a string 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.
|
String |
get()
Returns the string for the content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a StringHandle instance for a string.
|
void |
set(String content)
Assigns an string as the content.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer
encoded in UTF-8.
|
String |
toString()
Returns the content.
|
StringHandle |
with(String content)
Assigns a string as the content and returns the handle
as a fluent convenience.
|
StringHandle |
withFormat(Format format)
Specifies the format of the content and returns the handle
as a fluent convenience.
|
StringHandle |
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, setByteLength, setFormat, setMimetype
public StringHandle()
public StringHandle(String content)
content
- a content stringpublic static ContentHandleFactory newFactory()
public String get()
get
in interface ContentHandle<String>
public void set(String content)
set
in interface ContentHandle<String>
content
- a stringpublic StringHandle with(String content)
content
- a stringpublic StringHandle withFormat(Format format)
format
- the format of the contentpublic StringHandle 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 void write(OutputStream out) throws IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentIOException
Copyright © 2013-2015 MarkLogic Corporation.