Ignore:
Timestamp:
2018-03-25T03:25:55+02:00 (20 months ago)
Author:
Don-vip
Message:

extract DownloadPolicy / UploadPolicy to separate classes

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r13497 r13559  
    107107
    108108    /**
    109      * Download policy.
    110      *
    111      * Determines if download from the OSM server is intended, discouraged, or disabled / blocked.
    112      * @see UploadPolicy
    113      * @since 13453
    114      */
    115     public enum DownloadPolicy {
    116         /**
    117          * Normal dataset, download intended.
    118          */
    119         NORMAL("true"),
    120         /**
    121          * Download blocked.
    122          * Download options completely disabled. Intended for private layers, see #8039.
    123          */
    124         BLOCKED("never");
    125 
    126         final String xmlFlag;
    127 
    128         DownloadPolicy(String xmlFlag) {
    129             this.xmlFlag = xmlFlag;
    130         }
    131 
    132         /**
    133          * Get the corresponding value of the <code>upload='...'</code> XML-attribute
    134          * in the .osm file.
    135          * @return value of the <code>download</code> attribute
    136          */
    137         public String getXmlFlag() {
    138             return xmlFlag;
    139         }
    140 
    141         /**
    142          * Returns the {@code DownloadPolicy} for the given <code>upload='...'</code> XML-attribute
    143          * @param xmlFlag <code>download='...'</code> XML-attribute to convert
    144          * @return {@code DownloadPolicy} value
    145          * @throws IllegalArgumentException for invalid values
    146          */
    147         public static DownloadPolicy of(String xmlFlag) {
    148             for (DownloadPolicy policy : values()) {
    149                 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
    150                     return policy;
    151                 }
    152             }
    153             throw new IllegalArgumentException(xmlFlag);
    154         }
    155     }
    156 
    157     /**
    158      * Upload policy.
    159      *
    160      * Determines if upload to the OSM server is intended, discouraged, or disabled / blocked.
    161      * @see DownloadPolicy
    162      */
    163     public enum UploadPolicy {
    164         /**
    165          * Normal dataset, upload intended.
    166          */
    167         NORMAL("true"),
    168         /**
    169          * Upload discouraged, for example when using or distributing a private dataset.
    170          */
    171         DISCOURAGED("false"),
    172         /**
    173          * Upload blocked.
    174          * Upload options completely disabled. Intended for special cases
    175          * where a warning dialog is not enough, see #12731.
    176          *
    177          * For the user, it shouldn't be too easy to disable this flag.
    178          */
    179         BLOCKED("never");
    180 
    181         final String xmlFlag;
    182 
    183         UploadPolicy(String xmlFlag) {
    184             this.xmlFlag = xmlFlag;
    185         }
    186 
    187         /**
    188          * Get the corresponding value of the <code>upload='...'</code> XML-attribute
    189          * in the .osm file.
    190          * @return value of the <code>upload</code> attribute
    191          */
    192         public String getXmlFlag() {
    193             return xmlFlag;
    194         }
    195 
    196         /**
    197          * Returns the {@code UploadPolicy} for the given <code>upload='...'</code> XML-attribute
    198          * @param xmlFlag <code>upload='...'</code> XML-attribute to convert
    199          * @return {@code UploadPolicy} value
    200          * @throws IllegalArgumentException for invalid values
    201          * @since 13434
    202          */
    203         public static UploadPolicy of(String xmlFlag) {
    204             for (UploadPolicy policy : values()) {
    205                 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
    206                     return policy;
    207                 }
    208             }
    209             throw new IllegalArgumentException(xmlFlag);
    210         }
    211     }
    212 
    213     /**
    214109     * Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)
    215110     */
Note: See TracChangeset for help on using the changeset viewer.