001 /* java.beans.FeatureDescriptor 002 Copyright (C) 1998, 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package java.beans; 040 041 import java.util.Enumeration; 042 import java.util.Hashtable; 043 044 /** 045 * FeatureDescriptor is the common superclass for all JavaBeans Descriptor 046 * classes. JavaBeans descriptors are abstract descriptors of properties, 047 * events, methods, beans, etc.<P> 048 * 049 * <STRONG>Documentation Convention:</STRONG> for proper 050 * Internalization of Beans inside an RAD tool, sometimes there 051 * are two names for a property or method: a programmatic, or 052 * locale-independent name, which can be used anywhere, and a 053 * localized, display name, for ease of use. In the 054 * documentation I will specify different String values as 055 * either <EM>programmatic</EM> or <EM>localized</EM> to 056 * make this distinction clear. 057 * 058 * @author John Keiser 059 * @since 1.1 060 */ 061 062 public class FeatureDescriptor 063 { 064 String name; 065 String displayName; 066 String shortDescription; 067 boolean expert; 068 boolean hidden; 069 boolean preferred; 070 071 Hashtable<String,Object> valueHash; 072 073 /** 074 * Instantiate this FeatureDescriptor with appropriate default values. 075 */ 076 public FeatureDescriptor() 077 { 078 valueHash = new Hashtable<String,Object>(); 079 } 080 081 /** 082 * Get the programmatic name of this feature. 083 */ 084 public String getName() 085 { 086 return name; 087 } 088 089 /** 090 * Set the programmatic name of this feature. 091 * 092 * @param name the new name for this feature. 093 */ 094 public void setName(String name) 095 { 096 this.name = name; 097 } 098 099 /** 100 * Get the localized (display) name of this feature. 101 * 102 * @returns The localized display name of this feature or falls 103 * back to the programmatic name. 104 */ 105 public String getDisplayName() 106 { 107 return (displayName == null) ? name : displayName; 108 } 109 110 /** 111 * Set the localized (display) name of this feature. 112 * 113 * @param displayName the new display name for this feature. 114 */ 115 public void setDisplayName(String displayName) 116 { 117 this.displayName = displayName; 118 } 119 120 /** 121 * Get the localized short description for this feature. 122 * 123 * @returns A short localized description of this feature or 124 * what <code>getDisplayName</code> returns in case, that no short description 125 * is available. 126 */ 127 public String getShortDescription() 128 { 129 return (shortDescription == null) ? getDisplayName() : shortDescription; 130 } 131 132 /** 133 * Set the localized short description for this feature. 134 * 135 * @param shortDescription the new short description for this feature. 136 */ 137 public void setShortDescription(String shortDescription) 138 { 139 this.shortDescription = shortDescription; 140 } 141 142 /** 143 * Indicates whether this feature is for expert use only. 144 * 145 * @return true if for use by experts only, 146 * or false if anyone can use it. 147 */ 148 public boolean isExpert() 149 { 150 return expert; 151 } 152 153 /** 154 * Set whether this feature is for expert use only. 155 * 156 * @param expert true if for use by experts only, 157 * or false if anyone can use it. 158 */ 159 public void setExpert(boolean expert) 160 { 161 this.expert = expert; 162 } 163 164 /** 165 * Indicates whether this feature is for use by tools only. 166 * If it is for use by tools only, then it should not be displayed. 167 * 168 * @return true if tools only should use it, 169 * or false if anyone can see it. 170 */ 171 public boolean isHidden() 172 { 173 return hidden; 174 } 175 176 /** 177 * Set whether this feature is for use by tools only. 178 * If it is for use by tools only, then it should not be displayed. 179 * 180 * @param hidden true if tools only should use it, 181 * or false if anyone can see it. 182 */ 183 public void setHidden(boolean hidden) 184 { 185 this.hidden = hidden; 186 } 187 188 public boolean isPreferred () 189 { 190 return preferred; 191 } 192 193 public void setPreferred (boolean preferred) 194 { 195 this.preferred = preferred; 196 } 197 198 /** 199 * Get an arbitrary value set with setValue(). 200 * 201 * @param name the programmatic name of the key. 202 * 203 * @return the value associated with this name, 204 * or null if there is none. 205 */ 206 public Object getValue(String name) 207 { 208 return valueHash.get(name); 209 } 210 211 /** 212 * Set an arbitrary string-value pair with this feature. 213 * 214 * @param name the programmatic name of the key. 215 * @param value the value to associate with the name. 216 */ 217 public void setValue(String name, Object value) 218 { 219 valueHash.put(name, value); 220 } 221 222 /** 223 * Get a list of the programmatic key names set with setValue(). 224 * 225 * @return an Enumerator over all the programmatic key names associated 226 * with this feature. 227 */ 228 public Enumeration<String> attributeNames() 229 { 230 return valueHash.keys(); 231 } 232 }