1 14 15 package org.quickserver.util.xmlreader; 16 17 import java.util.*; 18 19 40 public class ApplicationConfiguration extends HashMap { 41 private String promptType = "gui"; 43 50 public void setPromptType(String promptType) { 51 if(promptType!=null && promptType.equals("")==false) 52 if(promptType.equals("gui") || promptType.equals("console")) 53 this.promptType = promptType; 54 } 55 60 public String getPromptType() { 61 return promptType; 62 } 63 64 67 public void addProperty(Property property) { 68 put(property.getName(), property.getValue()); 69 } 70 71 75 public Property findProperty(String name) { 76 String temp = (String ) get(name); 77 if(temp!=null) { 78 return new Property(name, temp); 79 } else { 80 return null; 81 } 82 } 83 84 87 public String toXML(String pad) { 88 if(pad==null) pad=""; 89 StringBuffer sb = new StringBuffer (); 90 sb.append(pad+"<application-configuration>\n"); 91 92 sb.append(pad+"\t<prompt-type>"+getPromptType()+"</prompt-type>"); 93 94 Iterator iterator = keySet().iterator(); 95 while(iterator.hasNext()) { 96 String key = (String ) iterator.next(); 97 String value = (String ) get(key); 98 sb.append(pad+"\t<property>"); 99 sb.append(pad+"\t\t<property-name>"+key+"</property-name>\n"); 100 sb.append(pad+"\t\t<property-value>"+value+"</property-value>\n"); 101 sb.append(pad+"\t</property>\n"); 102 } 103 sb.append(pad+"</application-configuration>\n"); 104 return sb.toString(); 105 } 106 } 107 | Popular Tags |