public class

StringPart

extends PartBase
java.lang.Object
   ↳ com.ning.http.multipart.Part
     ↳ com.ning.http.multipart.PartBase
       ↳ com.ning.http.multipart.StringPart

Class Overview

This class is an adaptation of the Apache HttpClient implementationhttp://hc.apache.org/httpclient-3.x/

Summary

Constants
String DEFAULT_CHARSET Default charset of string parameters
String DEFAULT_CONTENT_TYPE Default content encoding of string parameters.
String DEFAULT_TRANSFER_ENCODING Default transfer encoding of string parameters
[Expand]
Inherited Constants
From class com.ning.http.multipart.Part
Public Constructors
StringPart(String name, String value)
Constructor.
StringPart(String name, String value, String charset)
Constructor.
Public Methods
void setCharSet(String charSet)
Sets the character encoding.
Protected Methods
long lengthOfData()
Return the length of the data.
void sendData(OutputStream out)
Writes the data to the given OutputStream.
[Expand]
Inherited Methods
From class com.ning.http.multipart.PartBase
From class com.ning.http.multipart.Part
From class java.lang.Object
From interface com.ning.http.client.Part

Constants

public static final String DEFAULT_CHARSET

Default charset of string parameters

Constant Value: "US-ASCII"

public static final String DEFAULT_CONTENT_TYPE

Default content encoding of string parameters.

Constant Value: "text/plain"

public static final String DEFAULT_TRANSFER_ENCODING

Default transfer encoding of string parameters

Constant Value: "8bit"

Public Constructors

public StringPart (String name, String value)

Constructor.

Parameters
name The name of the part
value the string to post

public StringPart (String name, String value, String charset)

Constructor.

Parameters
name The name of the part
value the string to post
charset the charset to be used to encode the string, if null the default is used

Public Methods

public void setCharSet (String charSet)

Sets the character encoding.

Parameters
charSet the character encoding, or null to exclude the character encoding header

Protected Methods

protected long lengthOfData ()

Return the length of the data.

Returns
  • The length of the data.
Throws
IOException If an IO problem occurs

protected void sendData (OutputStream out)

Writes the data to the given OutputStream.

Parameters
out the OutputStream to write to
Throws
IOException if there is a write error