de.phleisch.app.itsucks.io.http.impl
Class HttpRetriever

java.lang.Object
  extended by de.phleisch.app.itsucks.io.impl.AbstractUrlDataRetriever
      extended by de.phleisch.app.itsucks.io.http.impl.HttpRetriever
All Implemented Interfaces:
DataRetriever, UrlDataRetriever

public class HttpRetriever
extends AbstractUrlDataRetriever

Implementation of an data retriever for the http protocol.

Author:
olli

Field Summary
protected static long DEFAULT_TIME_TO_WAIT_BETWEEN_RETRY
           
protected  boolean mAbort
           
protected  long mBytesToSkip
           
protected  HttpRetrieverConfiguration mConfiguration
           
protected  java.util.List<java.lang.String> mCookieList
           
protected  GetMethod mGet
           
protected  HttpMetadata mMetadata
           
protected  java.net.URL mReferer
           
protected  HttpRetrieverResponseCodeBehaviour mResponseCodeBehaviour
           
protected  int mResultCode
           
protected  long mTimeToWaitBetweenRetry
           
 
Fields inherited from class de.phleisch.app.itsucks.io.impl.AbstractUrlDataRetriever
mUrl
 
Fields inherited from interface de.phleisch.app.itsucks.io.UrlDataRetriever
RESULT_RETRIEVAL_ABORTED, RESULT_RETRIEVAL_FAILED, RESULT_RETRIEVAL_FAILED_BUT_RETRYABLE, RESULT_RETRIEVAL_NOT_STARTED_YET, RESULT_RETRIEVAL_OK, RESULT_RETRIEVAL_UNKNOWN
 
Fields inherited from interface de.phleisch.app.itsucks.io.DataRetriever
NOTIFICATION_PROGRESS
 
Constructor Summary
HttpRetriever(java.net.URL pUrl, HttpRetrieverConfiguration pHttpRetrieverConfiguration)
           
 
Method Summary
 void abort()
          Aborts the current retrieving.
protected  void analyzeResultCode()
           
 void connect()
          Advise the Retriever to connect to the data source.
protected static HttpRetrieverResponseCodeBehaviour createDefaultHttpRetrieverBehaviour()
           
protected  HttpClient createHttpClient(HttpRetrieverConfiguration pConfiguration)
           
 void disconnect()
          Disconnect from the data source.
 long getBytesSkipped()
          Returns the skipped bytes.
 HttpRetrieverConfiguration getConfiguration()
           
 long getContentLenght()
          Returns the content length in bytes.
 java.util.List<java.lang.String> getCookieList()
           
 java.io.InputStream getDataAsInputStream()
          Returns an input stream for the retrieved data.
protected  HttpClient getHttpClientFromConfiguration()
           
 HttpMetadata getMetadata()
          Returns the metadata of the data source connection.
 java.net.URL getReferer()
           
 HttpRetrieverResponseCodeBehaviour getResponseCodeBehaviour()
           
 int getResultCode()
          Returns the internal state and result code after connecting.
 long getSuggestedTimeToWaitForRetry()
          Returns the suggested time to wait befory retry the retrieval in ms.
 boolean isConnected()
          Returns true if the retriever is connected.
 boolean isDataAvailable()
          Returns true if the data source contains any data to be read.
 void setBytesToSkip(long pBytesToSkip)
          Skip the given bytes (seek) when reading the data source.
 void setConfiguration(HttpRetrieverConfiguration pConfiguration)
           
 void setCookieList(java.util.List<java.lang.String> pCookieList)
           
 void setReferer(java.net.URL pReferer)
           
 void setResponseCodeBehaviour(HttpRetrieverResponseCodeBehaviour pResponseCodeBehaviour)
           
 
Methods inherited from class de.phleisch.app.itsucks.io.impl.AbstractUrlDataRetriever
getUrl, setUrl, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TIME_TO_WAIT_BETWEEN_RETRY

protected static final long DEFAULT_TIME_TO_WAIT_BETWEEN_RETRY
See Also:
Constant Field Values

mTimeToWaitBetweenRetry

protected long mTimeToWaitBetweenRetry

mConfiguration

protected HttpRetrieverConfiguration mConfiguration

mResponseCodeBehaviour

protected HttpRetrieverResponseCodeBehaviour mResponseCodeBehaviour

mCookieList

protected java.util.List<java.lang.String> mCookieList

mReferer

protected java.net.URL mReferer

mGet

protected GetMethod mGet

mMetadata

protected HttpMetadata mMetadata

mResultCode

protected int mResultCode

mAbort

protected boolean mAbort

mBytesToSkip

protected long mBytesToSkip
Constructor Detail

HttpRetriever

public HttpRetriever(java.net.URL pUrl,
                     HttpRetrieverConfiguration pHttpRetrieverConfiguration)
Method Detail

connect

public void connect()
             throws java.io.IOException
Description copied from interface: DataRetriever
Advise the Retriever to connect to the data source.

Throws:
java.io.IOException

getHttpClientFromConfiguration

protected HttpClient getHttpClientFromConfiguration()

createHttpClient

protected HttpClient createHttpClient(HttpRetrieverConfiguration pConfiguration)

isDataAvailable

public boolean isDataAvailable()
                        throws java.io.IOException
Description copied from interface: DataRetriever
Returns true if the data source contains any data to be read.

Returns:
Throws:
java.io.IOException

isConnected

public boolean isConnected()
                    throws java.io.IOException
Description copied from interface: DataRetriever
Returns true if the retriever is connected.

Throws:
java.io.IOException

getDataAsInputStream

public java.io.InputStream getDataAsInputStream()
                                         throws java.io.IOException
Description copied from interface: DataRetriever
Returns an input stream for the retrieved data.

Returns:
Throws:
java.io.IOException

disconnect

public void disconnect()
Description copied from interface: DataRetriever
Disconnect from the data source.


getMetadata

public HttpMetadata getMetadata()
Description copied from interface: DataRetriever
Returns the metadata of the data source connection.

Returns:

abort

public void abort()
Description copied from interface: DataRetriever
Aborts the current retrieving.


setBytesToSkip

public void setBytesToSkip(long pBytesToSkip)
Description copied from interface: DataRetriever
Skip the given bytes (seek) when reading the data source.


getBytesSkipped

public long getBytesSkipped()
Description copied from interface: DataRetriever
Returns the skipped bytes.

Returns:

getResultCode

public int getResultCode()
Description copied from interface: UrlDataRetriever
Returns the internal state and result code after connecting. Check RESULT_RETRIEVAL_* constants for possible values.

Returns:

analyzeResultCode

protected void analyzeResultCode()

getSuggestedTimeToWaitForRetry

public long getSuggestedTimeToWaitForRetry()
Description copied from interface: UrlDataRetriever
Returns the suggested time to wait befory retry the retrieval in ms.

Returns:

getContentLenght

public long getContentLenght()
Description copied from interface: DataRetriever
Returns the content length in bytes.

Returns:

getConfiguration

public HttpRetrieverConfiguration getConfiguration()

setConfiguration

public void setConfiguration(HttpRetrieverConfiguration pConfiguration)

getResponseCodeBehaviour

public HttpRetrieverResponseCodeBehaviour getResponseCodeBehaviour()

setResponseCodeBehaviour

public void setResponseCodeBehaviour(HttpRetrieverResponseCodeBehaviour pResponseCodeBehaviour)

createDefaultHttpRetrieverBehaviour

protected static HttpRetrieverResponseCodeBehaviour createDefaultHttpRetrieverBehaviour()

getCookieList

public java.util.List<java.lang.String> getCookieList()

setCookieList

public void setCookieList(java.util.List<java.lang.String> pCookieList)

getReferer

public java.net.URL getReferer()

setReferer

public void setReferer(java.net.URL pReferer)


Copyright © 2010. All Rights Reserved.