org.apache.http.entity
Class AbstractHttpEntity

java.lang.Object
  extended by org.apache.http.entity.AbstractHttpEntity
All Implemented Interfaces:
HttpEntity
Direct Known Subclasses:
BasicHttpEntity, ByteArrayEntity, EntityTemplate, FileEntity, InputStreamEntity, NByteArrayEntity, NFileEntity, NStringEntity, SerializableEntity, StringEntity

public abstract class AbstractHttpEntity
extends Object
implements HttpEntity

Abstract base class for entities. Provides the commonly used attributes for streamed and self-contained implementations of HttpEntity.

Since:
4.0
Version:
$Revision: 744523 $

Field Summary
protected  boolean chunked
           
protected  Header contentEncoding
           
protected  Header contentType
           
 
Constructor Summary
protected AbstractHttpEntity()
          Protected default constructor.
 
Method Summary
 void consumeContent()
          Does not consume anything.
 Header getContentEncoding()
          Obtains the Content-Encoding header.
 Header getContentType()
          Obtains the Content-Type header.
 boolean isChunked()
          Obtains the 'chunked' flag.
 void setChunked(boolean b)
          Specifies the 'chunked' flag.
 void setContentEncoding(Header contentEncoding)
          Specifies the Content-Encoding header.
 void setContentEncoding(String ceString)
          Specifies the Content-Encoding header, as a string.
 void setContentType(Header contentType)
          Specifies the Content-Type header.
 void setContentType(String ctString)
          Specifies the Content-Type header, as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.http.HttpEntity
getContent, getContentLength, isRepeatable, isStreaming, writeTo
 

Field Detail

contentType

protected Header contentType

contentEncoding

protected Header contentEncoding

chunked

protected boolean chunked
Constructor Detail

AbstractHttpEntity

protected AbstractHttpEntity()
Protected default constructor. The attributes of the created object remain null and false, respectively.

Method Detail

getContentType

public Header getContentType()
Obtains the Content-Type header. The default implementation returns the value of the contentType attribute.

Specified by:
getContentType in interface HttpEntity
Returns:
the Content-Type header, or null

getContentEncoding

public Header getContentEncoding()
Obtains the Content-Encoding header. The default implementation returns the value of the contentEncoding attribute.

Specified by:
getContentEncoding in interface HttpEntity
Returns:
the Content-Encoding header, or null

isChunked

public boolean isChunked()
Obtains the 'chunked' flag. The default implementation returns the value of the chunked attribute.

Specified by:
isChunked in interface HttpEntity
Returns:
the 'chunked' flag

setContentType

public void setContentType(Header contentType)
Specifies the Content-Type header. The default implementation sets the value of the contentType attribute.

Parameters:
contentType - the new Content-Encoding header, or null to unset

setContentType

public void setContentType(String ctString)
Specifies the Content-Type header, as a string. The default implementation calls setContentType(Header).

Parameters:
ctString - the new Content-Type header, or null to unset

setContentEncoding

public void setContentEncoding(Header contentEncoding)
Specifies the Content-Encoding header. The default implementation sets the value of the contentEncoding attribute.

Parameters:
contentEncoding - the new Content-Encoding header, or null to unset

setContentEncoding

public void setContentEncoding(String ceString)
Specifies the Content-Encoding header, as a string. The default implementation calls setContentEncoding(Header).

Parameters:
ceString - the new Content-Encoding header, or null to unset

setChunked

public void setChunked(boolean b)
Specifies the 'chunked' flag. The default implementation sets the value of the chunked attribute.

Parameters:
b - the new 'chunked' flag

consumeContent

public void consumeContent()
                    throws IOException,
                           UnsupportedOperationException
Does not consume anything. The default implementation does nothing if isStreaming returns false, and throws an exception if it returns true. This removes the burden of implementing an empty method for non-streaming entities.

Specified by:
consumeContent in interface HttpEntity
Throws:
IOException - in case of an I/O problem
UnsupportedOperationException - if a streaming subclass does not override this method


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.