source: josm/trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesUrlIdTask.java@ 13612

Last change on this file since 13612 was 12284, checked in by Don-vip, 7 years ago

see #14794 - javadoc

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.downloadtasks;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.concurrent.Future;
7import java.util.regex.Matcher;
8import java.util.regex.Pattern;
9
10import 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 */
18public 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(boolean newLayer, 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.