|
Last change
on this file since 8318 was 8318, checked in by Don-vip, 10 years ago |
|
fix various Sonar issues:
- squid:S1068: Unused private fields should be removed
- squid:S1155: Collection.isEmpty() should be used to test for emptiness
- squid:S1185: Overriding methods should do more than simply call the same method in the super class
- squid:S1694: An abstract class should have both abstract and concrete methods
- squid:S1905: Redundant casts should not be used
- squid:S2065: Fields in non-serializable classes should not be "transient"
- squid:S2583: Conditions should not unconditionally evaluate to "TRUE" or to "FALSE"
- squid:ModifiersOrderCheck: Modifiers should be declared in the correct order
|
|
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 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(newLayer, 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.