1 19 20 24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.wizards; 25 26 import java.util.Set ; 27 import java.util.Vector ; 28 import java.util.Hashtable ; 29 import org.openide.util.NbBundle; 30 import org.openide.filesystems.FileObject; 31 import org.openide.loaders.DataFolder; 32 33 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 34 35 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard; 36 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants; 37 38 42 public class ResourceConfigData implements WizardConstants { 43 44 private DataFolder targetFolder; 45 private String targetFolderPath; 46 private String targetFile; 47 private FileObject targetFileObject; 48 private ResourceConfigHelperHolder holder; 49 private Hashtable prop_value_map = new Hashtable (); 50 private String resName; 51 52 53 public ResourceConfigData() { 54 } 55 56 86 87 public void removeAll() { 88 prop_value_map = new Hashtable (); 89 } 90 91 public String getResourceName() { 92 return resName; 93 } 94 95 public void setResourceName(String name) { 96 resName = name; 97 } 98 99 public String getString(String name) { 100 Object value = prop_value_map.get(name); 101 if (value == null) 102 return new String (); 103 else 104 return (String )value; 105 } 106 107 public void setString(String name, String value) { 108 set(name, value); 109 } 110 111 public Object get(String name) { 112 return prop_value_map.get(name); 113 } 114 115 public void set(String name, Object value) { 116 prop_value_map.put(name, value); 117 } 118 119 public String [] getFieldNames() { 120 Set keySet = prop_value_map.keySet(); 121 String [] fieldNames = new String [keySet.size()]; 122 return (String [])keySet.toArray(fieldNames); 123 } 124 125 public Vector getProperties() { 126 Vector props = (Vector )prop_value_map.get(__Properties); if (props == null) { 128 props = new Vector (); 129 prop_value_map.put(__Properties, props); } 131 return props; 132 } 133 134 public Vector getPropertyNames() { 135 Vector props = getProperties(); 136 Vector vec = new Vector (); 137 for (int i = 0; i < props.size(); i++) { 138 vec.add(((NameValuePair)props.elementAt(i)).getParamName()); 139 } 140 return vec; 141 } 142 143 public String getPropertyValue(String propName) { 144 Vector vec = getProperties(); 145 for (int i = 0; i < vec.size(); i++) { 146 NameValuePair pair = (NameValuePair)vec.elementAt(i); 147 if (pair.getParamName().equals(propName)) 148 return pair.getParamValue(); 149 } 150 return null; 151 } 152 153 public Vector addProperty(NameValuePair pair) { 154 Vector names = getPropertyNames(); 155 if (names.contains(pair.getParamName())) 156 return null; 157 Vector props = getProperties(); 158 props.add(pair); 159 return props; 160 } 161 162 public Vector addProperty(String name, String value) { 163 NameValuePair pair = new NameValuePair(); 164 pair.setParamName(name); 165 pair.setParamValue(value); 166 return addProperty(pair); 167 } 168 169 public void removeProperty(int index) { 170 Vector props = getProperties(); 171 props.removeElementAt(index); 172 } 173 174 public void setProperties(Vector props) { 175 set(__Properties, props); 176 } 177 178 public String toString() { 179 StringBuffer retValue = new StringBuffer (); 180 retValue.append(getResourceName() + "::\n"); String [] fieldNames = getFieldNames(); 182 for (int i = 0; i < fieldNames.length; i++) { 183 if (fieldNames[i].equals(__Properties)) { 184 retValue.append("properties: \n"); Vector props = (Vector )getProperties(); 186 for (int j = 0; j < props.size(); j++) { 187 NameValuePair pair = (NameValuePair)props.elementAt(j); 188 retValue.append(" " + pair.getParamName() + ": " + pair.getParamValue()); } 190 } 191 else 192 retValue.append(fieldNames[i] + ": " + getString(fieldNames[i]) + "\n"); } 194 return retValue.toString(); 195 } 196 197 public void setTargetFolder(DataFolder targetFolder){ 198 this.targetFolder = targetFolder; 199 } 200 201 public DataFolder getTargetFolder(){ 202 return this.targetFolder; 203 } 204 205 public void setTargetFolderPath(String path){ 206 this.targetFolderPath = path; 207 } 208 209 public String getTargetFolderPath(){ 210 return this.targetFolderPath; 211 } 212 213 public void setTargetFile(String targetFile){ 214 this.targetFile = targetFile; 215 } 216 217 public String getTargetFile(){ 218 return this.targetFile; 219 } 220 221 public FileObject getTargetFileObject(){ 222 return this.targetFileObject; 223 } 224 225 public void setTargetFileObject(FileObject targetObject){ 226 this.targetFileObject = targetObject; 227 } 228 229 public ResourceConfigHelperHolder getHolder(){ 230 return this.holder; 231 } 232 233 public void setHolder(ResourceConfigHelperHolder holder){ 234 this.holder = holder; 235 } 236 } 237 | Popular Tags |