Package org.apache.http.entity
Class AbstractHttpEntity
java.lang.Object
org.apache.http.entity.AbstractHttpEntity
- All Implemented Interfaces:
HttpEntity
- Direct Known Subclasses:
BasicHttpEntity,ByteArrayEntity,EntityTemplate,FileEntity,InputStreamEntity,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: 496070 $
- Author:
- Oleg Kalnichevski
-
Field Summary
Fields Modifier and Type Field Description protected booleanchunkedThe 'chunked' flag.protected HeadercontentEncodingThe Content-Encoding header.protected HeadercontentTypeThe Content-Type header. -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHttpEntity()Protected default constructor. -
Method Summary
Modifier and Type Method Description voidconsumeContent()Does not consume anything.HeadergetContentEncoding()Obtains the Content-Encoding header.HeadergetContentType()Obtains the Content-Type header.booleanisChunked()Obtains the 'chunked' flag.voidsetChunked(boolean b)Specifies the 'chunked' flag.voidsetContentEncoding(String ceString)Specifies the Content-Encoding header, as a string.voidsetContentEncoding(Header contentEncoding)Specifies the Content-Encoding header.voidsetContentType(String ctString)Specifies the Content-Type header, as a string.voidsetContentType(Header contentType)Specifies the Content-Type header.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.http.HttpEntity
getContent, getContentLength, isRepeatable, isStreaming, writeTo
-
Field Details
-
contentType
The Content-Type header. Returned bygetContentType, unless that method is overridden. -
contentEncoding
The Content-Encoding header. Returned bygetContentEncoding, unless that method is overridden. -
chunked
protected boolean chunkedThe 'chunked' flag. Returned byisChunked, unless that method is overridden.
-
-
Constructor Details
-
AbstractHttpEntity
protected AbstractHttpEntity()Protected default constructor. The attributes of the created object remainnullandfalse, respectively.
-
-
Method Details
-
getContentType
Obtains the Content-Type header. The default implementation returns the value of thecontentTypeattribute.- Specified by:
getContentTypein interfaceHttpEntity- Returns:
- the Content-Type header, or
null
-
getContentEncoding
Obtains the Content-Encoding header. The default implementation returns the value of thecontentEncodingattribute.- Specified by:
getContentEncodingin interfaceHttpEntity- Returns:
- the Content-Encoding header, or
null
-
isChunked
public boolean isChunked()Obtains the 'chunked' flag. The default implementation returns the value of thechunkedattribute.- Specified by:
isChunkedin interfaceHttpEntity- Returns:
- the 'chunked' flag
-
setContentType
Specifies the Content-Type header. The default implementation sets the value of thecontentTypeattribute.- Parameters:
contentType- the new Content-Encoding header, ornullto unset
-
setContentType
Specifies the Content-Type header, as a string. The default implementation callssetContentType(Header).- Parameters:
ctString- the new Content-Type header, ornullto unset
-
setContentEncoding
Specifies the Content-Encoding header. The default implementation sets the value of thecontentEncodingattribute.- Parameters:
contentEncoding- the new Content-Encoding header, ornullto unset
-
setContentEncoding
Specifies the Content-Encoding header, as a string. The default implementation callssetContentEncoding(Header).- Parameters:
ceString- the new Content-Encoding header, ornullto unset
-
setChunked
public void setChunked(boolean b)Specifies the 'chunked' flag. The default implementation sets the value of thechunkedattribute.- Parameters:
b- the new 'chunked' flag
-
consumeContent
Does not consume anything. The default implementation does nothing ifisStreamingreturnsfalse, and throws an exception if it returnstrue. This removes the burden of implementing an empty method for non-streaming entities.- Specified by:
consumeContentin interfaceHttpEntity- Throws:
IOException- in case of an I/O problemUnsupportedOperationException- if a streaming subclass does not override this method
-