|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectno.sesat.search.http.HTTPClient
public final class HTTPClient
Utility class to fetch URLs and return them as either BufferedReaders or XML documents. Keeps statistics on connection times and failures. XXX redesign into multiple classes with less static methods.
Supports protocols http, https, ftp, jar, and file. If no protocol is specified in the host it defaults to http. Provides support for URL Jars loaded with request properties as Sun's JVM does not. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6270774
| Method Summary | |
|---|---|
static void |
addConnectionStatistic(URLConnection conn,
long time)
|
boolean |
exists(String path)
|
BufferedReader |
getBufferedReader(String path)
|
BufferedReader |
getBufferedReader(String path,
String encoding)
|
BufferedInputStream |
getBufferedStream(String path)
|
long |
getLastModified(String path)
|
Document |
getXmlDocument(String path)
|
static HTTPClient |
instance(String host,
int port)
Returns client for specified host and port for HTTP protocol. |
static HTTPClient |
instance(String host,
int port,
String physicalHost)
Returns client for specified host, port and physical host (if the host is virtual). |
static HTTPClient |
instance(URL url)
Returns client instance for the specified URL. |
static HTTPClient |
instance(URL url,
String physicalHost)
Returns client instance for the specified URL and physical host. |
IOException |
interceptIOException(IOException ioe)
|
static IOException |
interceptIOException(URLConnection conn,
IOException ioe)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static HTTPClient instance(String host,
int port)
host - The host to use. If no protocol is given then http is assumed.port - The port to use.
public static HTTPClient instance(String host,
int port,
String physicalHost)
host - the physical host to use.port - the port to use.physicalHost - virtual host to use.
public static HTTPClient instance(URL url)
getBufferedStream(String path).
url - The URL.
public static HTTPClient instance(URL url,
String physicalHost)
url - The url.physicalHost - The physical host.
public Document getXmlDocument(String path)
throws IOException,
SAXException
path -
IOException
SAXException
public BufferedInputStream getBufferedStream(String path)
throws IOException
path -
IOException
public BufferedReader getBufferedReader(String path)
throws IOException
path -
IOException
public BufferedReader getBufferedReader(String path,
String encoding)
throws IOException
path - encoding -
IOException
public long getLastModified(String path)
throws IOException
path -
IOException
public boolean exists(String path)
throws IOException
path -
IOExceptionpublic IOException interceptIOException(IOException ioe)
ioe -
public static IOException interceptIOException(URLConnection conn,
IOException ioe)
conn - ioe -
public static void addConnectionStatistic(URLConnection conn,
long time)
conn - time -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||