1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * Upload policy.
|
---|
6 | *
|
---|
7 | * Determines if upload to the OSM server is intended, discouraged, or disabled / blocked.
|
---|
8 | * @see DownloadPolicy
|
---|
9 | * @since 13559 (extracted from {@link DataSet})
|
---|
10 | */
|
---|
11 | public enum UploadPolicy {
|
---|
12 | /**
|
---|
13 | * Normal dataset, upload intended.
|
---|
14 | */
|
---|
15 | NORMAL("true"),
|
---|
16 | /**
|
---|
17 | * Upload discouraged, for example when using or distributing a private dataset.
|
---|
18 | */
|
---|
19 | DISCOURAGED("false"),
|
---|
20 | /**
|
---|
21 | * Upload blocked.
|
---|
22 | * Upload options completely disabled. Intended for special cases
|
---|
23 | * where a warning dialog is not enough, see #12731.
|
---|
24 | *
|
---|
25 | * For the user, it shouldn't be too easy to disable this flag.
|
---|
26 | */
|
---|
27 | BLOCKED("never");
|
---|
28 |
|
---|
29 | final String xmlFlag;
|
---|
30 |
|
---|
31 | UploadPolicy(String xmlFlag) {
|
---|
32 | this.xmlFlag = xmlFlag;
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Get the corresponding value of the <code>upload='...'</code> XML-attribute in the .osm file.
|
---|
37 | * @return value of the <code>upload</code> attribute
|
---|
38 | */
|
---|
39 | public String getXmlFlag() {
|
---|
40 | return xmlFlag;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Returns the {@code UploadPolicy} for the given <code>upload='...'</code> XML-attribute
|
---|
45 | * @param xmlFlag <code>upload='...'</code> XML-attribute to convert
|
---|
46 | * @return {@code UploadPolicy} value
|
---|
47 | * @throws IllegalArgumentException for invalid values
|
---|
48 | * @since 13434
|
---|
49 | */
|
---|
50 | public static UploadPolicy of(String xmlFlag) {
|
---|
51 | for (UploadPolicy policy : values()) {
|
---|
52 | if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
|
---|
53 | return policy;
|
---|
54 | }
|
---|
55 | }
|
---|
56 | throw new IllegalArgumentException(xmlFlag);
|
---|
57 | }
|
---|
58 | }
|
---|