java.io.Closeable, java.lang.AutoCloseable, org.apache.http.HttpEntity, HttpAsyncContentProducer, ProducingNHttpEntitypublic class NStringEntity extends org.apache.http.entity.AbstractHttpEntity implements HttpAsyncContentProducer, ProducingNHttpEntity
String object.| Modifier and Type | Field | Description |
|---|---|---|
protected java.nio.ByteBuffer |
buffer |
Deprecated.
(4.2)
|
protected byte[] |
content |
Deprecated.
(4.2)
|
| Constructor | Description |
|---|---|
NStringEntity(java.lang.String s) |
Creates a NStringEntity with the specified content.
|
NStringEntity(java.lang.String s,
java.lang.String charset) |
Creates a NStringEntity with the specified content and charset.
|
NStringEntity(java.lang.String s,
java.nio.charset.Charset charset) |
Creates a NStringEntity with the specified content and charset.
|
NStringEntity(java.lang.String s,
org.apache.http.entity.ContentType contentType) |
Creates a NStringEntity with the specified content and content type.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
void |
finish() |
Deprecated.
(4.2) use
close() |
java.io.InputStream |
getContent() |
|
long |
getContentLength() |
|
boolean |
isRepeatable() |
Determines whether or not this producer is capable of producing
its content more than once.
|
boolean |
isStreaming() |
|
void |
produceContent(ContentEncoder encoder,
IOControl ioctrl) |
Invoked to write out a chunk of content to the
ContentEncoder. |
void |
writeTo(java.io.OutputStream outstream) |
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType, toString@Deprecated protected final byte[] content
@Deprecated protected final java.nio.ByteBuffer buffer
public NStringEntity(java.lang.String s,
org.apache.http.entity.ContentType contentType)
s - content to be used. Not null.contentType - content type to be used. May be null, in which case
ContentType.TEXT_PLAIN is assumed.java.lang.IllegalArgumentException - if the string parameter is nullpublic NStringEntity(java.lang.String s,
java.lang.String charset)
throws java.io.UnsupportedEncodingException
s - content to be used. Not null.charset - character set to be used. May be null, in which case the default
is HTTP.DEF_CONTENT_CHARSET is assumedjava.lang.IllegalArgumentException - if the string parameter is nulljava.io.UnsupportedEncodingException - Thrown when the named charset is not available in
this instance of the Java virtual machinepublic NStringEntity(java.lang.String s,
java.nio.charset.Charset charset)
s - content to be used. Not null.charset - character set to be used. May be null, in which case the default
is HTTP.DEF_CONTENT_CHARSET is assumedjava.lang.IllegalArgumentException - if the string parameter is nullpublic NStringEntity(java.lang.String s)
throws java.io.UnsupportedEncodingException
ContentType.TEXT_PLAIN.s - content to be used. Not null.java.lang.IllegalArgumentException - if the string parameter is nulljava.io.UnsupportedEncodingException - if the default HTTP charset is not supported.public boolean isRepeatable()
HttpAsyncContentProducerisRepeatable in interface HttpAsyncContentProducerisRepeatable in interface org.apache.http.HttpEntitypublic long getContentLength()
getContentLength in interface org.apache.http.HttpEntitypublic void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeable@Deprecated public void finish()
close()finish in interface ProducingNHttpEntitypublic void produceContent(ContentEncoder encoder, IOControl ioctrl) throws java.io.IOException
HttpAsyncContentProducerContentEncoder.
The IOControl interface can be used to suspend output event
notifications if the entity is temporarily unable to produce more content.
When all content is finished, the producer MUST call
ContentEncoder.complete(). Failure to do so may cause the entity
to be incorrectly delimited.
Please note that the ContentEncoder object is not thread-safe and
should only be used within the context of this method call.
The IOControl object can be shared and used on other thread
to resume output event notifications when more content is made available.
produceContent in interface HttpAsyncContentProducerproduceContent in interface ProducingNHttpEntityencoder - content encoder.ioctrl - I/O control of the underlying connection.java.io.IOExceptionpublic boolean isStreaming()
isStreaming in interface org.apache.http.HttpEntitypublic java.io.InputStream getContent()
getContent in interface org.apache.http.HttpEntitypublic void writeTo(java.io.OutputStream outstream)
throws java.io.IOException
writeTo in interface org.apache.http.HttpEntityjava.io.IOException