public class StringHandle extends BaseHandle<byte[],OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<String>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, QuadsWriteHandle, TriplesReadHandle, TriplesWriteHandle, SPARQLResultsReadHandle
A String Handle represents document content as a string for reading or writing.
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, getServerTimestamp, setByteLength, setFormat, setMimetype, setServerTimestamppublic StringHandle()
Zero-argument constructor.
public StringHandle(String content)
Initializes the handle with a string for the content.
content - a content stringpublic static ContentHandleFactory newFactory()
Creates a factory to create a StringHandle instance for a string.
public String get()
Returns the string for the content.
get in interface ContentHandle<String>public void set(String content)
Assigns an string as the content.
set in interface ContentHandle<String>content - a stringpublic StringHandle with(String content)
Assigns a string as the content and returns the handle as a fluent convenience.
content - a stringpublic StringHandle withFormat(Format format)
Specifies the format of the content and returns the handle as a fluent convenience.
format - the format of the contentpublic StringHandle 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 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.