Last change
on this file was 13927, checked in by Don-vip, 7 years ago |
see #11000 - Remote control: allow to specify layer_name for import
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.downloadtasks;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.concurrent.Future;
|
---|
7 | import java.util.regex.Matcher;
|
---|
8 | import java.util.regex.Pattern;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.gui.progress.ProgressMonitor;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Specialized task for downloading OSM notes by ID.
|
---|
14 | * <p>
|
---|
15 | * It handles one URL pattern: openstreetmap website URL with {@code /node/<id>} argument.
|
---|
16 | * @since 8195
|
---|
17 | */
|
---|
18 | public class DownloadNotesUrlIdTask extends DownloadNotesTask {
|
---|
19 |
|
---|
20 | private static final String URL_ID_PATTERN = "https?://www\\.(osm|openstreetmap)\\.org/note/(\\p{Digit}+).*";
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public Future<?> loadUrl(DownloadParams settings, String url, ProgressMonitor progressMonitor) {
|
---|
24 | final Matcher matcher = Pattern.compile(URL_ID_PATTERN).matcher(url);
|
---|
25 | if (matcher.matches()) {
|
---|
26 | return download(Long.parseLong(matcher.group(2)), null);
|
---|
27 | } else {
|
---|
28 | throw new IllegalStateException("Failed to parse note id from " + url);
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public String[] getPatterns() {
|
---|
34 | return new String[]{URL_ID_PATTERN};
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public String getTitle() {
|
---|
39 | return tr("Download OSM Note by ID");
|
---|
40 | }
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.