org.apache.commons.httpclient.methods

Class StringRequestEntity

Implemented Interfaces:
RequestEntity

public class StringRequestEntity
extends java.lang.Object
implements RequestEntity

A RequestEntity that contains a String.
Since:
3.0

Constructor Summary

StringRequestEntity(String content)
Creates a new entity with the given content.
StringRequestEntity(String content, String contentType, String charset)
Creates a new entity with the given content, content type, and charset.

Method Summary

String
getCharset()
String
getContent()
long
getContentLength()
String
getContentType()
Gets the entity's content type.
boolean
isRepeatable()
void
writeRequest(OutputStream out)
Writes the request entity to the given stream.

Constructor Details

StringRequestEntity

public StringRequestEntity(String content)
Parameters:
content - The content to set.

StringRequestEntity

public StringRequestEntity(String content,
                           String contentType,
                           String charset)
            throws UnsupportedEncodingException
Creates a new entity with the given content, content type, and charset.
Parameters:
content - The content to set.
contentType - The type of the content, or null. The value retured by getContentType(). If this content type contains a charset and the charset parameter is null, the content's type charset will be used.
charset - The charset of the content, or null. Used to convert the content to bytes. If the content type does not contain a charset and charset is not null, then the charset will be appended to the content type.

Method Details

getCharset

public String getCharset()
Returns:
Returns the charset used to convert the content to bytes. null if no charset as been specified.

getContent

public String getContent()
Returns:
Returns the content.

getContentLength

public long getContentLength()
Specified by:
getContentLength in interface RequestEntity
Returns:
The length of the content.

getContentType

public String getContentType()
Gets the entity's content type. This content type will be used as the value for the "Content-Type" header.
Specified by:
getContentType in interface RequestEntity
Returns:
the entity's content type

isRepeatable

public boolean isRepeatable()
Specified by:
isRepeatable in interface RequestEntity
Returns:
true

writeRequest

public void writeRequest(OutputStream out)
            throws IOException
Writes the request entity to the given stream.
Specified by:
writeRequest in interface RequestEntity
Parameters:
out -

Copyright (c) 1999-2005 - Apache Software Foundation