00001 package cedar.jetweb.generator; 00002 00003 import cedar.jetweb.JetWebException; 00004 00005 import java.util.HashMap; 00006 import java.util.Vector; 00007 import java.util.Map.Entry; 00008 import java.util.Iterator; 00009 00016 public class GeneratorWrapper{ 00017 00018 private Generator gen=null; 00019 00020 private Vector<Integer> ids=new Vector<Integer>();//null; 00021 private Vector<String> names=new Vector<String>(); 00022 private Vector<Integer> ivalues = new Vector<Integer>();//null; 00023 private Vector<Double> rvalues = new Vector<Double>();//null; 00024 private Vector<Integer> aindices = new Vector<Integer>();//null; 00025 00026 private Vector<Boolean> relPhoton_ = new Vector<Boolean>(); 00027 private Vector<Boolean> relProton_ = new Vector<Boolean>(); 00028 00029 00035 public GeneratorWrapper(Generator xx){ 00036 gen = xx; 00037 update(); 00038 00039 return; 00040 } 00042 00047 public GeneratorWrapper update(){ 00048 00049 HashMap<String, Integer> intParameters = gen.getIntParameters(); 00050 HashMap<String, Double> realParameters = gen.getRealParameters(); 00051 HashMap<String, HashMap<Integer, Integer>> intParameterArrays = 00052 gen.getIntParameterArrays(); 00053 HashMap<String, HashMap<Integer, Double>> realParameterArrays = 00054 gen.getRealParameterArrays(); 00055 00056 ids = new Vector<Integer>(); 00057 names = new Vector<String>(); 00058 rvalues = new Vector<Double>(); 00059 ivalues = new Vector<Integer>(); 00060 aindices = new Vector<Integer>(); 00061 relPhoton_ = new Vector<Boolean>(); 00062 relProton_ = new Vector<Boolean>(); 00063 00064 Iterator it = intParameters.entrySet().iterator(); 00065 Integer id=0; 00066 Short aindex = 0; 00067 while(it.hasNext()){ 00068 ++id; 00069 Entry ent = (Entry)it.next(); 00070 String name = (String)ent.getKey(); 00071 names.add(name); 00072 ivalues.add((Integer)ent.getValue()); 00073 try{ 00074 relPhoton_.add(gen.getIsRelevantToPhoton(name)); 00075 relProton_.add(gen.getIsRelevantToProton(name)); 00076 }catch(Throwable err){ 00077 System.out.println(err.getMessage()); 00078 } 00079 rvalues.add(null); 00080 aindices.add(null); 00081 ids.add(id); 00082 } 00083 00084 it = realParameters.entrySet().iterator(); 00085 while(it.hasNext()){ 00086 ++id; 00087 Entry ent = (Entry)it.next(); 00088 String name = (String)ent.getKey(); 00089 names.add(name); 00090 rvalues.add((Double)ent.getValue()); 00091 try{ 00092 relPhoton_.add(gen.getIsRelevantToPhoton(name)); 00093 relProton_.add(gen.getIsRelevantToProton(name)); 00094 }catch(Throwable err){ 00095 System.out.println(err.getMessage()); 00096 } 00097 ivalues.add(null); 00098 aindices.add(null); 00099 ids.add(id); 00100 } 00101 00102 it = intParameterArrays.entrySet().iterator(); 00103 00104 while(it.hasNext()){ 00105 Entry ient = (Entry)it.next(); 00106 String name = (String)ient.getKey(); 00107 HashMap<Integer, Integer> jmap = 00108 (HashMap<Integer, Integer>)ient.getValue(); 00109 Iterator jt = jmap.entrySet().iterator(); 00110 // aindex = 0; 00111 while(jt.hasNext()){ 00112 ++id; 00113 Entry jent = (Entry)jt.next(); 00114 names.add(name); 00115 ivalues.add((Integer)jent.getValue()); 00116 rvalues.add(null); 00117 Integer index = (Integer)jent.getKey(); 00118 aindices.add(index); 00119 ids.add(id); 00120 try{ 00121 relPhoton_.add(gen.getIsRelevantToPhoton(name, index)); 00122 relProton_.add(gen.getIsRelevantToProton(name, index)); 00123 }catch(Throwable err){ 00124 System.out.println(err.getMessage()); 00125 } 00126 00127 00128 // ++aindex; 00129 } 00130 } 00131 00132 it = realParameterArrays.entrySet().iterator(); 00133 00134 while(it.hasNext()){ 00135 Entry ient = (Entry)it.next(); 00136 String name = (String)ient.getKey(); 00137 HashMap<Integer, Double> jmap = 00138 (HashMap<Integer, Double>)ient.getValue(); 00139 Iterator jt = jmap.entrySet().iterator(); 00140 // aindex = 0; 00141 while(jt.hasNext()){ 00142 ++id; 00143 Entry jent = (Entry)jt.next(); 00144 names.add(name); 00145 ivalues.add(null); 00146 rvalues.add((Double)jent.getValue()); 00147 Integer index = (Integer)jent.getKey(); 00148 aindices.add(index); 00149 ids.add(id); 00150 try{ 00151 relPhoton_.add(gen.getIsRelevantToPhoton(name, index)); 00152 relProton_.add(gen.getIsRelevantToProton(name, index)); 00153 }catch(Throwable err){ 00154 System.out.println(err.getMessage()); 00155 } 00156 00157 00158 // ++aindex; 00159 } 00160 } 00161 return(this); 00162 } 00163 00168 public Vector<Integer> getparameterId(){ 00169 //Vector<Integer> ids = new Vector<Integer>(); 00170 00171 return(ids); 00172 } 00173 00178 public Vector<String> getname(){ 00179 //Vector<String> names = new Vector<String>(); 00180 return(names); 00181 } 00182 00187 public Vector<Integer> getivalue(){ 00188 //Vector<Integer> ivalues = new Vector<Integer>(); 00189 00190 return(ivalues); 00191 } 00192 00197 public Vector<Double> getrvalue(){ 00198 //Vector<Double> rvalues = new Vector<Double>(); 00199 00200 return(rvalues); 00201 } 00202 00207 public Vector<Integer> getaindices(){ 00208 return(aindices); 00209 } 00210 00215 public String toString(){ 00216 00217 //get rid of all the .s in the name 00218 00219 String name = gen.toString(); 00220 int ii = name.indexOf("."); 00221 00222 while(ii>-1){ 00223 name = name.substring(0,ii)+name.substring(ii+1); 00224 ii = name.indexOf("."); 00225 } 00226 00227 ii = name.indexOf("-"); 00228 00229 return(name.substring(0,ii)+name.substring(ii+1)); 00230 } 00231 00236 public Vector<Boolean> getrelPhoton(){ 00237 return relPhoton_; 00238 } 00239 00240 public Vector<Boolean> getrelProton(){ 00241 return(relProton_); 00242 } 00243 00244 00248 public Generator generator(){ 00249 return gen; 00250 } 00251 00252 } 00253 00254
Generated Wed Jan 17 09:14:27 GMT 2007