org.apache.commons.httpclient.methods
Class ByteArrayRequestEntity

java.lang.Object
  extended by org.apache.commons.httpclient.methods.ByteArrayRequestEntity
All Implemented Interfaces:
RequestEntity

public class ByteArrayRequestEntity
extends Object
implements RequestEntity

A RequestEntity that contains an array of bytes.

Since:
3.0

Constructor Summary
ByteArrayRequestEntity(byte[] content)
          Creates a new entity with the given content.
ByteArrayRequestEntity(byte[] content, String contentType)
          Creates a new entity with the given content and content type.
 
Method Summary
 byte[] getContent()
           
 long getContentLength()
          Gets the request entity's length.
 String getContentType()
          Gets the entity's content type.
 boolean isRepeatable()
          Tests if RequestEntity.writeRequest(OutputStream) can be called more than once.
 void writeRequest(OutputStream out)
          Writes the request entity to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayRequestEntity

public ByteArrayRequestEntity(byte[] content)
Creates a new entity with the given content.

Parameters:
content - The content to set.

ByteArrayRequestEntity

public ByteArrayRequestEntity(byte[] content,
                              String contentType)
Creates a new entity with the given content and content type.

Parameters:
content - The content to set.
contentType - The content type to set or null.
Method Detail

isRepeatable

public boolean isRepeatable()
Description copied from interface: RequestEntity
Tests if RequestEntity.writeRequest(OutputStream) can be called more than once.

Specified by:
isRepeatable in interface RequestEntity
Returns:
true

getContentType

public String getContentType()
Description copied from interface: RequestEntity
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
See Also:
HttpMethod.setRequestHeader(String, String)

writeRequest

public void writeRequest(OutputStream out)
                  throws IOException
Description copied from interface: RequestEntity
Writes the request entity to the given stream.

Specified by:
writeRequest in interface RequestEntity
Throws:
IOException

getContentLength

public long getContentLength()
Description copied from interface: RequestEntity
Gets the request entity's length. This method should return a non-negative value if the content length is known or a negative value if it is not. In the latter case the EntityEnclosingMethod will use chunk encoding to transmit the request entity.

Specified by:
getContentLength in interface RequestEntity
Returns:
The length of the content.

getContent

public byte[] getContent()
Returns:
Returns the content.


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.