001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2016 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 029package edu.wisc.ssec.mcidasv; 030 031 032import org.w3c.dom.*; 033 034import java.util.List; 035 036import ucar.unidata.util.StringUtil; 037 038 039/** 040 * An object to handle a saved parameter set. 041 */ 042public class ParameterSet { 043 044 /** Xml attribute name for the name */ 045 public static final String ATTR_NAME = "name"; 046 047 /** Xml attribute name for the category */ 048 public static final String ATTR_CATEGORY = "category"; 049 050 /** The name of the parameter set */ 051 private String name; 052 053 /** The category of the parameter set */ 054 private List<String> categories; 055 056 /** The type */ 057 private String type; 058 059 /** The XML element */ 060 private Element element; 061 062 /** prefix_ */ 063 private String uniquePrefix; 064 065 public ParameterSet(String name, String category, String type) { 066 this(name, category, type, null); 067 } 068 069 public ParameterSet(String name, List<String> categories, String type) { 070 this(name, categories, type, null); 071 } 072 073 public ParameterSet(String name, String category, String type, Element element) { 074 List<String> categories = PersistenceManager.stringToCategories(category); 075 this.name = name; 076 this.categories = categories; 077 this.type = type; 078 this.element = element; 079 } 080 081 public ParameterSet(String name, List<String>categories, String type, Element element) { 082 this.name = name; 083 this.categories = categories; 084 this.type = type; 085 this.element = element; 086 } 087 088 /** 089 * set the unique prefix 090 * 091 * @param p prefix 092 */ 093 protected void setUniquePrefix(String p) { 094 uniquePrefix = p; 095 } 096 097 /** 098 * Get the name to use with the categories as a prefix 099 * 100 * @return categorized name 101 */ 102 public String getCategorizedName() { 103 String catString = StringUtil.join("_", categories); 104 if (uniquePrefix != null) { 105 catString = uniquePrefix + catString; 106 } 107 return catString + name; 108 } 109 110 /** 111 * Set the Name property. 112 * 113 * @param value The new value for Name 114 */ 115 public void setName(String value) { 116 name = value; 117 } 118 119 /** 120 * Get the Name property. 121 * 122 * @return The Name 123 */ 124 public String getName() { 125 return name; 126 } 127 128 129 /** 130 * Set the Category property. 131 * 132 * @param value The new value for Category 133 */ 134 public void setCategories(List value) { 135 categories = value; 136 } 137 138 /** 139 * Get the Category property. 140 * 141 * @return The Category 142 */ 143 public List getCategories() { 144 return categories; 145 } 146 147 /** 148 * Set the Type property. 149 * 150 * @param value The new value for Type 151 */ 152 public void setType(String value) { 153 type = value; 154 } 155 156 /** 157 * Get the Type property. 158 * 159 * @return The Type 160 */ 161 public String getType() { 162 return type; 163 } 164 165 /** 166 * Set the Element property. 167 * 168 * @param value The new value for Element 169 */ 170 public void setElement(Element value) { 171 element = value; 172 } 173 174 /** 175 * Get the Element property. 176 * 177 * @return The Element 178 */ 179 public Element getElement() { 180 return element; 181 } 182 183 /** 184 * Full label 185 * 186 * @return The name. 187 */ 188 public String getLabel() { 189 return PersistenceManager.categoriesToString(categories) 190 + PersistenceManager.CATEGORY_SEPARATOR + name; 191 } 192 193 /** 194 * Override toString. 195 * 196 * @return The name. 197 */ 198 public String toString() { 199// String description = name + " { "; 200// NamedNodeMap attributes = element.getAttributes(); 201// for (int i=0; i<attributes.getLength(); i++) { 202// Node attribute = attributes.item(i); 203// description += attribute.getNodeName() + "=" + attribute.getNodeValue(); 204// if (i < attributes.getLength() - 1) description += ", "; 205// } 206// description += "}"; 207// return description; 208 return name; 209 } 210 211} 212