001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm; 003 004/** 005 * Download policy. 006 * 007 * Determines if download from the OSM server is intended, discouraged, or disabled / blocked. 008 * @see UploadPolicy 009 * @since 13559 (extracted from {@link DataSet}) 010 */ 011public enum DownloadPolicy { 012 /** 013 * Normal dataset, download intended. 014 */ 015 NORMAL("true"), 016 /** 017 * Download blocked. 018 * Download options completely disabled. Intended for private layers, see #8039. 019 */ 020 BLOCKED("never"); 021 022 final String xmlFlag; 023 024 DownloadPolicy(String xmlFlag) { 025 this.xmlFlag = xmlFlag; 026 } 027 028 /** 029 * Get the corresponding value of the <code>upload='...'</code> XML-attribute 030 * in the .osm file. 031 * @return value of the <code>download</code> attribute 032 */ 033 public String getXmlFlag() { 034 return xmlFlag; 035 } 036 037 /** 038 * Returns the {@code DownloadPolicy} for the given <code>upload='...'</code> XML-attribute 039 * @param xmlFlag <code>download='...'</code> XML-attribute to convert 040 * @return {@code DownloadPolicy} value 041 * @throws IllegalArgumentException for invalid values 042 */ 043 public static DownloadPolicy of(String xmlFlag) { 044 for (DownloadPolicy policy : values()) { 045 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) { 046 return policy; 047 } 048 } 049 throw new IllegalArgumentException(xmlFlag); 050 } 051}