public class GeoNamesFileExtractor extends Object implements GeoEntryExtractor
GeoEntryExtractor.ExtractionCallback
Constructor and Description |
---|
GeoNamesFileExtractor() |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection() |
javax.ws.rs.core.Response |
createConnection(String resource) |
List<GeoEntry> |
getGeoEntries(String resource,
ProgressCallback progressCallback)
Extracts GeoNames entries from a resource as
GeoEntry objects, all at once, providing
updates about the extraction progress. |
InputStream |
getUrlInputStreamFromWebClient() |
void |
pushGeoEntriesToExtractionCallback(String resource,
GeoEntryExtractor.ExtractionCallback extractionCallback)
Extracts GeoNames entries from a resource as
GeoEntry objects and passes each GeoEntry object through the callback extractionCallback . |
void |
setGeoEntryCreator(GeoEntryCreator geoEntryCreator) |
void |
setUrl(String url)
Sets the url
|
public void setGeoEntryCreator(GeoEntryCreator geoEntryCreator)
public void setUrl(String url)
GeoEntryExtractor
setUrl
in interface GeoEntryExtractor
public List<GeoEntry> getGeoEntries(String resource, ProgressCallback progressCallback) throws GeoEntryExtractionException, GeoNamesRemoteDownloadException
GeoEntryExtractor
GeoEntry
objects, all at once, providing
updates about the extraction progress.getGeoEntries
in interface GeoEntryExtractor
resource
- the resource containing GeoNames entriesprogressCallback
- the callback to receive updates about the extraction progress, may be
null if you don't want any updatesGeoEntry
objects corresponding to the GeoNames entries in the
resourceGeoEntryExtractionException
- if an error occurs while extracting GeoNames entries from
the resourceGeoNamesRemoteDownloadException
- if an error occurs while downloading from the resourcepublic void pushGeoEntriesToExtractionCallback(String resource, GeoEntryExtractor.ExtractionCallback extractionCallback) throws GeoEntryExtractionException, GeoNamesRemoteDownloadException
GeoEntryExtractor
GeoEntry
objects and passes each GeoEntry
object through the callback extractionCallback
. The callback is called
exactly once for each GeoEntry
object extracted from the resource.
This method should be used instead of GeoEntryExtractor.getGeoEntries(String, ProgressCallback)
if
the resource contains a very large number of entries.
pushGeoEntriesToExtractionCallback
in interface GeoEntryExtractor
resource
- the resource containing GeoNames entriesextractionCallback
- the callback that receives each extracted GeoEntry
object,
must not be nullGeoEntryExtractionException
- if an error occurs while extracting GeoNames entries from
the resourceGeoNamesRemoteDownloadException
- if an error occurs while downloading from the resourcepublic javax.ws.rs.core.Response createConnection(String resource)
public InputStream getUrlInputStreamFromWebClient() throws GeoNamesRemoteDownloadException
GeoNamesRemoteDownloadException
public void closeConnection()
This work is licensed under a Creative Commons Attribution 4.0 International License.