org.apache.http.entity.mime.content
Class StringBody

java.lang.Object
  extended by org.apache.http.entity.mime.content.AbstractContentBody
      extended by org.apache.http.entity.mime.content.StringBody
All Implemented Interfaces:
ContentBody, ContentDescriptor

public class StringBody
extends AbstractContentBody

Since:
4.0

Constructor Summary
StringBody(String text)
           
StringBody(String text, Charset charset)
           
StringBody(String text, String mimeType, Charset charset)
           
 
Method Summary
static StringBody create(String text)
           
static StringBody create(String text, Charset charset)
           
static StringBody create(String text, String mimeType, Charset charset)
           
 String getCharset()
          The body descriptors character set, defaulted appropriately for the MIME type.
 long getContentLength()
          Returns the body descriptors content-length.
 String getFilename()
           
 Reader getReader()
           
 String getTransferEncoding()
          Returns the body descriptors transfer encoding.
 void writeTo(OutputStream out)
           
 void writeTo(OutputStream out, int mode)
          Deprecated. use writeTo(OutputStream)
 
Methods inherited from class org.apache.http.entity.mime.content.AbstractContentBody
getMediaType, getMimeType, getSubType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringBody

public StringBody(String text,
                  String mimeType,
                  Charset charset)
           throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

StringBody

public StringBody(String text,
                  Charset charset)
           throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

StringBody

public StringBody(String text)
           throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException
Method Detail

create

public static StringBody create(String text,
                                String mimeType,
                                Charset charset)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException
Since:
4.1

create

public static StringBody create(String text,
                                Charset charset)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException
Since:
4.1

create

public static StringBody create(String text)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException
Since:
4.1

getReader

public Reader getReader()

writeTo

@Deprecated
public void writeTo(OutputStream out,
                               int mode)
             throws IOException
Deprecated. use writeTo(OutputStream)

Throws:
IOException

writeTo

public void writeTo(OutputStream out)
             throws IOException
Throws:
IOException

getTransferEncoding

public String getTransferEncoding()
Description copied from interface: ContentDescriptor
Returns the body descriptors transfer encoding.

Returns:
The transfer encoding. Must not be null, but "7bit", if no transfer-encoding was specified.

getCharset

public String getCharset()
Description copied from interface: ContentDescriptor

The body descriptors character set, defaulted appropriately for the MIME type.

For TEXT types, this will be defaulted to us-ascii. For other types, when the charset parameter is missing this property will be null.

Returns:
Character set, which has been parsed from the content-type definition. Not null for TEXT types, when unset will be set to default us-ascii. For other types, when unset, null will be returned.

getContentLength

public long getContentLength()
Description copied from interface: ContentDescriptor
Returns the body descriptors content-length.

Returns:
Content length, if known, or -1, to indicate the absence of a content-length header.

getFilename

public String getFilename()


Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.