1 package cve.esecutori.components.specificaSem; 2 3 import java.io.*; 4 import java.util.*; 5 6 import org.jdom.*; 7 import org.jdom.input.SAXBuilder; 8 import org.jdom.output.XMLOutputter; 9 10 import cve.staticLayout.*; 11 import org.apache.log4j.Logger; 12 13 19 public class ConfigElements 20 { 21 24 private HashMap elements; 25 26 public ConfigElements(){ 27 Cve.errLog.debug(""); 28 elements=new HashMap(); 29 } 30 31 public void addElement(String id, ConfigElement config){ 32 Cve.errLog.debug(""); 33 System.out.println(" #E @specificaSem.ConfigElements.addElement: idElemento: "+ id); 34 elements.put(id, config); 35 } 36 37 public void removeElement(String id){ 38 Cve.errLog.debug(""); 39 System.out.println(" #E @specificaSem.ConfigElement.removeElement: idElemento: "+ id); 40 elements.remove(id); 41 } 42 43 public ConfigElement getConfig(String id){ 44 Cve.errLog.debug(""); 45 return (ConfigElement)elements.get(id); 46 } 47 48 public HashMap getAllConfig(){ 49 Cve.errLog.debug(""); 50 return elements; 51 } 52 53 public Collection getInternalToken(){ 55 Cve.errLog.debug(""); 56 Vector appo_internal = new Vector(); 57 Set setKey = elements.keySet(); 59 Iterator assIt = setKey.iterator(); 60 String key; 61 ConfigElement appo_config; 62 while (assIt.hasNext()){ 63 64 key = (String )assIt.next(); 66 appo_config = getConfig(key); 67 68 Set setParameter = appo_config.getAllParameter().keySet(); 70 Iterator parIt = setParameter.iterator(); 71 String par; 72 String value; 73 while (parIt.hasNext()){ 74 par = (String )parIt.next(); 75 76 if (par.equals("num_token")){ 78 value = (String )appo_config.getParameter(par); 79 80 if (Integer.valueOf(value).intValue()>0){ 82 appo_internal.add(key); 83 } 84 } 85 } 86 } 87 return appo_internal; 88 } 89 90 public String toString(){ 92 Cve.errLog.debug(""); 93 String appo = new String (); 94 95 Set setKey = elements.keySet(); 97 98 System.out.println("Numero Elementi Registrati : " + setKey.size()); 99 100 Iterator assIt = setKey.iterator(); 102 String key; 103 ConfigElement appo_config; 104 while (assIt.hasNext()){ 105 106 key = (String )assIt.next(); 108 appo_config = getConfig(key); 109 110 appo = appo + "Elemento:"+ key +"\r\n"; 111 112 Set setParameter = appo_config.getAllParameter().keySet(); 114 Iterator parIt = setParameter.iterator(); 115 String par; 116 String value; 117 while (parIt.hasNext()){ 118 par = (String )parIt.next(); 119 value = (String )appo_config.getParameter(par); 120 appo = appo + " parameter : "+ par +" Value: "+value +"\r\n"; 121 } 122 } 123 return appo; 124 } 125 126 public void clear(){ 127 Cve.errLog.debug(""); 128 elements.clear(); 129 } 130 131 public static void main(String [] args){ 133 134 ConfigElements appo_lista = new ConfigElements(); 135 136 137 ConfigElement appo_c1 = new ConfigElement(); 139 appo_c1.putParameter("token","3"); 140 appo_c1.putParameter("prova","5"); 141 142 appo_lista.addElement("20", appo_c1); 143 144 ConfigElement appo_c2 = new ConfigElement(); 146 appo_c2.putParameter("token","1"); 147 appo_c2.putParameter("prova","8"); 148 149 appo_lista.addElement("22", appo_c2); 150 System.out.println(appo_lista.toString()); 151 } 152 } | Popular Tags |