com.ning.http.multipart
Class StringPart

java.lang.Object
  extended by com.ning.http.multipart.Part
      extended by com.ning.http.multipart.PartBase
          extended by com.ning.http.multipart.StringPart
All Implemented Interfaces:
Part

public class StringPart
extends PartBase

This class is an adaptation of the Apache HttpClient implementation


Field Summary
static String DEFAULT_CHARSET
          Default charset of string parameters
static String DEFAULT_CONTENT_TYPE
          Default content encoding of string parameters.
static String DEFAULT_TRANSFER_ENCODING
          Default transfer encoding of string parameters
 
Fields inherited from class com.ning.http.multipart.Part
BOUNDARY, CHARSET, CONTENT_DISPOSITION, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, CRLF, EXTRA, QUOTE
 
Constructor Summary
StringPart(String name, String value)
          Constructor.
StringPart(String name, String value, String charset)
          Constructor.
 
Method Summary
protected  long lengthOfData()
          Return the length of the data.
protected  void sendData(OutputStream out)
          Writes the data to the given OutputStream.
 void setCharSet(String charSet)
          Sets the character encoding.
 
Methods inherited from class com.ning.http.multipart.PartBase
getCharSet, getContentType, getName, getTransferEncoding, setContentType, setName, setTransferEncoding
 
Methods inherited from class com.ning.http.multipart.Part
getBoundary, getLengthOfParts, getLengthOfParts, getPartBoundary, isRepeatable, length, send, sendContentTypeHeader, sendDispositionHeader, sendEnd, sendEndOfHeader, sendMessageEnd, sendPart, sendParts, sendParts, sendStart, sendTransferEncodingHeader, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CONTENT_TYPE

public static final String DEFAULT_CONTENT_TYPE
Default content encoding of string parameters.

See Also:
Constant Field Values

DEFAULT_CHARSET

public static final String DEFAULT_CHARSET
Default charset of string parameters

See Also:
Constant Field Values

DEFAULT_TRANSFER_ENCODING

public static final String DEFAULT_TRANSFER_ENCODING
Default transfer encoding of string parameters

See Also:
Constant Field Values
Constructor Detail

StringPart

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

StringPart

public StringPart(String name,
                  String value)
Constructor.

Parameters:
name - The name of the part
value - the string to post
Method Detail

sendData

protected void sendData(OutputStream out)
                 throws IOException
Writes the data to the given OutputStream.

Specified by:
sendData in class Part
Parameters:
out - the OutputStream to write to
Throws:
IOException - if there is a write error

lengthOfData

protected long lengthOfData()
                     throws IOException
Return the length of the data.

Specified by:
lengthOfData in class Part
Returns:
The length of the data.
Throws:
IOException - If an IO problem occurs

setCharSet

public void setCharSet(String charSet)
Description copied from class: PartBase
Sets the character encoding.

Overrides:
setCharSet in class PartBase
Parameters:
charSet - the character encoding, or null to exclude the character encoding header


Copyright © 2011. All Rights Reserved.