|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.oopitis.weather.URLDataSource<T>
T - the type of the weather datapublic abstract class URLDataSource<T>
A helper class for retrieving weather data from URL-based providers. The
only abstract method in this class to implement is
parse(BufferedReader), which
parses the data streamed from the URL. Notice that this class does not
have public methods because it is not meant to be used with an arbitrary
URL. Typically subclasses provide URL construction methods and data access
interfaces to the public, and use fetch and
setProxy only internally.
| Nested Class Summary | |
|---|---|
static class |
URLDataSource.FetchException
Thrown when an error occurs during fetching data from the a data source. |
| Field Summary | |
|---|---|
protected java.lang.String |
licenseKey
The license key from the constructor. |
| Constructor Summary | |
|---|---|
protected |
URLDataSource(java.lang.String licenseKey)
Constructs a URL data source with a license key. |
| Method Summary | |
|---|---|
protected T |
fetch(java.lang.String urlStr)
Fetches raw data from a URL, parses it and returns the parsed data. |
protected abstract T |
parse(java.io.BufferedReader reader)
Parses the data from a reader and returns the parsed data. |
protected void |
setProxy(java.net.Proxy p)
Sets the proxy to be used with fetch(String). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.lang.String licenseKey
| Constructor Detail |
|---|
protected URLDataSource(java.lang.String licenseKey)
licenseKey - the license key to be used to access the URL;
null if not applicable| Method Detail |
|---|
protected void setProxy(java.net.Proxy p)
fetch(String).
p - the proxy to be used with fetch(String);
null if a direct connection should be usedprotected T fetch(java.lang.String urlStr)
parse(BufferedReader) to read and parse. The proxy, if not
null, is used to open the connection.
urlStr - the URL
URLDataSource.FetchException - if the given URL is malformed or an error
occurs during an I/O operationparse(BufferedReader)protected abstract T parse(java.io.BufferedReader reader)
reader - the reader that supplies the raw data
fetch(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||