org.apache.droids.protocol
Class HttpBase

Package class diagram package HttpBase
java.lang.Object
  extended by org.apache.droids.helper.Loggable
      extended by org.apache.droids.protocol.HttpBase
Direct Known Subclasses:
Http

public class HttpBase
extends Loggable

Helper class that provides basic methods like returning the agent string and content type. Further can be used to prepare the connection.


Field Summary
protected  String from
           
protected  String refer
           
protected  int timeout
           
protected  String userAgent
           
 
Fields inherited from class org.apache.droids.helper.Loggable
log
 
Constructor Summary
HttpBase()
           
 
Method Summary
 String getContentType(String url)
          Will analyze and return the content type of the given url.
 String getFrom()
          Returns the eMail address of the bot.
 String getRefer()
          Return the refer URI where the bot is send from.
 int getTimeout()
          Get the timeout we want for the connection.
 String getUserAgent()
          Get the name of our UserAgent
protected  HttpURLConnection prepareConnection(URL source)
          Will prepare a HttpURLConnection with the userAgent, from, the refer and the timeout
 void setFrom(String from)
          Set the eMail address of the bot.
 void setRefer(String refer)
          Set the refer URI where the bot is send from.
 void setTimeout(int timeout)
          Set the timeout we want for the connection.
 void setUserAgent(String userAgent)
          Set the name of our UserAgent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userAgent

protected String userAgent

timeout

protected int timeout

from

protected String from

refer

protected String refer
Constructor Detail

HttpBase

public HttpBase()
Method Detail

getContentType

public String getContentType(String url)
Will analyze and return the content type of the given url. Will actually open the connection and close it again.

Parameters:
url - the url to determine the content type from.
Returns:
the content type or null if we could not determine it.

prepareConnection

protected HttpURLConnection prepareConnection(URL source)
                                       throws IOException
Will prepare a HttpURLConnection with the userAgent, from, the refer and the timeout

Parameters:
source - the url to reach
Returns:
an opened HttpURLConnection
Make sure you close the connection afterwards again.
Throws:
IOException

getUserAgent

public String getUserAgent()
Get the name of our UserAgent

Returns:
the name of our UserAgent

setUserAgent

public void setUserAgent(String userAgent)
Set the name of our UserAgent

Parameters:
userAgent - the name of our UserAgent

getTimeout

public int getTimeout()
Get the timeout we want for the connection.

Returns:
the timeout we want for the connection.

setTimeout

public void setTimeout(int timeout)
Set the timeout we want for the connection.

Parameters:
timeout - the timeout we want for the connection.

getFrom

public String getFrom()
Returns the eMail address of the bot.

Returns:
eMail address of the bot.

setFrom

public void setFrom(String from)
Set the eMail address of the bot.

Parameters:
from - the eMail address of the bot.

getRefer

public String getRefer()
Return the refer URI where the bot is send from.

Returns:
the refer URI where the bot is send from.

setRefer

public void setRefer(String refer)
Set the refer URI where the bot is send from.

Parameters:
refer - the refer URI where the bot is send from. the refer URI where the bot is send from.


Copyright © 2008 The Apache Software Foundation