org.apache.http.entity
Class BasicHttpEntityHC4

java.lang.Object
  extended by org.apache.http.entity.AbstractHttpEntityHC4
      extended by org.apache.http.entity.BasicHttpEntityHC4
All Implemented Interfaces:
org.apache.http.HttpEntity

@NotThreadSafe
public class BasicHttpEntityHC4
extends AbstractHttpEntityHC4

A generic streamed, non-repeatable entity that obtains its content from an InputStream.

Since:
4.0

Field Summary
 
Fields inherited from class org.apache.http.entity.AbstractHttpEntityHC4
chunked, contentEncoding, contentType, OUTPUT_BUFFER_SIZE
 
Constructor Summary
BasicHttpEntityHC4()
          Creates a new basic entity.
 
Method Summary
 java.io.InputStream getContent()
          Obtains the content, once only.
 long getContentLength()
           
 boolean isRepeatable()
          Tells that this entity is not repeatable.
 boolean isStreaming()
           
 void setContent(java.io.InputStream instream)
          Specifies the content.
 void setContentLength(long len)
          Specifies the length of the content.
 void writeTo(java.io.OutputStream outstream)
           
 
Methods inherited from class org.apache.http.entity.AbstractHttpEntityHC4
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicHttpEntityHC4

public BasicHttpEntityHC4()
Creates a new basic entity. The content is initially missing, the content length is set to a negative number.

Method Detail

getContentLength

public long getContentLength()

getContent

public java.io.InputStream getContent()
                               throws java.lang.IllegalStateException
Obtains the content, once only.

Returns:
the content, if this is the first call to this method since setContent has been called
Throws:
java.lang.IllegalStateException - if the content has not been provided

isRepeatable

public boolean isRepeatable()
Tells that this entity is not repeatable.

Returns:
false

setContentLength

public void setContentLength(long len)
Specifies the length of the content.

Parameters:
len - the number of bytes in the content, or a negative number to indicate an unknown length

setContent

public void setContent(java.io.InputStream instream)
Specifies the content.

Parameters:
instream - the stream to return with the next call to getContent

writeTo

public void writeTo(java.io.OutputStream outstream)
             throws java.io.IOException
Throws:
java.io.IOException

isStreaming

public boolean isStreaming()