public Vector getAssociatedLevelLists() { Vector levelLists = new Vector(); Vector endPts = CollectionHelper.makeVector("Keyword"); Hashtable keywordParents = oncotcap.Oncotcap.getDataSource() .getParentTree( "Keyword", endPts, CollectionHelper.makeVector(this), TreeDisplayModePanel.ROOT); // Take each of the parents and get the associated level lists if (keywordParents.size() <= 0) return levelLists; Hashtable levelListsHashtable = oncotcap.Oncotcap.getDataSource() .getInstanceTree( "EnumLevelList", new Vector(), makeLevelListFilter(keywordParents), TreeDisplayModePanel.ROOT); for (Enumeration e = keywordParents.keys(); e.hasMoreElements(); ) { System.out.println("Keyword.getAssociatedLevelLists: " + e.nextElement()); } // Collect all the level lists from the hashtable Vector selectedItems = CollectionHelper.makeVector(keyword); for (Enumeration e = levelListsHashtable.keys(); e.hasMoreElements(); ) { Object obj = e.nextElement(); if (obj instanceof EnumLevelList) { levelLists.addElement(obj); } } return levelLists; }
private static PreparedStatement getInsertSQL(Connection conn, String tableName, Hashtable table) throws SQLException { String sql = "INSERT INTO " + tableName + " ( \n"; String sqlKeys = " "; String sqlValues = " "; Enumeration e = table.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (!MSUtil.isNull(MSUtil.get(table, key))) { sqlKeys += "\t" + key + ",\n"; sqlValues += "\t?,\n"; } } sql += sqlKeys.substring(0, sqlKeys.length() - 2) + "\n ) VALUES ( \n" + sqlValues.substring(0, sqlValues.length() - 2) + "\n)\n"; // System.out.println("THE QUERY IS " +sql); PreparedStatement ps = DBManagement.getStatement(conn, sql); e = table.keys(); int columnIndx = 1; while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = MSUtil.get(table, key); if (!MSUtil.isNull(value)) ps.setString(columnIndx++, value); } MSUtil.writeLog("\n\n" + ps + "\n\n"); return ps; }
/** * If a mapping occurs more than once will rename instance to "x 1", "x 2"... and so on where x is * the mapping in question */ public LabelMapping getUniquifiedMappings() { Hashtable totals = new Hashtable(); for (Enumeration e = mappings_.keys(); e.hasMoreElements(); ) { Object key = e.nextElement(); Object mapping = mappings_.get(key); int count = 1; if (totals.containsKey(mapping)) { count = ((Integer) totals.get(mapping)).intValue() + 1; } totals.put(mapping, new Integer(count)); } Hashtable counts = new Hashtable(); Hashtable result = new Hashtable(); for (Enumeration e = mappings_.keys(); e.hasMoreElements(); ) { Object key = e.nextElement(); Object mapping = mappings_.get(key); int total = ((Integer) totals.get(mapping)).intValue(); if (total == 1) { result.put(key, mapping); } else { int count = 1; if (counts.containsKey(mapping)) { count = ((Integer) counts.get(mapping)).intValue() + 1; } counts.put(mapping, new Integer(count)); result.put(key, mapping + " " + count); } } return new LabelMapping(result); }
///////////////////////////////////////////////////////// Crear un archivo de un grafo // /////////////////////////////////////////////// public void guardar(Grafo g, String n) throws IOException { File archivo = new File( "C:/Documents and Settings/Administrator/Desktop/Proyecto1 06-40476,06-40273/bin/doc/Guardado.txt"); int count; int tamL; int tamV; FileWriter txt = new FileWriter(archivo); PrintWriter out = new PrintWriter(txt); tamL = CjtoLados.size(); tamV = CjtoVertice.size(); out.println("Grafo g\n"); out.println("Numero de Vertices: " + tamV); out.println("Numeros de Lados: " + tamL); out.println("Vértices:"); for (Enumeration e = CjtoVertice.keys(); e.hasMoreElements(); ) { String X = (String) e.nextElement(); Vertice y = (Vertice) CjtoVertice.get(X); out.println(X); } out.println("Lados:"); for (Enumeration e = CjtoLados.keys(); e.hasMoreElements(); ) { String v = (String) e.nextElement(); Lado w = (Lado) CjtoLados.get(v); out.println(v); } out.close(); };
/** Dump the dependency information loaded from the classes to the Ant log */ private void dumpDependencies() { log("Reverse Dependency Dump for " + affectedClassMap.size() + " classes:", Project.MSG_DEBUG); Enumeration classEnum = affectedClassMap.keys(); while (classEnum.hasMoreElements()) { String className = (String) classEnum.nextElement(); log(" Class " + className + " affects:", Project.MSG_DEBUG); Hashtable affectedClasses = (Hashtable) affectedClassMap.get(className); Enumeration affectedClassEnum = affectedClasses.keys(); while (affectedClassEnum.hasMoreElements()) { String affectedClass = (String) affectedClassEnum.nextElement(); ClassFileInfo info = (ClassFileInfo) affectedClasses.get(affectedClass); log(" " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG); } } if (classpathDependencies != null) { log("Classpath file dependencies (Forward):", Project.MSG_DEBUG); Enumeration classpathEnum = classpathDependencies.keys(); while (classpathEnum.hasMoreElements()) { String className = (String) classpathEnum.nextElement(); log(" Class " + className + " depends on:", Project.MSG_DEBUG); Hashtable dependencies = (Hashtable) classpathDependencies.get(className); Enumeration classpathFileEnum = dependencies.elements(); while (classpathFileEnum.hasMoreElements()) { File classpathFile = (File) classpathFileEnum.nextElement(); log(" " + classpathFile.getPath(), Project.MSG_DEBUG); } } } }
public static void main(String[] args) { // Creating a Hash Table Hashtable hash = new Hashtable(); // Add items to the hash table hash.put("John", new Double(100)); // key value pair hash.put("Peter", new Double(200)); hash.put("Clark", new Double(300)); hash.put("Bruce", new Double(400)); // Get a particular value double bal = (Double) hash.get("Aditya"); System.out.println("Retrieving an entry "); System.out.println("Aditya's balance : " + bal); // Iterate through all the values inside the hash System.out.println("Printing the values of the hash"); Enumeration val = hash.keys(); while (val.hasMoreElements()) { String str = (String) val.nextElement(); System.out.println(str + " : " + hash.get(str)); } // Changing the entry of the table System.out.println("Changing an entry of the table "); double changeBal = (Double) hash.get("Clark"); hash.put("Clark", new Double(changeBal + 300)); // Iterate through all the values inside the hash Enumeration newValues = hash.keys(); while (newValues.hasMoreElements()) { String str = (String) newValues.nextElement(); System.out.println(str + " : " + hash.get(str)); } }
public void write(Writer writer, int linebreakEvery) throws IOException { writer.write(name + " {\n"); Enumeration<String> keys = fields.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (key.length() == 1) continue; writer.write("\t" + key + " = " + fields.get(key) + "\n"); } writer.write("\n"); int linesWritten = 0; for (int i = 0; i < lines.length; i++) { writer.write("\t" + lines[i] + "\n"); linesWritten++; if (linebreakEvery != 0 && linesWritten % linebreakEvery == 0) writer.write("\n"); } writer.write("\n"); keys = fields.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (key.length() != 1) continue; writer.write("\t" + key + " = " + fields.get(key) + "\n"); } writer.write("}"); }
/** * This utility method is used to get the String representation of this object of <code> * ApplicationStateDetails</code>. * * @return The String representation of this object. * @since Tifosi2.0 */ public String toString() { String baseString = super.toString(); StringBuffer strBuf = new StringBuffer(); strBuf.append(baseString); strBuf.append(""); strBuf.append("Application State Details = "); strBuf.append("["); strBuf.append("Launch Time = "); strBuf.append(m_launchTime); strBuf.append(", "); strBuf.append("Kill Time = "); strBuf.append(m_killTime); strBuf.append(", "); strBuf.append("Application GUID = "); strBuf.append(m_strAppGUID); strBuf.append(", "); strBuf.append("Application Version = "); strBuf.append(m_strAppVersion); strBuf.append(", "); Enumeration enums = m_serviceStates.keys(); if (enums != null) { strBuf.append("Service States :: "); while (enums.hasMoreElements()) { String instName = (String) enums.nextElement(); strBuf.append(instName); strBuf.append(", "); ServiceInstanceStateDetails status = (ServiceInstanceStateDetails) m_serviceStates.get(instName); strBuf.append(status.toString()); strBuf.append(", "); } } Enumeration traceEnums = m_serviceExceptionTraces.keys(); if (enums != null) { strBuf.append("Service Error Trace = "); while (traceEnums.hasMoreElements()) { String instName = (String) traceEnums.nextElement(); strBuf.append(instName); strBuf.append(", "); String status = (String) m_serviceExceptionTraces.get(instName); strBuf.append(status); strBuf.append(", "); } } return strBuf.toString(); }
/** * This method writes this object of <code>ApplicationStateDetails</code> to the specified output * stream object. * * @param out DataOutput object * @param versionNo * @throws IOException if an error occurs while converting data and writing it to a binary stream. * @since Tifosi2.0 */ public void toStream(DataOutput out, int versionNo) throws IOException { super.toStream(out, versionNo); out.writeLong(m_launchTime); out.writeLong(m_killTime); writeUTF(out, m_strAppGUID); writeUTF(out, m_strAppVersion); out.writeInt(m_serviceStates.size()); Enumeration enums = m_serviceStates.keys(); while (enums.hasMoreElements()) { String instName = (String) enums.nextElement(); ServiceInstanceStateDetails status = (ServiceInstanceStateDetails) m_serviceStates.get(instName); UTFReaderWriter.writeUTF(out, instName); status.toStream(out, versionNo); } out.writeInt(m_serviceExceptionTraces.size()); Enumeration traceEnums = m_serviceExceptionTraces.keys(); while (traceEnums.hasMoreElements()) { String instName = (String) traceEnums.nextElement(); String trace = (String) m_serviceExceptionTraces.get(instName); UTFReaderWriter.writeUTF(out, instName); UTFReaderWriter.writeUTF(out, trace); } out.writeInt(m_debugRoutes.size()); Iterator debugRoutes = getDebugRoutes(); while (debugRoutes.hasNext()) { String routeGUID = (String) debugRoutes.next(); UTFReaderWriter.writeUTF(out, routeGUID); } out.writeInt(m_pendingDebugRoutesForClosure.size()); Iterator pendingDebugRoutesForClosure = getPendingDebugRoutesForClosure(); while (pendingDebugRoutesForClosure.hasNext()) { String routeGUID = (String) pendingDebugRoutesForClosure.next(); UTFReaderWriter.writeUTF(out, routeGUID); } out.writeInt(m_previousSyncPeers.size()); Iterator previousSynchPeers = getPreviousSynchPeers(); while (previousSynchPeers.hasNext()) { String peerName = (String) previousSynchPeers.next(); UTFReaderWriter.writeUTF(out, peerName); } }
void fireObjectsNotification() throws Exception { String strBody = ""; String strUrl = ""; synchronized (m_mxObjectNotify) { if (m_strObjectNotifyUrl.length() == 0) return; strUrl = getNet().resolveUrl(m_strObjectNotifyUrl); Enumeration valsNotify = m_hashSrcIDAndObject.elements(); Enumeration keysNotify = m_hashSrcIDAndObject.keys(); while (valsNotify.hasMoreElements()) { Integer nSrcID = (Integer) keysNotify.nextElement(); Hashtable hashObject = (Hashtable) valsNotify.nextElement(); Enumeration valsObject = hashObject.elements(); Enumeration keysObject = hashObject.keys(); while (valsObject.hasMoreElements()) { int nNotifyType = ((Integer) valsObject.nextElement()).intValue(); String strObject = (String) keysObject.nextElement(); if (nNotifyType == enNone.intValue()) continue; // This is slow operation /* if ( nNotifyType == enDelete.intValue() ) { IDBResult res = getDB().executeSQL("SELECT object FROM object_values where object=? LIMIT 1 OFFSET 0", strObject ); if ( !res.isOneEnd() ) nNotifyType = enUpdate.intValue(); } */ if (strBody.length() > 0) strBody += "&rho_callback=1&"; if (nNotifyType == enDelete.intValue()) { strBody += "deleted[][object]=" + strObject; strBody += "&deleted[][source_id]=" + nSrcID; } else if (nNotifyType == enUpdate.intValue()) { strBody += "updated[][object]=" + strObject; strBody += "&updated[][source_id]=" + nSrcID; } else if (nNotifyType == enCreate.intValue()) { strBody += "created[][object]=" + strObject; strBody += "&created[][source_id]=" + nSrcID; } hashObject.put(strObject, enNone); } } if (strBody.length() == 0) return; } callNotify(new SyncNotification(strUrl, "", false), strBody); }
/** * 判断相等 * * @param params0 * @param params1 * @return */ public static boolean equals(Hashtable params0, Hashtable params1) { // 相等,包括均为空 if (params0 == null && params1 == null) { return true; } // 非空 if (params0 == null || params1 == null) { return false; } if (params0.size() != params1.size()) { return false; } // 键和值相等 for (Enumeration e = params0.keys(); e.hasMoreElements(); ) { String key0 = (String) e.nextElement(); String val0 = (String) params0.get(key0); if (params1.containsKey(key0)) { String val1 = (String) params1.get(key0); if (!val0.equals(val1)) { return false; } } else { return false; } } return true; }
/** 打开查询结果 */ public static String[] openQuery(Hashtable params) { JParamObject PO = new JParamObject(); for (Enumeration e = params.keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String val = (String) params.get(key); PO.SetValueByParamName(key, val); } String[] queryResult = new String[2]; JResponseObject RO = (JResponseObject) JActiveDComDM.AbstractDataActiveFramework.InvokeObjectMethod( "DataReport", "OpenQuery", PO, ""); String XMLStr = (String) RO.ResponseObject; if (RO != null && RO.ResponseObject != null) { XMLStr = (String) RO.ResponseObject; JXMLBaseObject XMLObj = new JXMLBaseObject(XMLStr); Element queryElmt = XMLObj.GetElementByName("Query"); // 格式 queryResult[0] = queryElmt.getAttributeValue("QueryFormat"); // 数据 queryResult[0] = queryElmt.getAttributeValue("QueryData"); } return queryResult; }
/** returns a string representation of all the system properties */ public String toString() { Enumeration<String> enm; String result; String key; Vector<String> keys; int i; String value; result = ""; keys = new Vector<String>(); // get names and sort them enm = m_Info.keys(); while (enm.hasMoreElements()) keys.add(enm.nextElement()); Collections.sort(keys); // generate result for (i = 0; i < keys.size(); i++) { key = keys.get(i).toString(); value = m_Info.get(key).toString(); if (key.equals("line.separator")) value = Utils.backQuoteChars(value); result += key + ": " + value + "\n"; } return result; }
/** * Construct a service description for registrating with JmDNS. The properties hashtable must map * property names to either Strings or byte arrays describing the property values. * * @param type fully qualified service type name, such as <code>_http._tcp.local.</code>. * @param name unqualified service instance name, such as <code>foobar</code> * @param port the local port on which the service runs * @param weight weight of the service * @param priority priority of the service * @param props properties describing the service */ public ServiceInfo( String type, String name, int port, int weight, int priority, Hashtable props) { this(type, name, port, weight, priority, new byte[0]); if (props != null) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(256); for (Enumeration e = props.keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); Object val = props.get(key); ByteArrayOutputStream out2 = new ByteArrayOutputStream(100); writeUTF(out2, key); if (val instanceof String) { out2.write('='); writeUTF(out2, (String) val); } else { if (val instanceof byte[]) { out2.write('='); byte[] bval = (byte[]) val; out2.write(bval, 0, bval.length); } else { if (val != NO_VALUE) { throw new IllegalArgumentException("invalid property value: " + val); } } } byte data[] = out2.toByteArray(); out.write(data.length); out.write(data, 0, data.length); } this.text = out.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected exception: " + e); } } }
public static void storeDevices(Hashtable devices, String selected) { File cf = getConfigFile(); if (cf == null) { return; } FileWriter fw = null; try { fw = new FileWriter(cf, false); for (Enumeration i = devices.keys(); i.hasMoreElements(); ) { String addr = (String) i.nextElement(); DeviceInfo di = (DeviceInfo) devices.get(addr); fw.write(devicePrefix + di.saveAsLine() + "\n"); } if (selected != null) { fw.write(selectedPrefix + selected + "\n"); } for (Enumeration en = properties.propertyNames(); en.hasMoreElements(); ) { String name = (String) en.nextElement(); fw.write(name + "=" + properties.getProperty(name) + "\n"); } fw.flush(); } catch (Throwable e) { Logger.debug(e); return; } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { } } } }
/** Method to eliminate all LSPs. It is meant to be used in case of ROADM safe shut down. */ public void killAllLSP() { log.info("Killing All LSPs"); Enumeration<LSPKey> e = LSPList.keys(); while (e.hasMoreElements()) { LSPList.remove(e.nextElement()); } }
/** * Temporary release objects. The memory is not actually released and instances are retained for * reuse. */ public static void release() { if (verbose) { if (Log.isLoggable(Log.TRACE)) { Log.trace(TAG_LOG, "Releasing all objects in the pool"); } } // Move all the used objects into the empty ones synchronized (emptyPool) { Enumeration keys = usedPool.keys(); while (keys.hasMoreElements()) { Class klass = (Class) keys.nextElement(); Vector u = (Vector) usedPool.get(klass); Vector e = (Vector) emptyPool.get(klass); for (int i = 0; i < u.size(); ++i) { Object o = u.elementAt(i); if (e == null) { e = new Vector(); emptyPool.put(klass, e); } e.addElement(o); } u.removeAllElements(); } // Dump stats dumpStats(); } }
public void insertOrUpdate(Hashtable resources) throws Exception { Enumeration en = resources.keys(); while (en.hasMoreElements()) { BaseUnit res = (BaseUnit) resources.get(en.nextElement()); insertOrUpdate(res); } }
@Override public boolean tick(Tickable ticking, int tickID) { final MOB mob = (MOB) affected; if (mob == null) return false; if (song == null) { if ((whom == null) || (commonRoomSet == null) || (!commonRoomSet.contains(whom.location())) || (CMLib.flags().isSleeping(invoker)) || (!CMLib.flags().canBeSeenBy(whom, invoker))) return unsingMe(mob, null); } if ((whom != null) && (song != null) && (affected == invoker()) && (CMLib.dice().rollPercentage() < 10)) { final Hashtable<Integer, Integer> H = getSongBenefits(song); final Vector<Integer> V = new Vector<Integer>(); for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) V.addElement(e.nextElement()); final Integer I = V.elementAt(CMLib.dice().roll(1, V.size(), -1)); final String[] chk = stuff[I.intValue()]; invoker() .location() .show(invoker(), this, whom, CMMsg.MSG_SPEAK, L("<S-NAME> sing(s) '@x1'.", chk[3])); } if (!super.tick(ticking, tickID)) return false; return true; }
public <E extends IEntity> Integer fetchEntitiesCount( Class<E> inEntityClass, Hashtable<String, Object> criteria) { String entityClsName = inEntityClass.getSimpleName(); StringBuffer sQuery = new StringBuffer(); sQuery .append("SELECT count(instance) from ") .append(entityClsName.toString()) .append(" instance "); if (criteria != null && !criteria.isEmpty()) { sQuery.append("where "); } Iterator<Entry<String, Object>> it = criteria.entrySet().iterator(); while (it.hasNext()) { Entry<String, Object> pairs = it.next(); sQuery.append("instance.").append(pairs.getKey()).append("=:").append(pairs.getKey()); // it.remove(); if (it.hasNext()) sQuery.append(" AND "); } Query query = entityManager.createQuery(sQuery.toString()); Enumeration<String> keys = criteria.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); query.setParameter(key, criteria.get(key)); } Long count = (Long) query.getSingleResult(); return Integer.valueOf(count.toString()); }
public void deleteAllBaseUnitsByPlanet(String planet) { Hashtable ht = null; try { ht = getAll(); } catch (Exception e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } if (ht == null) return; Enumeration ex = ht.keys(); while (ex.hasMoreElements()) { String key = String.valueOf(ex.nextElement()); BaseUnit bu = (BaseUnit) ht.get(key); if (bu.getMissionId().equals(planet)) { try { delete(bu); } catch (Exception e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } } } }
static void dumpToFile( String name1, String name2, OutputStream ostream, Hashtable<String, PkgEntry> tbl1, Hashtable<String, PkgEntry> tbl2) { List<String> keyList = new ArrayList<String>(); for (String x : Collections.list(tbl1.keys())) { keyList.add(x); } Collections.sort(keyList); PrintWriter pw = null; pw = new PrintWriter(new OutputStreamWriter(ostream)); pw.printf("\t%s\t%s\n", name1, name2); long sum1 = 0L; long sum2 = 0L; for (String x : keyList) { pw.printf("%s\t%s\t%s\n", x, tbl1.get(x).getSize() / 1024, tbl2.get(x).getSize() / 1024); sum1 += tbl1.get(x).getSize(); sum2 += tbl2.get(x).getSize(); } pw.printf("Total\t%s\t%s\n", sum1 / 1024, sum2 / 1024); pw.flush(); }
/** * Dump the attributes that are attached to the file state * * @param out PrintStream */ public final void DumpAttributes(PrintStream out) { // Check if there are any attributes if (m_cache != null) { // Enumerate the available attribute objects Enumeration names = m_cache.keys(); while (names.hasMoreElements()) { // Get the current attribute name String name = (String) names.nextElement(); // Get the associated attribute object Object attrib = m_cache.get(name); // Output the attribute details out.println("++ " + name + " : " + attrib); } } else out.println("++ No Attributes"); }
/** * Writes data to given socket * * @param id a Socket * @throws IOException */ public void writeData(Socket id) throws IOException { // checkSanity(); if (_hdr != null) _hdr.writeData(id); if (_clientHandle != null) _clientHandle.writeData(id); if (_context != null) _context.writeData(id); for (Enumeration e = _clientSIs.elements(); e.hasMoreElements(); ) { COPSClientSI clientSI = (COPSClientSI) e.nextElement(); clientSI.writeData(id); } // Display any local decisions for (Enumeration e = _decisions.keys(); e.hasMoreElements(); ) { COPSContext context = (COPSContext) e.nextElement(); Vector v = (Vector) _decisions.get(context); context.writeData(id); for (Enumeration ee = v.elements(); e.hasMoreElements(); ) { COPSLPDPDecision decision = (COPSLPDPDecision) ee.nextElement(); decision.writeData(id); } } if (_integrity != null) _integrity.writeData(id); }
public String[] getKeys() { String[] keys = new String[data.size()]; int index = 0; Enumeration ks = data.keys(); while (ks.hasMoreElements()) keys[index++] = (String) ks.nextElement(); return keys; }
/** * Set the message length, base on the set of objects it contains * * @throws COPSException */ protected void setMsgLength() throws COPSException { short len = 0; if (_clientHandle != null) len += _clientHandle.getDataLength(); if (_context != null) len += _context.getDataLength(); for (Enumeration e = _clientSIs.elements(); e.hasMoreElements(); ) { COPSClientSI clientSI = (COPSClientSI) e.nextElement(); len += clientSI.getDataLength(); } // Display any local decisions for (Enumeration e = _decisions.keys(); e.hasMoreElements(); ) { COPSContext context = (COPSContext) e.nextElement(); Vector v = (Vector) _decisions.get(context); len += context.getDataLength(); for (Enumeration ee = v.elements(); e.hasMoreElements(); ) { COPSLPDPDecision decision = (COPSLPDPDecision) ee.nextElement(); len += decision.getDataLength(); } } if (_integrity != null) { len += _integrity.getDataLength(); } _hdr.setMsgLength((int) len); }
protected void printIRHelper() { PrintWriter ps = openOutput(name + "IRHelper"); if (ps == null) { return; } printPackage(ps); ps.println(Environment.NL + "/**"); ps.println(" * This class contains generated Interface Repository information."); ps.println(" * @author JacORB IDL compiler."); ps.println(" */" + Environment.NL); ps.println("public class " + name + "IRHelper"); ps.println("{"); String HASHTABLE = System.getProperty("java.version").startsWith("1.1") ? "com.sun.java.util.collections.Hashtable" : "java.util.Hashtable"; ps.println("\tpublic static " + HASHTABLE + " irInfo = new " + HASHTABLE + "();"); ps.println("\tstatic"); ps.println("\t{"); body.getIRInfo(irInfoTable); for (Enumeration e = irInfoTable.keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); ps.println("\t\tirInfo.put(\"" + key + "\", \"" + (String) irInfoTable.get(key) + "\");"); } ps.println("\t}"); ps.println("}"); ps.close(); }
/** * Write an object textual description in the output stream * * @param os an OutputStream * @throws IOException */ public void dump(OutputStream os) throws IOException { _hdr.dump(os); if (_clientHandle != null) _clientHandle.dump(os); if (_context != null) _context.dump(os); for (Enumeration e = _clientSIs.elements(); e.hasMoreElements(); ) { COPSClientSI clientSI = (COPSClientSI) e.nextElement(); clientSI.dump(os); } // Display any local decisions for (Enumeration e = _decisions.keys(); e.hasMoreElements(); ) { COPSContext context = (COPSContext) e.nextElement(); Vector v = (Vector) _decisions.get(context); context.dump(os); for (Enumeration ee = v.elements(); e.hasMoreElements(); ) { COPSLPDPDecision decision = (COPSLPDPDecision) ee.nextElement(); decision.dump(os); } } if (_integrity != null) { _integrity.dump(os); } }
/** * Takes a table of nodes and adds a weighted score to each node score in the table. A vector of * nodes that we want to be near is also taken as an argument. Here are the rules for scoring: If * a node is two away from a node in the desired set of nodes it gets 100. Otherwise it gets 0. * * @param board the game board * @param nodesIn the table of nodes to evaluate: Hashtable<Integer,Integer> * @param nodeSet the set of desired nodes * @param weight the score multiplier */ protected void bestSpot2AwayFromANodeSet( SOCBoard board, Hashtable nodesIn, Vector nodeSet, int weight) { Enumeration nodesInEnum = nodesIn.keys(); // <Integer> while (nodesInEnum.hasMoreElements()) { Integer nodeCoord = (Integer) nodesInEnum.nextElement(); int node = nodeCoord.intValue(); int score = 0; final int oldScore = ((Integer) nodesIn.get(nodeCoord)).intValue(); Enumeration nodeSetEnum = nodeSet.elements(); while (nodeSetEnum.hasMoreElements()) { int target = ((Integer) nodeSetEnum.nextElement()).intValue(); if (node == target) { break; } else if (board.isNode2AwayFromNode(node, target)) { score = 100; } } /** multiply by weight */ score *= weight; nodesIn.put(nodeCoord, new Integer(oldScore + score)); // log.debug("BS2AFANS -- put node "+Integer.toHexString(node)+" with old score "+oldScore+" + // new score "+score); } }
/** * Find an element in the list. * * <p>This is a little more complex than the simple lookup since it might be that we are indexing * with a class and the list contains interfaces. * * <p>Since the hashtable lookup is a lot faster than the linear search we add the result of the * linear search to the hashtable so that the next time we need not do it. * * @return Checklist or null if noone exist. * @param cls the class to lookup. */ private static Checklist lookupChecklist(Class cls) { if (lists.contains(cls)) { return (Checklist) lists.get(cls); } // Now lets search Enumeration enumeration = lists.keys(); while (enumeration.hasMoreElements()) { Object clazz = enumeration.nextElement(); Class[] intfs = cls.getInterfaces(); for (int i = 0; i < intfs.length; i++) { if (intfs[i].equals(clazz)) { // We found it! Checklist chlist = (Checklist) lists.get(clazz); // Enter the class to speed up the next search. lists.put(cls, chlist); return chlist; } } } return null; }