• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
BasicHttpEntity Class Reference

A generic streamed entity being received on a connection. More...

Inheritance diagram for BasicHttpEntity:
AbstractHttpEntity HttpEntity

Description

Author
Oleg Kalnichevski
Version
Revision
496070
Since
4.0

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 BasicHttpEntity ()
 Creates a new basic entity. More...
 
long getContentLength ()
 Tells the length of the content, if known. More...
 
InputStream getContent () throws IllegalStateException
 Obtains the content, once only. More...
 
boolean isRepeatable ()
 Tells that this entity is not repeatable. More...
 
void setContentLength (long len)
 Specifies the length of the content. More...
 
void setContent (final InputStream instream)
 Specifies the content. More...
 
void writeTo (final OutputStream outstream) throws IOException
 Writes the entity content to the output stream. More...
 
boolean isStreaming ()
 Tells whether this entity depends on an underlying stream. More...
 
void consumeContent () throws IOException
 Does not consume anything. More...
 
- Public Member Functions inherited from AbstractHttpEntity
Header getContentType ()
 Obtains the Content-Type header. More...
 
Header getContentEncoding ()
 Obtains the Content-Encoding header. More...
 
boolean isChunked ()
 Obtains the 'chunked' flag. More...
 
void setContentType (final Header contentType)
 Specifies the Content-Type header. More...
 
void setContentType (final String ctString)
 Specifies the Content-Type header, as a string. More...
 
void setContentEncoding (final Header contentEncoding)
 Specifies the Content-Encoding header. More...
 
void setContentEncoding (final String ceString)
 Specifies the Content-Encoding header, as a string. More...
 
void setChunked (boolean b)
 Specifies the 'chunked' flag. More...
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHttpEntity
 AbstractHttpEntity ()
 Protected default constructor. More...
 
- Protected Attributes inherited from AbstractHttpEntity
Header contentType
 The Content-Type header. More...
 
Header contentEncoding
 The Content-Encoding header. More...
 
boolean chunked
 The 'chunked' flag. More...
 

Constructor & Destructor Documentation

◆ BasicHttpEntity()

The content is initially missing, the content length is set to a negative number.

Member Function Documentation

◆ getContentLength()

long getContentLength ( )
Returns
the number of bytes of the content, or a negative number if unknown. If the content length is known but exceeds java.lang.Long.MAX_VALUE, a negative number is returned.

Implements HttpEntity.

◆ getContent()

InputStream getContent ( ) throws IllegalStateException
Returns
the content, if this is the first call to this method since setContent has been called
Exceptions
IllegalStateExceptionif the content has been obtained before, or has not yet been provided

Implements HttpEntity.

◆ isRepeatable()

boolean isRepeatable ( )
Returns
false

Implements HttpEntity.

◆ setContentLength()

void setContentLength ( long  len)
Parameters
lenthe number of bytes in the content, or a negative number to indicate an unknown length

◆ setContent()

void setContent ( final InputStream  instream)
Parameters
instreamthe stream to return with the next call to getContent

◆ writeTo()

void writeTo ( final OutputStream  outstream) throws IOException
Parameters
outstreamthe output stream to write entity content to
Exceptions
IOExceptionif an I/O error occurs

Implements HttpEntity.

◆ isStreaming()

boolean isStreaming ( )

Streamed entities should return true until the content has been consumed, false afterwards. Self-contained entities should return false. Wrapping entities should delegate this call to the wrapped entity.
The content of a streamed entity is consumed when the stream returned by getContent has been read to EOF, or after consumeContent has been called. If a streamed entity can not detect whether the stream has been read to EOF, it should return true until consumeContent is called.

Returns
true if the entity content is streamed and not yet consumed, false otherwise

Implements HttpEntity.

◆ consumeContent()

void consumeContent ( ) throws IOException

The default implementation does nothing if #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.

Exceptions
IOExceptionin case of an I/O problem
UnsupportedOperationExceptionif a streaming subclass does not override this method

Reimplemented from AbstractHttpEntity.