001 /* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2013 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see http://www.gnu.org/licenses. 027 */ 028 029 package edu.wisc.ssec.mcidasv; 030 031 032 import org.w3c.dom.*; 033 034 import java.util.ArrayList; 035 import java.util.List; 036 037 import ucar.unidata.util.StringUtil; 038 039 040 /** 041 * An object to handle a saved parameter set. 042 */ 043 public class ParameterSet { 044 045 /** Xml attribute name for the name */ 046 public static final String ATTR_NAME = "name"; 047 048 /** Xml attribute name for the category */ 049 public static final String ATTR_CATEGORY = "category"; 050 051 /** The name of the parameter set */ 052 private String name; 053 054 /** The category of the parameter set */ 055 private List<String> categories; 056 057 /** The type */ 058 private String type; 059 060 /** The XML element */ 061 private Element element; 062 063 /** prefix_ */ 064 private String uniquePrefix; 065 066 public ParameterSet(String name, String category, String type) { 067 this(name, category, type, null); 068 } 069 070 public ParameterSet(String name, List<String> categories, String type) { 071 this(name, categories, type, null); 072 } 073 074 public ParameterSet(String name, String category, String type, Element element) { 075 List<String> categories = PersistenceManager.stringToCategories(category); 076 this.name = name; 077 this.categories = categories; 078 this.type = type; 079 this.element = element; 080 } 081 082 public ParameterSet(String name, List<String>categories, String type, Element element) { 083 this.name = name; 084 this.categories = categories; 085 this.type = type; 086 this.element = element; 087 } 088 089 /** 090 * set the unique prefix 091 * 092 * @param p prefix 093 */ 094 protected void setUniquePrefix(String p) { 095 uniquePrefix = p; 096 } 097 098 /** 099 * Get the name to use with the categories as a prefix 100 * 101 * @return categorized name 102 */ 103 public String getCategorizedName() { 104 String catString = StringUtil.join("_", categories); 105 if (uniquePrefix != null) { 106 catString = uniquePrefix + catString; 107 } 108 return catString + name; 109 } 110 111 /** 112 * Set the Name property. 113 * 114 * @param value The new value for Name 115 */ 116 public void setName(String value) { 117 name = value; 118 } 119 120 /** 121 * Get the Name property. 122 * 123 * @return The Name 124 */ 125 public String getName() { 126 return name; 127 } 128 129 130 /** 131 * Set the Category property. 132 * 133 * @param value The new value for Category 134 */ 135 public void setCategories(List value) { 136 categories = value; 137 } 138 139 /** 140 * Get the Category property. 141 * 142 * @return The Category 143 */ 144 public List getCategories() { 145 return categories; 146 } 147 148 /** 149 * Set the Type property. 150 * 151 * @param value The new value for Type 152 */ 153 public void setType(String value) { 154 type = value; 155 } 156 157 /** 158 * Get the Type property. 159 * 160 * @return The Type 161 */ 162 public String getType() { 163 return type; 164 } 165 166 /** 167 * Set the Element property. 168 * 169 * @param value The new value for Element 170 */ 171 public void setElement(Element value) { 172 element = value; 173 } 174 175 /** 176 * Get the Element property. 177 * 178 * @return The Element 179 */ 180 public Element getElement() { 181 return element; 182 } 183 184 /** 185 * Full label 186 * 187 * @return The name. 188 */ 189 public String getLabel() { 190 return PersistenceManager.categoriesToString(categories) 191 + PersistenceManager.CATEGORY_SEPARATOR + name; 192 } 193 194 /** 195 * Override toString. 196 * 197 * @return The name. 198 */ 199 public String toString() { 200 // String description = name + " { "; 201 // NamedNodeMap attributes = element.getAttributes(); 202 // for (int i=0; i<attributes.getLength(); i++) { 203 // Node attribute = attributes.item(i); 204 // description += attribute.getNodeName() + "=" + attribute.getNodeValue(); 205 // if (i < attributes.getLength() - 1) description += ", "; 206 // } 207 // description += "}"; 208 // return description; 209 return name; 210 } 211 212 } 213