Last change
on this file since 8855 was 8855, checked in by Don-vip, 9 years ago |
sonar - Unused private method should be removed
sonar - Unused protected methods should be removed
sonar - Sections of code should not be "commented out"
sonar - Empty statements should be removed
sonar - squid:S1172 - Unused method parameters should be removed
sonar - squid:S1481 - Unused local variables should be removed
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 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 | public class DownloadNotesUrlIdTask extends DownloadNotesTask {
|
---|
13 |
|
---|
14 | private static final String URL_ID_PATTERN = "https?://www\\.(osm|openstreetmap)\\.org/note/(\\p{Digit}+).*";
|
---|
15 |
|
---|
16 | @Override
|
---|
17 | public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) {
|
---|
18 | final Matcher matcher = Pattern.compile(URL_ID_PATTERN).matcher(url);
|
---|
19 | if (matcher.matches()) {
|
---|
20 | return download(Long.parseLong(matcher.group(2)), null);
|
---|
21 | } else {
|
---|
22 | throw new IllegalStateException("Failed to parse note id from " + url);
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public String[] getPatterns() {
|
---|
28 | return new String[]{URL_ID_PATTERN};
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public String getTitle() {
|
---|
33 | return tr("Download OSM Note by ID");
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.