FileDocCategorySizeDatePackage
AbstractHttpEntity.javaAPI DocAndroid 1.5 API6710Wed May 06 22:41:10 BST 2009org.apache.http.entity

AbstractHttpEntity

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 {@link HttpEntity HttpEntity}.
author
Oleg Kalnichevski
version
$Revision: 496070 $
since
4.0

Fields Summary
protected Header
contentType
The Content-Type header. Returned by {@link #getContentType getContentType}, unless that method is overridden.
protected Header
contentEncoding
The Content-Encoding header. Returned by {@link #getContentEncoding getContentEncoding}, unless that method is overridden.
protected boolean
chunked
The 'chunked' flag. Returned by {@link #isChunked isChunked}, unless that method is overridden.
Constructors Summary
protected AbstractHttpEntity()
Protected default constructor. The attributes of the created object remain null and false, respectively.

        super();
    
Methods Summary
public voidconsumeContent()
Does not consume anything. The default implementation does nothing if {@link HttpEntity#isStreaming isStreaming} returns false, and throws an exception if it returns true. This removes the burden of implementing an empty method for non-streaming entities.

throws
IOException in case of an I/O problem
throws
UnsupportedOperationException if a streaming subclass does not override this method

        if (isStreaming()) {
            throw new UnsupportedOperationException
                ("streaming entity does not implement consumeContent()");
        }
    
public org.apache.http.HeadergetContentEncoding()
Obtains the Content-Encoding header. The default implementation returns the value of the {@link #contentEncoding contentEncoding} attribute.

return
the Content-Encoding header, or null

        return this.contentEncoding;
    
public org.apache.http.HeadergetContentType()
Obtains the Content-Type header. The default implementation returns the value of the {@link #contentType contentType} attribute.

return
the Content-Type header, or null

        return this.contentType;
    
public booleanisChunked()
Obtains the 'chunked' flag. The default implementation returns the value of the {@link #chunked chunked} attribute.

return
the 'chunked' flag

        return this.chunked;
    
public voidsetChunked(boolean b)
Specifies the 'chunked' flag. The default implementation sets the value of the {@link #chunked chunked} attribute.

param
b the new 'chunked' flag

        this.chunked = b;
    
public voidsetContentEncoding(org.apache.http.Header contentEncoding)
Specifies the Content-Encoding header. The default implementation sets the value of the {@link #contentEncoding contentEncoding} attribute.

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

        this.contentEncoding = contentEncoding;
    
public voidsetContentEncoding(java.lang.String ceString)
Specifies the Content-Encoding header, as a string. The default implementation calls {@link #setContentEncoding(Header) setContentEncoding(Header)}.

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

        Header h = null;
        if (ceString != null) {
            h = new BasicHeader(HTTP.CONTENT_ENCODING, ceString);
        }
        setContentEncoding(h);
    
public voidsetContentType(org.apache.http.Header contentType)
Specifies the Content-Type header. The default implementation sets the value of the {@link #contentType contentType} attribute.

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

        this.contentType = contentType;
    
public voidsetContentType(java.lang.String ctString)
Specifies the Content-Type header, as a string. The default implementation calls {@link #setContentType(Header) setContentType(Header)}.

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

        Header h = null;
        if (ctString != null) {
            h = new BasicHeader(HTTP.CONTENT_TYPE, ctString);
        }
        setContentType(h);