public abstract class OsmServerReader extends OsmConnection
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
OsmServerReader.DomParser<R>
DOM document parser.
|
OsmConnection.OAuthAccessTokenFetcher| Modifier and Type | Field and Description |
|---|---|
private OsmApi |
api |
protected java.lang.String |
contentType |
private boolean |
doAuthenticate |
protected boolean |
gpxParsedProperly |
activeConnection, cancel, fetcher, oauthParameters| Constructor and Description |
|---|
OsmServerReader()
Constructs a new
OsmServerReader. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
adaptRequest(HttpClient request)
Allows subclasses to modify the request.
|
<T> T |
fetchData(java.lang.String api,
java.lang.String subtask,
OsmServerReader.DomParser<T> parser,
ProgressMonitor monitor,
java.lang.String reason)
Fetches generic data from the DOM document resulting an API call.
|
private static java.lang.String |
fetchResponseText(HttpClient.Response response) |
protected static java.lang.String |
getAttribute(org.w3c.dom.Node node,
java.lang.String name)
Returns an attribute from the given DOM node.
|
protected java.lang.String |
getBaseUrl()
Return the base URL for relative URL requests
|
protected java.io.InputStream |
getInputStream(java.lang.String urlStr,
ProgressMonitor progressMonitor)
Open a connection to the given url and return a reader on the input stream
from that connection.
|
protected java.io.InputStream |
getInputStream(java.lang.String urlStr,
ProgressMonitor progressMonitor,
java.lang.String reason)
Open a connection to the given url and return a reader on the input stream
from that connection.
|
protected java.io.InputStream |
getInputStreamRaw(java.lang.String urlStr,
ProgressMonitor progressMonitor)
Open a connection to the given url and return a reader on the input stream
from that connection.
|
protected java.io.InputStream |
getInputStreamRaw(java.lang.String urlStr,
ProgressMonitor progressMonitor,
java.lang.String reason)
Open a connection to the given url and return a reader on the input stream
from that connection.
|
protected java.io.InputStream |
getInputStreamRaw(java.lang.String urlStr,
ProgressMonitor progressMonitor,
java.lang.String reason,
boolean uncompressAccordingToContentDisposition)
Open a connection to the given url (if HTTP, trough a GET request) and return a reader on the input stream
from that connection.
|
protected java.io.InputStream |
getInputStreamRaw(java.lang.String urlStr,
ProgressMonitor progressMonitor,
java.lang.String reason,
boolean uncompressAccordingToContentDisposition,
java.lang.String httpMethod,
byte[] requestBody)
Open a connection to the given url (if HTTP, with the specified method) and return a reader on the input stream
from that connection.
|
boolean |
isDoAuthenticate()
Returns true if this reader is adding authentication credentials to the read
request sent to the server.
|
boolean |
isGpxParsedProperly()
Determines if the GPX data has been parsed properly.
|
java.util.List<Note> |
parseNotes(int noteLimit,
int daysClosed,
ProgressMonitor progressMonitor)
Downloads notes from the API, given API limit parameters
|
abstract DataSet |
parseOsm(ProgressMonitor progressMonitor)
Download OSM files from somewhere
|
DataSet |
parseOsm(ProgressMonitor progressMonitor,
Compression compression)
Download compressed OSM files from somewhere
|
DataSet |
parseOsmChange(ProgressMonitor progressMonitor)
Download OSM Change uncompressed files from somewhere
|
DataSet |
parseOsmChange(ProgressMonitor progressMonitor,
Compression compression)
Download OSM Change compressed files from somewhere
|
GpxData |
parseRawGps(ProgressMonitor progressMonitor)
Retrieve raw gps waypoints from the server API.
|
GpxData |
parseRawGps(ProgressMonitor progressMonitor,
Compression compression)
Retrieve compressed GPX files from somewhere.
|
java.util.List<Note> |
parseRawNotes(ProgressMonitor progressMonitor)
Downloads notes from a given raw URL.
|
java.util.List<Note> |
parseRawNotes(ProgressMonitor progressMonitor,
Compression compression)
Download notes from a URL that contains a compressed notes dump file
|
void |
setDoAuthenticate(boolean doAuthenticate)
Sets whether this reader adds authentication credentials to the read
request sent to the server.
|
addAuth, addBasicAuthorizationHeader, addOAuthAuthorizationHeader, cancel, isCanceled, obtainAccessToken, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcherprivate boolean doAuthenticate
protected boolean gpxParsedProperly
protected java.lang.String contentType
public OsmServerReader()
OsmServerReader.protected java.io.InputStream getInputStream(java.lang.String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException
null.
Relative URL's are directed to API base URL.urlStr - The url to connect to.progressMonitor - progress monitoring and abort handlernull.OsmTransferException - if data transfer errors occurprotected java.io.InputStream getInputStream(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.String reason) throws OsmTransferException
null.
Relative URL's are directed to API base URL.urlStr - The url to connect to.progressMonitor - progress monitoring and abort handlerreason - The reason to show on console. Can be null if no reason is givennull.OsmTransferException - if data transfer errors occurprotected java.lang.String getBaseUrl()
protected java.io.InputStream getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException
null.urlStr - The exact url to connect to.progressMonitor - progress monitoring and abort handlernull.OsmTransferException - if data transfer errors occurprotected java.io.InputStream getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.String reason) throws OsmTransferException
null.urlStr - The exact url to connect to.progressMonitor - progress monitoring and abort handlerreason - The reason to show on console. Can be null if no reason is givennull.OsmTransferException - if data transfer errors occurprotected java.io.InputStream getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.String reason, boolean uncompressAccordingToContentDisposition) throws OsmTransferException
null.urlStr - The exact url to connect to.progressMonitor - progress monitoring and abort handlerreason - The reason to show on console. Can be null if no reason is givenuncompressAccordingToContentDisposition - Whether to inspect the HTTP header Content-Disposition
for filename and uncompress a gzip/bzip2/xz/zip stream.null.OsmTransferException - if data transfer errors occurprotected java.io.InputStream getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.String reason, boolean uncompressAccordingToContentDisposition, java.lang.String httpMethod, byte[] requestBody) throws OsmTransferException
null.urlStr - The exact url to connect to.progressMonitor - progress monitoring and abort handlerreason - The reason to show on console. Can be null if no reason is givenuncompressAccordingToContentDisposition - Whether to inspect the HTTP header Content-Disposition
for filename and uncompress a gzip/bzip2/xz/zip stream.httpMethod - HTTP method ("GET", "POST" or "PUT")requestBody - HTTP request body (for "POST" and "PUT" methods only). Must be null for "GET" method.null.OsmTransferException - if data transfer errors occurprivate static java.lang.String fetchResponseText(HttpClient.Response response)
protected void adaptRequest(HttpClient request)
request - the prepared requestpublic abstract DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
progressMonitor - The progress monitorOsmTransferException - if any error occurspublic DataSet parseOsm(ProgressMonitor progressMonitor, Compression compression) throws OsmTransferException
progressMonitor - The progress monitorcompression - compression to useOsmTransferException - if any error occurspublic DataSet parseOsmChange(ProgressMonitor progressMonitor) throws OsmTransferException
progressMonitor - The progress monitorOsmTransferException - if any error occurspublic DataSet parseOsmChange(ProgressMonitor progressMonitor, Compression compression) throws OsmTransferException
progressMonitor - The progress monitorcompression - compression to useOsmTransferException - if any error occurspublic GpxData parseRawGps(ProgressMonitor progressMonitor) throws OsmTransferException
progressMonitor - The progress monitorOsmTransferException - if any error occurspublic GpxData parseRawGps(ProgressMonitor progressMonitor, Compression compression) throws OsmTransferException
progressMonitor - The progress monitorcompression - compression to useOsmTransferException - if any error occurspublic boolean isDoAuthenticate()
public void setDoAuthenticate(boolean doAuthenticate)
doAuthenticate - true if this reader adds authentication credentials to the read
request sent to the serverpublic final boolean isGpxParsedProperly()
GpxReader.parse(boolean)public java.util.List<Note> parseNotes(int noteLimit, int daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException
noteLimit - How many notes to download.daysClosed - Return notes closed this many days in the past. -1 means all notes, ever. 0 means only unresolved notes.progressMonitor - Progress monitor for user feedbackOsmTransferException - if any errors happenpublic java.util.List<Note> parseRawNotes(ProgressMonitor progressMonitor) throws OsmTransferException
progressMonitor - progress monitorOsmTransferException - if any error occurs during dialog with OSM APIpublic java.util.List<Note> parseRawNotes(ProgressMonitor progressMonitor, Compression compression) throws OsmTransferException
progressMonitor - progress monitorcompression - compression to useOsmTransferException - if any error occurs during dialog with OSM APIprotected static java.lang.String getAttribute(org.w3c.dom.Node node, java.lang.String name)
node - DOM nodename - attribute namepublic <T> T fetchData(java.lang.String api, java.lang.String subtask, OsmServerReader.DomParser<T> parser, ProgressMonitor monitor, java.lang.String reason) throws OsmTransferException
T - data typeapi - the OSM API callsubtask - the subtask translated messageparser - the parser converting the DOM document (OSM API result)monitor - The progress monitorreason - The reason to show on console. Can be null if no reason is givenOsmTransferException - if something goes wrong