|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.util.WebResource
public class WebResource
A WebResource is backed by an URL and potentially the proxy through which it need go. It can get basic information about the resource and it can get the resource. The requests are subject to a timeout, which can be set via the constructor or previously by a call to set the default timeout. The initial default timeout is 750 milliseconds.
for license details.
The copyright to this program is held by it's authors.
Field Summary | |
---|---|
private org.apache.http.client.HttpClient |
client
|
private static int |
timeout
Define a 750 ms timeout to get a connection |
private URI |
uri
|
Constructor Summary | |
---|---|
WebResource(URI theURI)
Construct a WebResource for the given URL, while timing out if too much time has passed. |
|
WebResource(URI theURI,
int theTimeout)
Construct a WebResource for the given URL, while timing out if too much time has passed. |
|
WebResource(URI theURI,
String theProxyHost)
Construct a WebResource for the given URL, going through the optional proxy and default port, while timing out if too much time has passed. |
|
WebResource(URI theURI,
String theProxyHost,
int theTimeout)
Construct a WebResource for the given URL, going through the optional proxy and default port, while timing out if too much time has passed. |
|
WebResource(URI theURI,
String theProxyHost,
Integer theProxyPort)
Construct a WebResource for the given URL, going through the optional proxy and port, while timing out if too much time has passed. |
|
WebResource(URI theURI,
String theProxyHost,
Integer theProxyPort,
int theTimeout)
Construct a WebResource for the given URL, going through the optional proxy and port, while timing out if too much time has passed. |
Method Summary | |
---|---|
void |
copy(URI dest)
Copy this WebResource to the destination. |
void |
copy(URI dest,
Progress meter)
Copy this WebResource to the destination and report progress. |
private long |
getHeaderAsDate(org.apache.http.HttpResponse response,
String field)
Get the number of seconds since start of epoch for the field in the response headers as a Date. |
private int |
getHeaderAsInt(org.apache.http.HttpResponse response,
String field)
Get the field as a long. |
long |
getLastModified()
Determine the last modified date of this WebResource. |
int |
getSize()
Determine the size of this WebResource. |
static int |
getTimeout()
|
static void |
setTimeout(int timeout)
|
void |
shutdown()
When this WebResource is no longer needed it should be shutdown to return underlying resources back to the OS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int timeout
private URI uri
private org.apache.http.client.HttpClient client
Constructor Detail |
---|
public WebResource(URI theURI)
theURI
- the Resource to get via HTTPpublic WebResource(URI theURI, int theTimeout)
theURI
- the Resource to get via HTTPtheTimeout
- the length of time in milliseconds to allow a connection to
respond before timing outpublic WebResource(URI theURI, String theProxyHost)
theURI
- the Resource to get via HTTPtheProxyHost
- the proxy host or nullpublic WebResource(URI theURI, String theProxyHost, int theTimeout)
theURI
- the Resource to get via HTTPtheProxyHost
- the proxy host or nulltheTimeout
- the length of time in milliseconds to allow a connection to
respond before timing outpublic WebResource(URI theURI, String theProxyHost, Integer theProxyPort)
theURI
- the Resource to get via HTTPtheProxyHost
- the proxy host or nulltheProxyPort
- the proxy port or null, where null means use the standard portpublic WebResource(URI theURI, String theProxyHost, Integer theProxyPort, int theTimeout)
theURI
- the Resource to get via HTTPtheProxyHost
- the proxy host or nulltheProxyPort
- the proxy port or null, where null means use the standard porttheTimeout
- the length of time in milliseconds to allow a connection to
respond before timing outMethod Detail |
---|
public void shutdown()
public static int getTimeout()
public static void setTimeout(int timeout)
timeout
- the timeout to set in millisecondspublic int getSize()
Note that the http client may read the entire file to determine this.
public long getLastModified()
Note that the http client may read the entire file.
public void copy(URI dest, Progress meter) throws LucidException
dest
- the URI of the destination, typically a file:///.meter
- the job on which to report progress
LucidException
public void copy(URI dest) throws LucidException
dest
-
LucidException
private int getHeaderAsInt(org.apache.http.HttpResponse response, String field)
response
- The response from the requestfield
- the header field to check
private long getHeaderAsDate(org.apache.http.HttpResponse response, String field)
response
- The response from the requestfield
- the header field to check
|
Copyright ? 2003-2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |