xsmeral.semnet.crawler.util
Class ConnectionManager

java.lang.Object
  extended by xsmeral.semnet.crawler.util.ConnectionManager

public class ConnectionManager
extends Object

Provides consistent network settings across classes using HttpURLConnections.


Constructor Summary
ConnectionManager()
           
 
Method Summary
static HttpURLConnection getConnection(URL url)
          Returns a HttpUrlConnection set up with the defined settings.
static int getConnTimeout()
          Corresponds to URLConnection.getConnectTimeout()
static InputStream getInputStream(URL url)
          Returns an InputStream to the given URL.
static InputStream getInputStream(URL url, int retries)
          Returns an InputStream to the given URL, possibly retrying the connection.
static InputStream getInputStream(URL url, int retries, String referer)
          Returns an InputStream to the given URL, possibly retrying the connection.
static int getReadTimeout()
          Corresponds to URLConnection.getReadTimeout()
static String getUserAgent()
          Returns the User-agent.
static boolean isFollowRedirects()
          Corresponds to HttpURLConnection.getFollowRedirects()
static void setConnTimeout(int connTimeout)
          Corresponds to URLConnection.setConnectTimeout(int)
static void setFollowRedirects(boolean followRedirects)
          Corresponds to HttpURLConnection.setFollowRedirects(boolean)
static void setReadTimeout(int readTimeout)
          Corresponds to URLConnection.setReadTimeout(int)
static void setUserAgent(String userAgent)
          Same as HttpURLConnection.setRequestProperty("User-Agent", userAgent)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager()
Method Detail

getConnTimeout

public static int getConnTimeout()
Corresponds to URLConnection.getConnectTimeout()


setConnTimeout

public static void setConnTimeout(int connTimeout)
Corresponds to URLConnection.setConnectTimeout(int)


getReadTimeout

public static int getReadTimeout()
Corresponds to URLConnection.getReadTimeout()


setReadTimeout

public static void setReadTimeout(int readTimeout)
Corresponds to URLConnection.setReadTimeout(int)


getUserAgent

public static String getUserAgent()
Returns the User-agent. If it has not been set, returns the default value (not Java default).


setUserAgent

public static void setUserAgent(String userAgent)
Same as HttpURLConnection.setRequestProperty("User-Agent", userAgent)


isFollowRedirects

public static boolean isFollowRedirects()
Corresponds to HttpURLConnection.getFollowRedirects()


setFollowRedirects

public static void setFollowRedirects(boolean followRedirects)
Corresponds to HttpURLConnection.setFollowRedirects(boolean)


getConnection

public static HttpURLConnection getConnection(URL url)
                                       throws IOException
Returns a HttpUrlConnection set up with the defined settings.

Throws:
IOException

getInputStream

public static InputStream getInputStream(URL url,
                                         int retries,
                                         String referer)
                                  throws IOException
Returns an InputStream to the given URL, possibly retrying the connection. Sets the referer field to the given value.

Throws:
IOException

getInputStream

public static InputStream getInputStream(URL url,
                                         int retries)
                                  throws IOException
Returns an InputStream to the given URL, possibly retrying the connection.

Throws:
IOException

getInputStream

public static InputStream getInputStream(URL url)
                                  throws IOException
Returns an InputStream to the given URL.

Throws:
IOException