Last change
on this file was 13559, checked in by Don-vip, 7 years ago |
extract DownloadPolicy / UploadPolicy to separate classes
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[13559] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.data.osm;
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Download policy.
|
---|
| 6 | *
|
---|
| 7 | * Determines if download from the OSM server is intended, discouraged, or disabled / blocked.
|
---|
| 8 | * @see UploadPolicy
|
---|
| 9 | * @since 13559 (extracted from {@link DataSet})
|
---|
| 10 | */
|
---|
| 11 | public enum DownloadPolicy {
|
---|
| 12 | /**
|
---|
| 13 | * Normal dataset, download intended.
|
---|
| 14 | */
|
---|
| 15 | NORMAL("true"),
|
---|
| 16 | /**
|
---|
| 17 | * Download blocked.
|
---|
| 18 | * Download options completely disabled. Intended for private layers, see #8039.
|
---|
| 19 | */
|
---|
| 20 | BLOCKED("never");
|
---|
| 21 |
|
---|
| 22 | final String xmlFlag;
|
---|
| 23 |
|
---|
| 24 | DownloadPolicy(String xmlFlag) {
|
---|
| 25 | this.xmlFlag = xmlFlag;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * Get the corresponding value of the <code>upload='...'</code> XML-attribute
|
---|
| 30 | * in the .osm file.
|
---|
| 31 | * @return value of the <code>download</code> attribute
|
---|
| 32 | */
|
---|
| 33 | public String getXmlFlag() {
|
---|
| 34 | return xmlFlag;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Returns the {@code DownloadPolicy} for the given <code>upload='...'</code> XML-attribute
|
---|
| 39 | * @param xmlFlag <code>download='...'</code> XML-attribute to convert
|
---|
| 40 | * @return {@code DownloadPolicy} value
|
---|
| 41 | * @throws IllegalArgumentException for invalid values
|
---|
| 42 | */
|
---|
| 43 | public static DownloadPolicy of(String xmlFlag) {
|
---|
| 44 | for (DownloadPolicy policy : values()) {
|
---|
| 45 | if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
|
---|
| 46 | return policy;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 | throw new IllegalArgumentException(xmlFlag);
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.