List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:com.opengamma.analytics.financial.interestrate.capletstripping.CapletStrippingFunction.java
public CapletStrippingFunction(final List<CapFloor> caps, final YieldCurveBundle yieldCurves, final LinkedHashMap<String, double[]> knotPoints, final LinkedHashMap<String, Interpolator1D> interpolators, final LinkedHashMap<String, ParameterLimitsTransform> parameterTransforms, final LinkedHashMap<String, InterpolatedDoublesCurve> knownParameterTermSturctures) { Validate.notNull(caps, "caps null"); Validate.notNull(knotPoints, "null node points"); Validate.notNull(interpolators, "null interpolators"); Validate.isTrue(knotPoints.size() == interpolators.size(), "size mismatch between nodes and interpolators"); if (knownParameterTermSturctures == null) { Validate.isTrue(knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue(knotPoints.containsKey(BETA) && interpolators.containsKey(BETA), "beta curve not found"); Validate.isTrue(knotPoints.containsKey(NU) && interpolators.containsKey(NU), "nu curve not found"); Validate.isTrue(knotPoints.containsKey(RHO) && interpolators.containsKey(RHO), "rho curve not found"); } else {/*from w w w. ja va 2s . c o m*/ Validate.isTrue((knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA)) ^ knownParameterTermSturctures.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue((knotPoints.containsKey(BETA) && interpolators.containsKey(BETA)) ^ knownParameterTermSturctures.containsKey(BETA), "beta curve not found"); Validate.isTrue((knotPoints.containsKey(NU) && interpolators.containsKey(NU)) ^ knownParameterTermSturctures.containsKey(NU), "nu curve not found"); Validate.isTrue((knotPoints.containsKey(RHO) && interpolators.containsKey(RHO)) ^ knownParameterTermSturctures.containsKey(RHO), "rho curve not found"); } final LinkedHashMap<String, Interpolator1D> transInterpolators = new LinkedHashMap<String, Interpolator1D>(); final Set<String> names = interpolators.keySet(); for (final String name : names) { final Interpolator1D temp = new TransformedInterpolator1D(interpolators.get(name), parameterTransforms.get(name)); transInterpolators.put(name, temp); } _curveBuilder = new InterpolatedCurveBuildingFunction(knotPoints, transInterpolators); // _parameterTransforms = parameterTransforms; //TODO all the check for this _capPricers = new ArrayList<CapFloorPricer>(caps.size()); for (final CapFloor cap : caps) { _capPricers.add(new CapFloorPricer(cap, yieldCurves)); } _knownParameterTermStructures = knownParameterTermSturctures; }
From source file:pt.lsts.neptus.plugins.sunfish.awareness.HubLocationProvider.java
@Periodic(millisBetweenUpdates = 3000 * 60) public void sendToHub() { if (!enabled) return;//from w ww .j a v a2 s . co m NeptusLog.pub().info("Uploading device updates to Hub..."); LinkedHashMap<Integer, AssetPosition> toSend = new LinkedHashMap<Integer, AssetPosition>(); LocationType myLoc = MyState.getLocation(); AssetPosition myPos = new AssetPosition(StringUtils.toImcName(GeneralPreferences.imcCcuName), myLoc.getLatitudeDegs(), myLoc.getLongitudeDegs()); toSend.put(ImcMsgManager.getManager().getLocalId().intValue(), myPos); toSend.putAll(positionsToSend); positionsToSend.clear(); DeviceUpdate upd = new DeviceUpdate(); //ExtendedDeviceUpdate upd = new ExtendedDeviceUpdate(); upd.source = ImcMsgManager.getManager().getLocalId().intValue(); upd.destination = 65535; for (Entry<Integer, AssetPosition> pos : toSend.entrySet()) { Position p = new Position(); p.id = pos.getKey(); p.latRads = pos.getValue().getLoc().getLatitudeRads(); p.lonRads = pos.getValue().getLoc().getLongitudeRads(); p.posType = Position.fromImcId(p.id); p.timestamp = pos.getValue().getTimestamp() / 1000.0; upd.getPositions().put(pos.getKey(), p); } for (Position p : upd.getPositions().values()) { NeptusLog.pub().info("Uploading position for " + p.id + ": " + Math.toDegrees(p.latRads) + "/" + Math.toDegrees(p.lonRads) + "/" + new Date((long) (1000 * p.timestamp))); } try { HttpPost postMethod = new HttpPost(iridiumUrl); postMethod.setHeader("Content-type", "application/hub"); String data = new String(Hex.encodeHex(upd.serialize())); NeptusLog.pub().info("Sending '" + data + "'"); StringEntity ent = new StringEntity(data); postMethod.setEntity(ent); @SuppressWarnings("resource") HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(postMethod); NeptusLog.pub().info("Sent " + upd.getPositions().size() + " device updates to Hub: " + response.getStatusLine().toString()); postMethod.abort(); } catch (Exception e) { NeptusLog.pub().error("Error sending updates to hub", e); parent.postNotification(Notification .error("Situation Awareness", e.getClass().getSimpleName() + " while trying to send device updates to HUB.") .requireHumanAction(false)); } }
From source file:com.espertech.esper.epl.spec.PatternStreamSpecRaw.java
private static StreamTypeService getStreamTypeService(String engineURI, String statementId, EventAdapterService eventAdapterService, Map<String, Pair<EventType, String>> taggedEventTypes, Map<String, Pair<EventType, String>> arrayEventTypes, Deque<Integer> subexpressionIdStack, String objectType) {/*from ww w . j av a2 s . c om*/ LinkedHashMap<String, Pair<EventType, String>> filterTypes = new LinkedHashMap<String, Pair<EventType, String>>(); filterTypes.putAll(taggedEventTypes); // handle array tags (match-until clause) if (arrayEventTypes != null) { String patternSubexEventType = getPatternSubexEventType(statementId, objectType, subexpressionIdStack); EventType arrayTagCompositeEventType = eventAdapterService .createSemiAnonymousMapType(patternSubexEventType, new HashMap(), arrayEventTypes, false); for (Map.Entry<String, Pair<EventType, String>> entry : arrayEventTypes.entrySet()) { String tag = entry.getKey(); if (!filterTypes.containsKey(tag)) { Pair<EventType, String> pair = new Pair<EventType, String>(arrayTagCompositeEventType, tag); filterTypes.put(tag, pair); } } } return new StreamTypeServiceImpl(filterTypes, engineURI, true, false); }
From source file:com.textocat.textokit.eval.GoldStandardBasedEvaluation.java
private void evaluate(CAS goldCas, CAS sysCas) { FSIterator<AnnotationFS> goldAnnoIter = annotationExtractor.extract(goldCas); Set<AnnotationFS> goldProcessed = new HashSet<AnnotationFS>(); // system annotations that exactly match a gold one Set<AnnotationFS> sysMatched = newHashSet(); // matches/*from www. j av a 2s . co m*/ LinkedHashMap<AnnotationFS, MatchInfo> matchesMap = newLinkedHashMap(); while (goldAnnoIter.hasNext()) { AnnotationFS goldAnno = goldAnnoIter.next(); if (goldProcessed.contains(goldAnno)) { continue; } MatchInfo mi = new MatchInfo(); matchesMap.put(goldAnno, mi); Set<AnnotationFS> candidates = newLinkedHashSet(matchingStrategy.searchCandidates(goldAnno)); candidates.removeAll(sysMatched); AnnotationFS exactSys = matchingStrategy.searchExactMatch(goldAnno, candidates); if (exactSys != null) { // sanity check assert candidates.contains(exactSys); mi.exact = exactSys; sysMatched.add(exactSys); } mi.partialSet.addAll(candidates); goldProcessed.add(goldAnno); } // filter partials that match a next gold for (MatchInfo mi : matchesMap.values()) { mi.partialSet.removeAll(sysMatched); } // report for each gold anno for (AnnotationFS goldAnno : matchesMap.keySet()) { // assert order declared in EvaluationListener javadoc MatchInfo mi = matchesMap.get(goldAnno); boolean matchedExactly = mi.exact != null; if (matchedExactly) { evalCtx.reportExactMatch(goldAnno, mi.exact); } for (AnnotationFS partialSys : mi.partialSet) { evalCtx.reportPartialMatch(goldAnno, partialSys); } if (!matchedExactly) { evalCtx.reportMissing(goldAnno); } } // report spurious (false positives) FSIterator<AnnotationFS> sysAnnoIter = annotationExtractor.extract(sysCas); while (sysAnnoIter.hasNext()) { AnnotationFS sysAnno = sysAnnoIter.next(); if (!sysMatched.contains(sysAnno)) { evalCtx.reportSpurious(sysAnno); } } }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupRtBoxPlot.java
protected String getPeakName(IPeakGroupDescriptor pgd) { String rt = "mean rt: " + String.format("%.2f", pgd.getMeanApexTime()) + "+/-" + String.format("%.2f", pgd.getApexTimeStdDev()) + "; median rt: " + String.format("%.2f", pgd.getMedianApexTime()) + ": "; LinkedHashMap<String, Integer> names = new LinkedHashMap<>(); if (!pgd.getDisplayName().equals(pgd.getName())) { return rt + pgd.getDisplayName(); }// w w w.j ava 2 s. c o m for (IPeakAnnotationDescriptor ipad : pgd.getPeakAnnotationDescriptors()) { if (names.containsKey(ipad.getName())) { names.put(ipad.getName(), names.get(ipad.getName()) + 1); } else { names.put(ipad.getName(), 1); } } if (names.isEmpty()) { return rt + "<NA>"; } if (names.size() > 1) { StringBuilder sb = new StringBuilder(); for (String key : names.keySet()) { sb.append(key); sb.append(" (" + names.get(key) + ")"); sb.append(" | "); } return rt + sb.replace(sb.length() - 1, sb.length() - 1, "").toString(); } else { return rt + names.keySet().toArray(new String[0])[0]; } }
From source file:rb.app.RBnSCMCSystem.java
private List<Integer> getSorted_CJ_Indices(Vector<Parameter> C_J) { int J = C_J.size(); LinkedHashMap<Double, Integer> dist_from_mu = new LinkedHashMap<Double, Integer>(J); for (int j = 0; j < J; j++) { double dist = param_dist(get_current_parameters(), C_J.get(j)); dist_from_mu.put(dist, j); }/*w ww . ja v a 2s. c om*/ List<Map.Entry<Double, Integer>> list = new LinkedList<Map.Entry<Double, Integer>>(dist_from_mu.entrySet()); Collections.sort(list, new Comparator() { public int compare(Object o1, Object o2) { return ((Comparable) ((Map.Entry) (o1)).getKey()).compareTo(((Map.Entry) (o2)).getKey()); } }); // Create a sorted list of values to return List<Integer> result = new LinkedList<Integer>(); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry<Double, Integer> entry = (Map.Entry<Double, Integer>) it.next(); result.add(entry.getValue()); } return result; }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupBoxPlot.java
protected String getPeakName(IPeakGroupDescriptor pgd) { String rt = "mean area: " + String.format("%.2f", pgd.getMeanArea(normalizer)) + "+/-" + String.format("%.2f", pgd.getAreaStdDev(normalizer)) + "; median area: " + String.format("%.2f", pgd.getMedianArea(normalizer)) + ": "; LinkedHashMap<String, Integer> names = new LinkedHashMap<>(); if (!pgd.getDisplayName().equals(pgd.getName())) { return rt + pgd.getDisplayName(); }//w w w .j a va2s. c o m for (IPeakAnnotationDescriptor ipad : pgd.getPeakAnnotationDescriptors()) { if (names.containsKey(ipad.getName())) { names.put(ipad.getName(), names.get(ipad.getName()) + 1); } else { names.put(ipad.getName(), 1); } } if (names.isEmpty()) { return rt + "<NA>"; } if (names.size() > 1) { StringBuilder sb = new StringBuilder(); for (String key : names.keySet()) { sb.append(key); sb.append(" (" + names.get(key) + ")"); sb.append(" | "); } return rt + sb.replace(sb.length() - 1, sb.length() - 1, "").toString(); } else { return rt + names.keySet().toArray(new String[0])[0]; } }
From source file:org.openspaces.maven.plugin.CreatePUProjectMojo.java
/** * Returns an array of available project templates names. *//*from w w w . j a v a 2s . c om*/ private HashMap getAvailableTemplates() throws Exception { HashMap templates = new HashMap(); Enumeration urls = Thread.currentThread().getContextClassLoader().getResources(DIR_TEMPLATES); while (urls.hasMoreElements()) { URL url = (URL) urls.nextElement(); PluginLog.getLog().debug("retrieving all templates from url: " + url); HashMap jarTemplates = getJarTemplates(getJarURLFromURL(url, "")); templates.putAll(jarTemplates); } LinkedHashMap sortedTemplates = new LinkedHashMap(); String desc = (String) templates.remove("event-processing"); if (desc != null) { sortedTemplates.put("event-processing", desc); } desc = (String) templates.remove("persistent-event-processing"); if (desc != null) { sortedTemplates.put("persistent-event-processing", desc); } sortedTemplates.putAll(templates); return sortedTemplates; }
From source file:com.px100systems.data.core.DatabaseStorage.java
/** * Get a map of current tenants. Used internally by the framework. * @return tenant map/*www . j av a 2s . c o m*/ */ public LinkedHashMap<Integer, String> getTenants() { LinkedHashMap<Integer, String> tenants = new LinkedHashMap<>(); if (tenantLoader != null) for (BaseTenantConfig t : tenantLoader.load()) tenants.put(t.getId(), t.getUrlIdentifier()); else tenants.put(0, "Default"); return tenants; }
From source file:fr.gael.dhus.olingo.v1.entity.Product.java
@Override public Map<String, Object> toEntityResponse(String root_url) { // superclass node response is not required. Only Item response is // necessary. Map<String, Object> res = super.itemToEntityResponse(root_url); res.put(NodeEntitySet.CHILDREN_NUMBER, getChildrenNumber()); LinkedHashMap<String, Date> dates = new LinkedHashMap<String, Date>(); dates.put(V1Model.TIME_RANGE_START, getContentStart()); dates.put(V1Model.TIME_RANGE_END, getContentEnd()); res.put(ProductEntitySet.CONTENT_DATE, dates); HashMap<String, String> checksum = new LinkedHashMap<String, String>(); checksum.put(V1Model.ALGORITHM, getChecksumAlgorithm()); checksum.put(V1Model.VALUE, getChecksumValue()); res.put(ProductEntitySet.CHECKSUM, checksum); res.put(ProductEntitySet.INGESTION_DATE, getIngestionDate()); res.put(ProductEntitySet.CREATION_DATE, getCreationDate()); res.put(ProductEntitySet.EVICTION_DATE, getEvictionDate()); res.put(ProductEntitySet.CONTENT_GEOMETRY, getGeometry()); Path incoming_path = Paths.get(CONFIG_MGR.getArchiveConfiguration().getIncomingConfiguration().getPath()); String prod_path = this.getDownloadablePath(); if (prod_path != null) // Can happen with not yet ingested products {//from ww w.j a v a 2s . co m Path prod_path_path = Paths.get(prod_path); if (prod_path_path.startsWith(incoming_path)) { prod_path = incoming_path.relativize(prod_path_path).toString(); } else { prod_path = null; } } else { prod_path = null; } res.put(ProductEntitySet.LOCAL_PATH, prod_path); try { String url = root_url + V1Model.PRODUCT.getName() + "('" + getId() + "')/$value"; MetalinkBuilder mb = new MetalinkBuilder(); mb.addFile(getName() + ".zip").addUrl(url, null, 0); StringWriter sw = new StringWriter(); Document doc = mb.build(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(doc), new StreamResult(sw)); res.put(ProductEntitySet.METALINK, sw.toString()); } catch (ParserConfigurationException e) { LOGGER.error("Error when creating Product EntityResponse", e); } catch (TransformerException e) { LOGGER.error("Error when creating Product EntityResponse", e); } return res; }