void Save() throws RemoveException, FinderException, CreateException { // System.out.println ("PropertySet::Save"); for (Entry<String, T> e : original.entrySet()) { if (!current.containsKey(e.getKey())) { // System.out.println ("PropertySet::Save Delete "+e.getValue()); DeleteEntry(e.getValue()); } } for (Entry<String, T> e : current.entrySet()) { String key = e.getKey(); if (original.containsKey(key)) { // Property o = original.get(key); // Property c = e.getValue(); // System.out.println ("PropertySet::Save original "+o.getName()+"->"+o.getValue()); // System.out.println ("PropertySet::Save current "+c.getName()+"->"+c.getValue()); SetEntry(e.getValue()); } else { // System.out.println ("PropertySet::Save insert "+e.getValue()); InsertEntry(e.getValue()); } } original.clear(); original.putAll(current); }
/** Sets up all parameters with target Graph target */ public MoleculeParameters(Molecule target) { // automatically set initial individuals size range int vertices = target.getVerticesSize(); verticesInterval.set(Math.max(2, vertices / 2), vertices * 2); cyclesInterval.set(0, target.getNumberOfCycles() * 2); // insure that all possible vertex and edge types are in initial population in roughly equal // quantities java.util.Hashtable elements = new java.util.Hashtable(); for (VertexIterator v = target.getVertexIterator(); v.more(); v.next()) { String s = v.vertex().toString(); if (!elements.containsKey(s)) { elements.put(s, s); try { provider.add((Vertex) v.vertex().clone()); } catch (CloneNotSupportedException e) { Error.fatal("can't clone vertex: " + e); } } } for (EdgeIterator e = target.getEdgeIterator(); e.more(); e.next()) { String s = e.edge().toString(); if (!elements.containsKey(s)) { elements.put(s, s); try { provider.add((Edge) e.edge().clone()); } catch (CloneNotSupportedException ee) { Error.fatal("can't clone edge: " + ee); } } } setParameters(target); }
@Override public void configure(Hashtable /*<String, String>*/ data) throws RuntimeException { if (data.containsKey("IP")) { try { address = InetAddress.getByName((String) data.get("IP")); } catch (UnknownHostException e) { throw new RuntimeException("Unknown host: " + data.get("IP"), e); } } else { throw new RuntimeException("The configuration parameter 'IP' is required!"); } if (data.containsKey("Port")) { port = Integer.parseInt((String) data.get("Port")); } else { throw new RuntimeException("The configuration parameter 'Port' is required!"); } if (data.containsKey("Serializer")) { try { se = (Serializer) Class.forName((String) data.get("Serializer")).newInstance(); } catch (Exception e) { throw new RuntimeException("Error creating serializer object.", e); } } if (data.containsKey("Name")) { this.name = (String) data.get("Name"); } else throw new RuntimeException("Signal name is missing in LCF"); }
private boolean checkForSubType( TypeDeclaration curTypeDecl, Hashtable knownSubTypes, Hashtable finishedTypes, boolean descent) { if (curTypeDecl == null) { return false; } if (curTypeDecl == _localType) { return true; } if (knownSubTypes.containsKey(curTypeDecl)) { return true; } if (finishedTypes.containsKey(curTypeDecl)) { return false; } boolean result = false; if (curTypeDecl instanceof ClassDeclaration) { ClassDeclaration classDecl = (ClassDeclaration) curTypeDecl; if (classDecl.hasBaseClass()) { if (descent) { if (checkForSubType( classDecl.getBaseClass().getReferenceBaseTypeDecl(), knownSubTypes, finishedTypes, true)) { knownSubTypes.put(curTypeDecl, curTypeDecl); result = true; } } else { if (_localType == classDecl.getBaseClass().getReferenceBaseTypeDecl()) { knownSubTypes.put(curTypeDecl, curTypeDecl); result = true; } } } } if (!result) { for (TypeIterator it = curTypeDecl.getBaseInterfaces().getIterator(); it.hasNext(); ) { if (descent) { if (checkForSubType( it.getNext().getReferenceBaseTypeDecl(), knownSubTypes, finishedTypes, true)) { knownSubTypes.put(curTypeDecl, curTypeDecl); result = true; } } else { if (_localType == it.getNext().getReferenceBaseTypeDecl()) { knownSubTypes.put(curTypeDecl, curTypeDecl); result = true; } } } } finishedTypes.put(curTypeDecl, curTypeDecl); return result; }
public Document getDocument(String function, Hashtable params) throws XFormsException { Hashtable ret = runFunc(function, params); if (!ret.containsKey("status")) { throw new XFormsException("XML-RPC return hash has no status"); } String status = (String) ret.get("status"); if (status.equals("error")) { if (!ret.containsKey("error")) { throw new XFormsException("Unknown error: cannot find XML-RPC error code"); } String s = (String) ret.get("error"); throw new XFormsException(s); } byte[] docbytes = (byte[]) ret.get("doc"); Document doc = null; try { DocTransformer dt = new DocTransformer(docbytes); doc = dt.getDoc(); } catch (Exception e) { throw new XFormsException(e); } return doc; }
public Integer getWeight(HybridNetwork n, MyNode v) { if (nodeToCluster.containsKey(v)) { BitSet b = nodeToCluster.get(v); if (clusterToNumber.containsKey(b)) return clusterToNumber.get(b); } return null; }
public synchronized void registerService( ConnectionPoolConfiguration config, List<TaskStub> taskList) throws RegistrationException { ConnectionPool pool = ConnectionPool.createFromConfiguration(config); for (Iterator<TaskStub> it = taskList.iterator(); it.hasNext(); ) { TaskStub stub = it.next(); String name = stub.getName(); System.out.println("registering task: " + name); if (registeredServices.containsKey(name)) { if (!registeredServices.get(name).equals(stub)) throw new RegistrationException("TASK CONFLICT: " + name); } else { System.out.println("not found in registeredServices"); registeredServices.put(name, stub); } if (connectionResources.containsKey(name)) { System.out.println("found in connectionResources"); stub.setBalancer(connectionResources.get(name)); connectionResources.get(name).addPool(pool); } else { LoadBalancer balancer = new RoundRobinBalancer(); balancer.addPool(pool); stub.setBalancer(balancer); connectionResources.put(name, balancer); } } if (!connectionPools.contains(pool)) { connectionPools.add(pool); } registeredEndpoints.add(new InetSocketAddress(config.getRemoteHost(), config.getPort())); notifyChanged(); }
/** * Interface TestListener. * * <p>A Test is finished. */ public void endTest(Test test) { // Fix for bug #5637 - if a junit.extensions.TestSetup is // used and throws an exception during setUp then startTest // would never have been called if (!testStarts.containsKey(test)) { startTest(test); } Element currentTest = null; if (!failedTests.containsKey(test)) { currentTest = doc.createElement(TESTCASE); currentTest.setAttribute(ATTR_NAME, JUnitVersionHelper.getTestCaseName(test)); // a TestSuite can contain Tests from multiple classes, // even tests with the same name - disambiguate them. currentTest.setAttribute(ATTR_CLASSNAME, test.getClass().getName()); rootElement.appendChild(currentTest); testElements.put(test, currentTest); } else { currentTest = (Element) testElements.get(test); } Long l = (Long) testStarts.get(test); currentTest.setAttribute( ATTR_TIME, "" + ((System.currentTimeMillis() - l.longValue()) / 1000.0)); }
/** * 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); }
public ArrayList<Product> getTotalList(String type, String subType) { ArrayList<Product> total = new ArrayList<Product>(); if (type == "Recommended") { return recommended; } else { if (subType == "All") { if (categoryTable.containsKey(type)) { for (ArrayList<Product> al : totalItems.get(categoryTable.get(type))) { for (Product p : al) { total.add(p); } } } } else { if (categoryTable.containsKey(type)) { if (subcategoryTable.get(categoryTable.get(type)).containsKey(subType)) { for (Product p : totalItems .get(categoryTable.get(type)) .get(subcategoryTable.get(categoryTable.get(type)).get(subType))) { total.add(p); } } } } } return total; }
/** * Service to update a Bcid's metadata * * @param doi * @param webAddress * @param title * @param resourceTypeString * @param resourceTypesMinusDataset * @param identifier * @return */ @POST @Authenticated @Path("/update") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) public Response bcidUpdate( @FormParam("doi") String doi, @FormParam("webAddress") String webAddress, @FormParam("title") String title, @FormParam("resourceType") String resourceTypeString, @FormParam("resourceTypesMinusDataset") Integer resourceTypesMinusDataset, @FormParam("identifier") String identifier) { Hashtable<String, String> metadata; Hashtable<String, String> update = new Hashtable<String, String>(); BcidMinter bcidMinter = new BcidMinter(); if (identifier == null || identifier.isEmpty()) { throw new BadRequestException("You must include an identifier."); } if (!bcidMinter.userOwnsBcid(identifier, user.getUserId())) { throw new BadRequestException( "Either the identifier doesn't exist or you are not the owner."); } // get this BCID's metadata metadata = bcidMinter.getBcidMetadata(identifier); if (resourceTypesMinusDataset != null && resourceTypesMinusDataset > 0) { resourceTypeString = new ResourceTypes().get(resourceTypesMinusDataset).string; } // compare every field and if they don't match, add them to the update hashtable if (doi != null && (!metadata.containsKey("doi") || !metadata.get("doi").equals(doi))) { update.put("doi", doi); } if (webAddress != null && (!metadata.containsKey("webAddress") || !metadata.get("webAddress").equals(webAddress))) { update.put("webAddress", webAddress); } if (title != null && (!metadata.containsKey("title") || !metadata.get("title").equals(title))) { update.put("title", title); } if (resourceTypeString != null && (!metadata.containsKey("resourceType") || !metadata.get("resourceType").equals(resourceTypeString))) { update.put("resourceTypeString", resourceTypeString); } if (update.isEmpty()) { return Response.ok("{\"success\": \"Nothing needed to be updated.\"}").build(); // try to update the metadata by calling d.updateBcidMetadata } else if (bcidMinter.updateBcidMetadata(update, identifier)) { return Response.ok("{\"success\": \"BCID successfully updated.\"}").build(); } else { // if we are here, the Bcid wasn't found throw new BadRequestException("Bcid wasn't found"); } }
/** * Uses "ep" prefix to denote a checkbox with an engine pick up, and "es" for an engine set out. * * @param rl The routeLocation to show loco pick ups or set outs. */ protected void updateLocoPanes(RouteLocation rl) { if (Setup.isPrintHeadersEnabled()) { JLabel header = new JLabel(Tab + trainCommon.getPickupEngineHeader()); setLabelFont(header); pPickupLocos.add(header); JLabel headerDrop = new JLabel(Tab + trainCommon.getDropEngineHeader()); setLabelFont(headerDrop); pSetoutLocos.add(headerDrop); } // check for locos List<Engine> engList = engManager.getByTrainBlockingList(_train); for (Engine engine : engList) { if (engine.getRouteLocation() == rl && engine.getTrack() != null) { locoPane.setVisible(true); pPickupLocos.setVisible(true); rollingStock.add(engine); engine.addPropertyChangeListener(this); JCheckBox checkBox; if (checkBoxes.containsKey("ep" + engine.getId())) { checkBox = checkBoxes.get("ep" + engine.getId()); } else { checkBox = new JCheckBox(trainCommon.pickupEngine(engine)); setCheckBoxFont(checkBox); addCheckBoxAction(checkBox); checkBoxes.put("ep" + engine.getId(), checkBox); } if (isSetMode && !checkBox.isSelected()) { pPickupLocos.add(addSet(engine)); } else { pPickupLocos.add(checkBox); } } if (engine.getRouteDestination() == rl) { locoPane.setVisible(true); pSetoutLocos.setVisible(true); rollingStock.add(engine); engine.addPropertyChangeListener(this); JCheckBox checkBox; if (checkBoxes.containsKey("es" + engine.getId())) { checkBox = checkBoxes.get("es" + engine.getId()); } else { checkBox = new JCheckBox(trainCommon.dropEngine(engine)); setCheckBoxFont(checkBox); addCheckBoxAction(checkBox); checkBoxes.put("es" + engine.getId(), checkBox); } if (isSetMode && !checkBox.isSelected()) { pSetoutLocos.add(addSet(engine)); } else { pSetoutLocos.add(checkBox); } } } // pad the panels in case the horizontal scroll bar appears pPickupLocos.add(new JLabel(Space)); pSetoutLocos.add(new JLabel(Space)); }
/** * Function to handle the reception of missingpackets. * * @param sequenceNumber The sequenceNumber of the recieved packet. * @param i Redundant generation of the received packet that contains the desired data. * @param data The data of the received packet. */ public void receivedMissingPacket(long sequenceNumber, int i, byte[] data) { if (missingPackets.containsKey(Long.valueOf(sequenceNumber))) { missingPackets.remove(Long.valueOf(sequenceNumber)); if (!receivedPackets.containsKey(Long.valueOf(sequenceNumber))) { receivedPackets.put(new Long(sequenceNumber), (byte[]) getData((i), data)); } } }
/** * Removes a parameter from the design * * @param param the parameter to be removed. * @throws IllegalArgumentException if the parameter is unknown to the design. */ public void removeParameter(Parameter param) { if (stringParameterValues.containsKey(param)) { stringParameterValues.remove(param); } else if (numericalParameterValues.containsKey(param)) { numericalParameterValues.remove(param); } else { throw new IllegalArgumentException("Unknown parameter " + param.getName()); } }
/** * Gets the String representation of a value for a given parameter. * * @param param the parameter for which the value should be returned. * @return the string value for the given parameter * @throws IllegalArgumentException if the parameter is unknown to the design. */ public String getStringValue(Parameter param) { if (stringParameterValues.containsKey(param)) { return (stringParameterValues.get(param)); } else if (numericalParameterValues.containsKey(param)) { return Float.toString(numericalParameterValues.get(param)); } else { throw new IllegalArgumentException("Unknown parameter " + param.getName()); } }
public void CheckObjList(CM_SRC cm_src, TObj tobj) { TObj objlist[] = tobj.getTObjList(); if (objlist == null) return; for (int i = 0; i < objlist.length; i++) { TObj tmpobj = objlist[i]; CheckObjList(cm_src, tmpobj); String objname = tmpobj.getName(); String fullobjname = tmpobj.getName(); int idx; if ((idx = objname.indexOf('(')) > 0) { objname = objname.substring(0, idx).trim(); } if (tmpobj.getType() == C_FUNCTION_OBJECT) { tmpobj.setKeyValidation(100); if (objname.equals("main")) { mainflag = true; } else if (extern_main_flag(objname, fullobjname) == true) { mainflag = true; log.debug("extern find main", tmpobj.getName()); } else if (fullobjname.indexOf("(TPSVCINFO") > 0) { submainflag = true; if (!hsubmainname.containsKey(objname)) { Integer val = new Integer(0); hsubmainname.put(objname, val); } log.debug("find sub main", tmpobj.getName()); } else if (extern_sub_flag(objname, fullobjname) == true) { submainflag = true; if (!hsubmainname.containsKey(objname)) { Integer val = new Integer(0); hsubmainname.put(objname, val); } log.debug("extern find sub main", tmpobj.getName()); } else { if (!hfunname.containsKey(objname)) { // log.debug("push hash", objname); Integer val = new Integer(0); hfunname.put(objname, val); } } } if (tmpobj.getType() == C_FUNCTION_DECARE || tmpobj.getType() == C_FUNCTION_OBJECT) { TMeta mt[] = tmpobj.getTMetaList(); for (int k = 0; k < mt.length; k++) { if (mt[k].getName().equals("5100410")) { if (mt[k].getValue().startsWith("static ")) { hStaticfun.put(objname, objname); } } } } } }
/** * Checks the current instance against what is known about the structure of the data set so far. * If there is a nominal value for an attribute that was beleived to be numeric then all * previously seen values for this attribute are stored in a Hashtable. * * @param current a <code>ArrayList</code> value * @exception Exception if an error occurs * <pre><jml> * private_normal_behavior * requires: current != null; * also * private_exceptional_behavior * requires: current == null * || (* unrecognized object type in current *); * signals: (Exception); * </jml></pre> */ private void checkStructure(ArrayList<Object> current) throws Exception { if (current == null) { throw new Exception("current shouldn't be null in checkStructure"); } // initialize ranges, if necessary if (m_FirstCheck) { m_NominalAttributes.setUpper(current.size() - 1); m_StringAttributes.setUpper(current.size() - 1); m_FirstCheck = false; } for (int i = 0; i < current.size(); i++) { Object ob = current.get(i); if ((ob instanceof String) || (m_NominalAttributes.isInRange(i)) || (m_StringAttributes.isInRange(i))) { if (ob.toString().compareTo(m_MissingValue) == 0) { // do nothing } else { Hashtable<Object, Integer> tempHash = m_cumulativeStructure.get(i); if (!tempHash.containsKey(ob)) { // may have found a nominal value in what was previously thought to // be a numeric variable. if (tempHash.size() == 0) { for (int j = 0; j < m_cumulativeInstances.size(); j++) { ArrayList tempUpdate = ((ArrayList) m_cumulativeInstances.get(j)); Object tempO = tempUpdate.get(i); if (tempO instanceof String) { // must have been a missing value } else { if (!tempHash.containsKey(tempO)) { tempHash.put( new Double(((Double) tempO).doubleValue()), new Integer(tempHash.size())); } } } } int newIndex = tempHash.size(); tempHash.put(ob, new Integer(newIndex)); } } } else if (ob instanceof Double) { Hashtable<Object, Integer> tempHash = m_cumulativeStructure.get(i); if (tempHash.size() != 0) { if (!tempHash.containsKey(ob)) { int newIndex = tempHash.size(); tempHash.put(new Double(((Double) ob).doubleValue()), new Integer(newIndex)); } } } else { throw new Exception("Wrong object type in checkStructure!"); } } }
/** * Create an AbstractMessageHandler for dealing with a given message. * * @param connector The connector (used for responding to the message). * @param message The message in question. * @param ID The ID of the current agent. */ public AbstractMessageHandler create(String msgType) { // At least one must be non-null. if (!(defaultHandlers.containsKey(msgType) || customHandlers.containsKey(msgType))) { throw new LoggingRuntimeException( "Unknown message type: " + msgType.toString() + " >>NOT HANDLED."); } // Else, one or both can be null. Let the BifurcatedMessageHandler decide. return BifurcatedHandler.CreateHandler( defaultHandlers.get(msgType), customHandlers.get(msgType)); }
// Done !!! :D :D public void insertRecord(Hashtable<String, String> htblColNameValue, int numberOfRows) throws ClassNotFoundException, IOException, DBAppException { ArrayList<String> colName = DBApp.getKeysOfHashtable(htblColNameValue); for (int i = 0; i < colName.size(); i++) { if (!ColNameType.containsKey(colName.get(i))) throw new DBAppException(); } Page p = (Page) DBApp.readObj("src/classes/Datei/" + tableName + numberOfPages + ".class"); if (p.isFull()) { p = addPage(numberOfRows, colName); } int row = p.insert(htblColNameValue, colName); for (int i = 0; i < singleIndexedColumns.size(); i++) if (htblColNameValue.containsKey(singleIndexedColumns.get(i))) { LinearHashTable LHT = (LinearHashTable) DBApp.readObj( "src/classes/Datei/Hashtable#" + tableName + "#" + singleIndexedColumns.get(i) + ".class"); LHT.put(htblColNameValue.get(singleIndexedColumns.get(i)), p.getPageNumber() + "#" + row); DBApp.writeObj( LHT, "src/classes/Datei/Hashtable#" + tableName + "#" + singleIndexedColumns.get(i) + ".class"); } for (int i = 0; i < multiIndexedColumns.size(); i++) { String[] thisKDTreeColumns = multiIndexedColumns.get(i); boolean weNeedIt = true; for (int j = 0; j < thisKDTreeColumns.length; j++) weNeedIt = weNeedIt && htblColNameValue.containsKey(thisKDTreeColumns[j]); String thisKDTreeName = DBApp.getKDTreeName(thisKDTreeColumns); KDTree kdtree = (KDTree) DBApp.readObj( "src/classes/Datei/KDTree#" + tableName + "#" + thisKDTreeName + ".class"); kdtree.insert(p.getValues(row, thisKDTreeColumns), p.getPageNumber() + "#" + row); DBApp.writeObj( kdtree, "src/classes/Datei/KDTree#" + tableName + "#" + thisKDTreeName + ".class"); } DBApp.writeObj(p, "src/classes/Datei/" + tableName + p.getPageNumber() + ".class"); }
@Override public ProximityDescriptor computeProximity(Task wi1, Task wi2) { List<CodeContext> c1 = getContextEvents(wi1); List<CodeContext> c2 = getContextEvents(wi2); int totaItems = 0; int overlappingItems = 0; Hashtable<String, OverlapItem> allElements = new Hashtable<String, OverlapItem>(); OverlapItem oi; String elementID; ProximityDescriptor pd = new ProximityDescriptor(); ArrayList<Task> relatedTasks = new ArrayList<Task>(); // go through the 2 working sets one by one: first one ... relatedTasks.add(wi1); for (CodeContext eventC1 : c1) { if (granularity == ProximityGranularity.FILE_LEVEL) elementID = eventC1.getFileName(); else elementID = eventC1.getHandle(); if (allElements.containsKey(elementID) == false) { oi = new OverlapItem(elementID); allElements.put(elementID, oi); } else oi = allElements.get(elementID); if (eventC1.wasEdited()) oi.setEdit1(oi.getEdit1() + 1); else oi.setSelection1(oi.getSelection1() + 1); } // ... and now second one relatedTasks.add(wi2); for (CodeContext eventC2 : c2) { if (granularity == ProximityGranularity.FILE_LEVEL) elementID = eventC2.getFileName(); else elementID = eventC2.getHandle(); if (allElements.containsKey(elementID) == false) { oi = new OverlapItem(elementID); allElements.put(elementID, oi); } else oi = allElements.get(elementID); if (eventC2.wasEdited()) oi.setEdit1(oi.getEdit1() + 1); else oi.setSelection1(oi.getSelection1() + 1); } totaItems = allElements.keySet().size(); List<OverlapItem> actualOverlaps = new ArrayList<OverlapItem>(); for (OverlapItem overlap : allElements.values()) { if (overlap.isActualOverlap()) actualOverlaps.add(overlap); } overlappingItems = actualOverlaps.size(); pd.setOverlappingItems(actualOverlaps); pd.setPreliminaryDistance(computeRawProximity(actualOverlaps)); pd.setInvolvedTasks(relatedTasks); return pd; }
/** * Returns true if this clusterer has an incoming connection that is a batch set of instances * * @return a <code>boolean</code> value */ public boolean hasIncomingBatchInstances() { if (m_listenees.size() == 0) { return false; } if (m_listenees.containsKey("trainingSet") || m_listenees.containsKey("testSet") || m_listenees.containsKey("dataSet")) { return true; } return false; }
public long generateGID(String prefix, TDpd tdpd) { String dpd_name = tdpd.getName(); if (tdpd.getType() == C_FUNCTION_CALL) { if (dpd_name.indexOf('(') > 0) { dpd_name = dpd_name.substring(0, dpd_name.indexOf('(')).trim(); } dpd_name = dpd_name.trim(); int cnt = 0; if (hfunname.containsKey(dpd_name)) { Integer val = (Integer) hfunname.get(dpd_name); cnt = val.intValue(); } if (mainflag) { if (cnt == 0) { String str = new String(); str = dpd_name; tdpd.setGID(str); return FileUtil.getGID("<EC>", str); } String str = new String(); str = filestr + "." + dpd_name; tdpd.setGID(str); return FileUtil.getGID("<EC>", str); } else if (submainflag) { if (hsubmainname.containsKey(dpd_name)) { String str = new String(); str = dpd_name; tdpd.setGID(str); return FileUtil.getGID("<EC>", str); } if (cnt == 0) { String str = new String(); str = dpd_name; tdpd.setGID(str); return FileUtil.getGID("<EC>", str); } String str = new String(); str = filestr + "." + dpd_name; tdpd.setGID(str); return FileUtil.getGID("<EC>", str); } else { String str = new String(); if (hStaticfun.containsKey(dpd_name)) { str = filestr + "." + dpd_name; } else str = dpd_name; tdpd.setGID(tdpd.getGID()); // str return FileUtil.getGID("<EC>", str); } } return 0L; }
@SuppressWarnings("static-access") public String downloadReport() { String type = getParaValue("type"); CompReportHelper helper = new CompReportHelper(); Hashtable allData = helper.getAllDevice(); Vector vector = null; List deviceList = new ArrayList(); String file = ""; // 保存到项目文件夹下的指定文件夹 String filePath = ""; // 获取系统文件夹路径 if (allData != null) { if (allData.containsKey("deviceVec")) { vector = (Vector) allData.get("deviceVec"); helper.createPie(vector); } if (allData.containsKey("deviceList")) { deviceList = (List) allData.get("deviceList"); if (type.equals("doc")) { file = "/temp/allDevice.doc"; filePath = ResourceCenter.getInstance().getSysPath() + file; try { helper.createDoc(vector, deviceList, filePath); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (type.equals("xls")) { file = "/temp/allDevice.xls"; filePath = ResourceCenter.getInstance().getSysPath() + file; try { helper.createExcel(vector, deviceList, filePath); } catch (WriteException e) { e.printStackTrace(); } } else if (type.equals("pdf")) { file = "/temp/allDevice.pdf"; filePath = ResourceCenter.getInstance().getSysPath() + file; try { helper.createPdf(vector, deviceList, filePath); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } } request.setAttribute("filename", filePath); return "/capreport/net/download.jsp"; }
/** * Gets the numeric (double) representation of a value for a given parameter. * * @param param the parameter for which the value should be returned. * @return the parameter value * @throws IllegalArgumentException if the parameter is unknown to the design. */ public double getDoubleValue(Parameter param) { if (stringParameterValues.containsKey(param)) { return param.getDoubleValueOf(stringParameterValues.get(param)); } else if (numericalParameterValues.containsKey(param) && param.isNumeric()) { return (numericalParameterValues.get(param)); } else if (numericalParameterValues.containsKey(param)) { return param.getDoubleValueOf(Float.toString(numericalParameterValues.get(param))); } else { throw new IllegalArgumentException("Unknown parameter " + param.getName()); } }
/** * Edited: Simental Magaña Marcos Eleno Joaquín Para práctica 5 Se agrega Método para solicitar el * buzon perteneciente del proceso, si proceso no tiene buzon, regresa null */ private Buzon dameMiBuzon(int idProceso) { Buzon miBuzon = null; Integer key = new Integer(idProceso); System.out.println( "MicroNucleo.java: Proceso " + idProceso + " solicita buzón: " + tablaBuzones.containsKey(key)); if (tablaBuzones.containsKey(key)) { miBuzon = tablaBuzones.get(key); } return miBuzon; }
/** * Returns true, if at the current time, the named event could be generated. Assumes that the * supplied event name is an event that could be generated by this bean * * @param eventName the name of the event in question * @return true if the named event could be generated at this point in time */ public boolean eventGeneratable(String eventName) { if (eventName.compareTo("graph") == 0) { // can't generate a GraphEvent if clusterer is not drawable if (!(m_Clusterer instanceof weka.core.Drawable)) { return false; } // need to have a training set before the clusterer // can generate a graph! if (!m_listenees.containsKey("trainingSet")) { return false; } // Source needs to be able to generate a trainingSet // before we can generate a graph Object source = m_listenees.get("trainingSet"); if (source instanceof EventConstraints) { if (!((EventConstraints) source).eventGeneratable("trainingSet")) { return false; } } } if (eventName.compareTo("batchClusterer") == 0) { if (!m_listenees.containsKey("trainingSet")) { return false; } Object source = m_listenees.get("trainingSet"); if (source != null && source instanceof EventConstraints) { if (!((EventConstraints) source).eventGeneratable("trainingSet")) { return false; } } } if (eventName.compareTo("text") == 0) { if (!m_listenees.containsKey("trainingSet")) { return false; } Object source = m_listenees.get("trainingSet"); if (source != null && source instanceof EventConstraints) { if (!((EventConstraints) source).eventGeneratable("trainingSet")) { return false; } } } if (eventName.compareTo("batchClassifier") == 0) return false; if (eventName.compareTo("incrementalClassifier") == 0) return false; return true; }
private void getStockLevels() { CrashReporter.leaveBreadcrumb("Trip_Stock_Load: getStockLevels"); // Create the Hashtable if it does not already exist if (stockLevels == null) { CrashReporter.leaveBreadcrumb( "Trip_Stock_Load: getStockLevels - Creating stock levels hashtable ..."); stockLevels = new Hashtable<String, Integer>(); } CrashReporter.leaveBreadcrumb( "Trip_Stock_Load: getStockLevels - Clearing stock levels hashtable ..."); // Empty it stockLevels.clear(); for (dbVehicleStock vehicleStock : dbVehicleStock.findAllNonCompartmentStock(Active.vehicle)) { String productName = vehicleStock.Product.Desc; int stockLevel = vehicleStock.CurrentStock; if (!stockLevels.containsKey(productName)) { CrashReporter.leaveBreadcrumb( String.format( "Trip_Stock_Load: getStockLevels - Adding entry for %s to hashtable ...", productName)); stockLevels.put(productName, 0); } CrashReporter.leaveBreadcrumb("Trip_Stock_Load: getStockLevels - Updating stock level ..."); stockLevels.put(productName, stockLevels.get(productName) + stockLevel); } if (Active.vehicle.getHasHosereel()) { CrashReporter.leaveBreadcrumb( "Trip_Stock_Load: getStockLevels - Adding hosereel product to stock"); String productName = Active.vehicle.getHosereelProduct().Desc; int hosereelCapacity = Active.vehicle.getHosereelCapacity(); if (!stockLevels.containsKey(productName)) { stockLevels.put(productName, 0); } stockLevels.put(productName, stockLevels.get(productName) + hosereelCapacity); } }
public void run() { // each file is processed into a local hash table and then merged with the global results // this will cause much less contention on the global table, but still avoids a sequential // update Hashtable<String, Integer> local_results = new Hashtable<String, Integer>(WordCountJ.HASH_SIZE, WordCountJ.LF); // grab a file to work on String cf; while ((cf = files.poll()) != null) { try { BufferedReader input = new BufferedReader(new FileReader(cf)); String text; // well go line-by-line... maybe this is not the fastest while ((text = input.readLine()) != null) { // parse words Matcher matcher = pattern.matcher(text); while (matcher.find()) { String word = matcher.group(1); if (local_results.containsKey(word)) { local_results.put(word, 1 + local_results.get(word)); } else { local_results.put(word, 1); } } } input.close(); } catch (Exception e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); return; } // merge local hashmap with shared one,could have a // seperate thread do this but that might be cheating Iterator<Map.Entry<String, Integer>> updates = local_results.entrySet().iterator(); while (updates.hasNext()) { Map.Entry<String, Integer> kv = updates.next(); String k = kv.getKey(); Integer v = kv.getValue(); synchronized (results) { if (results.containsKey(k)) { results.put(k, v + results.get(k)); } else { results.put(k, v); } } } local_results.clear(); } }
public void persistentRequestError(final String id, final NodeMessage nm) { if (uploadModelItems.containsKey(id)) { final FrostUploadItem item = uploadModelItems.get(id); item.setEnabled(false); item.setState(FrostUploadItem.STATE_FAILED); item.setErrorCodeDescription(nm.getStringValue("CodeDescription")); } else if (downloadModelItems.containsKey(id)) { final FrostDownloadItem item = downloadModelItems.get(id); item.setEnabled(false); item.setState(FrostDownloadItem.STATE_FAILED); item.setErrorCodeDescription(nm.getStringValue("CodeDescription")); } else { System.out.println("persistentRequestError: ID not in any model: " + id); } }
private Hashtable getCredentials() { if (credentials == null) { throw new IllegalStateException("Consumer credentials has not been initialized!"); } String appId = callback.replace('/', '_'); Hashtable h = (Hashtable) credentials.get(appId); if (h == null || h.containsKey("key") == false || h.containsKey("secret") == false) { throw new IllegalStateException( "Consumer credentials has not been initialized for callback!"); } if (h.containsKey("provider") == false) { throw new IllegalStateException("Service provider has not been initialized!"); } return h; }