Package org.openstreetmap.josm.io
Class MultiFetchServerObjectReader.Fetcher
- java.lang.Object
-
- org.openstreetmap.josm.io.OsmConnection
-
- org.openstreetmap.josm.io.OsmServerReader
-
- org.openstreetmap.josm.io.MultiFetchServerObjectReader.Fetcher
-
- All Implemented Interfaces:
java.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>
- Enclosing class:
- MultiFetchServerObjectReader
protected class MultiFetchServerObjectReader.Fetcher extends OsmServerReader implements java.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>
The class that actually download data from OSM API. Several instances of this class are used byMultiFetchServerObjectReader(one per set of primitives to fetch). The inheritance ofOsmServerReaderis only explained by the need to have a distinct OSM connection byFetcherinstance.- See Also:
MultiFetchServerObjectReader.FetchResult
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmServerReader
OsmServerReader.DomParser<R>
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmConnection
OsmConnection.OAuthAccessTokenFetcher
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.Long>pkgprivate ProgressMonitorprogressMonitorprivate OsmPrimitiveTypetype-
Fields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperly
-
Fields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, fetcher, oAuth20Parameters
-
-
Constructor Summary
Constructors Constructor Description Fetcher(OsmPrimitiveType type, java.util.Set<java.lang.Long> idsPackage, ProgressMonitor progressMonitor)Constructs aFetcher
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiFetchServerObjectReader.FetchResultcall()protected MultiFetchServerObjectReader.FetchResultfetch(ProgressMonitor progressMonitor)fetches the requested primitives and updates the specified progress monitor.protected java.lang.StringgetBaseUrl()Return the base URL for relative URL requestsprotected MultiFetchServerObjectReader.FetchResultmultiGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.Long> pkg, ProgressMonitor progressMonitor)invokes a Multi Get for a set of ids and a givenOsmPrimitiveType.DataSetparseOsm(ProgressMonitor progressMonitor)Download OSM files from somewhereprotected DataSetsingleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor)invokes a Multi Get for a single id and a givenOsmPrimitiveType.protected MultiFetchServerObjectReader.FetchResultsingleGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.Long> pkg, ProgressMonitor progressMonitor)invokes a sequence of Multi Gets for individual ids in a set of ids and a givenOsmPrimitiveType.-
Methods inherited from class org.openstreetmap.josm.io.OsmServerReader
adaptRequest, fetchData, getAttribute, getInputStream, getInputStream, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, isDoAuthenticate, isGpxParsedProperly, parseNotes, parseOsm, parseOsmChange, parseOsmChange, parseRawGps, parseRawGps, parseRawNotes, parseRawNotes, setDoAuthenticate
-
Methods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcher
-
-
-
-
Field Detail
-
pkg
private final java.util.Set<java.lang.Long> pkg
-
type
private final OsmPrimitiveType type
-
progressMonitor
private final ProgressMonitor progressMonitor
-
-
Constructor Detail
-
Fetcher
public Fetcher(OsmPrimitiveType type, java.util.Set<java.lang.Long> idsPackage, ProgressMonitor progressMonitor)
Constructs aFetcher
-
-
Method Detail
-
parseOsm
public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
Description copied from class:OsmServerReaderDownload OSM files from somewhere- Specified by:
parseOsmin classOsmServerReader- Parameters:
progressMonitor- The progress monitor- Returns:
- The corresponding dataset
- Throws:
OsmTransferException- if any error occurs
-
call
public MultiFetchServerObjectReader.FetchResult call() throws java.lang.Exception
- Specified by:
callin interfacejava.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>- Throws:
java.lang.Exception
-
fetch
protected MultiFetchServerObjectReader.FetchResult fetch(ProgressMonitor progressMonitor) throws OsmTransferException
fetches the requested primitives and updates the specified progress monitor.- Parameters:
progressMonitor- the progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
getBaseUrl
protected java.lang.String getBaseUrl()
Description copied from class:OsmServerReaderReturn the base URL for relative URL requests- Overrides:
getBaseUrlin classOsmServerReader- Returns:
- base url of API
-
multiGetIdPackage
protected MultiFetchServerObjectReader.FetchResult multiGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.Long> pkg, ProgressMonitor progressMonitor) throws OsmTransferException
invokes a Multi Get for a set of ids and a givenOsmPrimitiveType. The retrieved primitives are merged toMultiFetchServerObjectReader.outputDataSet.- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONpkg- the package of idsprogressMonitor- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
singleGetId
protected DataSet singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) throws OsmTransferException
invokes a Multi Get for a single id and a givenOsmPrimitiveType. The retrieved primitive is merged toMultiFetchServerObjectReader.outputDataSet.- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONid- the idprogressMonitor- progress monitor- Returns:
- the
DataSetresulting of this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
singleGetIdPackage
protected MultiFetchServerObjectReader.FetchResult singleGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.Long> pkg, ProgressMonitor progressMonitor) throws OsmTransferException
invokes a sequence of Multi Gets for individual ids in a set of ids and a givenOsmPrimitiveType. The retrieved primitives are merged toMultiFetchServerObjectReader.outputDataSet.This method is used if one of the ids in pkg doesn't exist (the server replies with return code 404). If the set is fetched with this method it is possible to find out which of the ids doesn't exist. Unfortunately, the server does not provide an error header or an error body for a 404 reply.
- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONpkg- the set of idsprogressMonitor- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
-