List of usage examples for java.util TreeMap get
public V get(Object key)
From source file:com.sfs.whichdoctor.beans.WhichDoctorCoreIdentityBean.java
/** * Gets the grouped relationships.//from w ww. j av a 2s . c om * * @return the grouped relationships */ public final TreeMap<String, Collection<RelationshipBean>> getGroupedRelationships() { TreeMap<String, Collection<RelationshipBean>> groupedRelationships = new TreeMap<String, Collection<RelationshipBean>>(); if (this.getRelationships() != null) { for (RelationshipBean relationship : this.getRelationships()) { String key = "Unnamed"; Collection<RelationshipBean> rels = new ArrayList<RelationshipBean>(); if (relationship.getRelatedPerson() != null) { PersonBean person = relationship.getRelatedPerson(); key = person.getLastName() + " " + person.getFirstName() + " " + person.getPersonIdentifier(); } if (groupedRelationships.containsKey(key)) { rels = groupedRelationships.get(key); } rels.add(relationship); groupedRelationships.put(key, rels); } } return groupedRelationships; }
From source file:gsn.beans.StreamElement.java
public StreamElement(TreeMap<String, Serializable> output, DataField[] fields) { int nbFields = output.keySet().size(); if (output.containsKey("timed")) nbFields--;/* www. j av a 2 s .c om*/ String fieldNames[] = new String[nbFields]; Byte fieldTypes[] = new Byte[nbFields]; Serializable fieldValues[] = new Serializable[nbFields]; TreeMap<String, Integer> indexedFieldNames = new TreeMap<String, Integer>(new CaseInsensitiveComparator()); int idx = 0; long timestamp = System.currentTimeMillis(); for (String key : output.keySet()) { Serializable value = output.get(key); if (key.equalsIgnoreCase("timed")) { timestamp = (Long) value; timestampProvided = true; } else { fieldNames[idx] = key; fieldValues[idx] = value; for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equalsIgnoreCase(key)) fieldTypes[idx] = fields[i].getDataTypeID(); } indexedFieldNames.put(key, idx); idx++; } } this.fieldNames = fieldNames; this.fieldTypes = fieldTypes; this.fieldValues = fieldValues; this.indexedFieldNames = indexedFieldNames; this.timeStamp = timestamp; }
From source file:com.sun.faces.generate.HtmlTaglibGenerator.java
/** * * @return a SortedMap, where the keys are component-family String * entries, and the values are {@link RendererBean} instances *//* ww w.j a va 2 s .c o m*/ private static SortedMap getComponentFamilyRendererMap(String rkId) throws IllegalStateException { RenderKitBean renderKit = null; RendererBean[] renderers = null; RendererBean renderer = null; TreeMap result = null; ArrayList list = null; String componentFamily = null; if (null == (renderKit = fcb.getRenderKit(rkId))) { RenderKitBean[] kits = null; if (null == (kits = fcb.getRenderKits())) { throw new IllegalStateException("no RenderKits"); } if (null == (renderKit = kits[0])) { throw new IllegalStateException("no RenderKits"); } } if (null == (renderers = renderKit.getRenderers())) { throw new IllegalStateException("no Renderers"); } result = new TreeMap(); for (int i = 0, len = renderers.length; i < len; i++) { if (null == (renderer = renderers[i])) { throw new IllegalStateException("no Renderer"); } // if this is the first time we've encountered this // componentFamily if (null == (list = (ArrayList) result.get(componentFamily = renderer.getComponentFamily()))) { // create a list for it list = new ArrayList(); list.add(renderer); result.put(componentFamily, list); } else { list.add(renderer); } } return result; }
From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java
private void addResourceRequest(Priority priority, String resourceName, Resource capability, T req, boolean relaxLocality, String labelExpression) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { remoteRequests = new HashMap<String, TreeMap<Resource, ResourceRequestInfo>>(); this.remoteRequestsTable.put(priority, remoteRequests); if (LOG.isDebugEnabled()) { LOG.debug("Added priority=" + priority); }// ww w. java2 s . c o m } TreeMap<Resource, ResourceRequestInfo> reqMap = remoteRequests.get(resourceName); if (reqMap == null) { // capabilities are stored in reverse sorted order. smallest last. reqMap = new TreeMap<Resource, ResourceRequestInfo>(new ResourceReverseMemoryThenCpuComparator()); remoteRequests.put(resourceName, reqMap); } ResourceRequestInfo resourceRequestInfo = reqMap.get(capability); if (resourceRequestInfo == null) { resourceRequestInfo = new ResourceRequestInfo(priority, resourceName, capability, relaxLocality); reqMap.put(capability, resourceRequestInfo); } resourceRequestInfo.remoteRequest .setNumContainers(resourceRequestInfo.remoteRequest.getNumContainers() + 1); if (relaxLocality) { resourceRequestInfo.containerRequests.add(req); } if (ResourceRequest.ANY.equals(resourceName)) { resourceRequestInfo.remoteRequest.setNodeLabelExpression(labelExpression); } // Note this down for next interaction with ResourceManager addResourceRequestToAsk(resourceRequestInfo.remoteRequest); if (LOG.isDebugEnabled()) { LOG.debug("addResourceRequest:" + " applicationId=" + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + resourceRequestInfo.remoteRequest.getNumContainers() + " #asks=" + ask.size()); } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
private void updateIsotopeCurves() { update_isotope_curves = false;/*from w ww . j av a2 s . c o m*/ TreeMap<Peak, Collection<Annotation>> map = new TreeMap<Peak, Collection<Annotation>>(); for (PeakAnnotationMultiple pam : theSearchResults.getAnnotations()) { if (map.get(pam.getPeak()) == null) map.put(pam.getPeak(), new Vector<Annotation>()); Collection<Annotation> dest = map.get(pam.getPeak()); for (Vector<Annotation> va : pam.getAnnotations()) dest.addAll(va); } addIsotopeCurves(map); }
From source file:org.apache.hadoop.hbase.master.handler.TableEventHandler.java
public boolean reOpenAllRegions(List<HRegionInfo> regions) throws IOException { boolean done = false; LOG.info("Bucketing regions by region server..."); HTable table = new HTable(masterServices.getConfiguration(), tableName); TreeMap<ServerName, List<HRegionInfo>> serverToRegions = Maps.newTreeMap(); NavigableMap<HRegionInfo, ServerName> hriHserverMapping; try {/*from w w w. j ava 2 s .com*/ hriHserverMapping = table.getRegionLocations(); } finally { table.close(); } List<HRegionInfo> reRegions = new ArrayList<HRegionInfo>(); for (HRegionInfo hri : regions) { ServerName rsLocation = hriHserverMapping.get(hri); // Skip the offlined split parent region // See HBASE-4578 for more information. if (null == rsLocation) { LOG.info("Skip " + hri); continue; } if (!serverToRegions.containsKey(rsLocation)) { LinkedList<HRegionInfo> hriList = Lists.newLinkedList(); serverToRegions.put(rsLocation, hriList); } reRegions.add(hri); serverToRegions.get(rsLocation).add(hri); } LOG.info("Reopening " + reRegions.size() + " regions on " + serverToRegions.size() + " region servers."); this.masterServices.getAssignmentManager().setRegionsToReopen(reRegions); BulkReOpen bulkReopen = new BulkReOpen(this.server, serverToRegions, this.masterServices.getAssignmentManager()); while (true) { try { if (bulkReopen.bulkReOpen()) { done = true; break; } else { LOG.warn("Timeout before reopening all regions"); } } catch (InterruptedException e) { LOG.warn("Reopen was interrupted"); // Preserve the interrupt. Thread.currentThread().interrupt(); break; } } return done; }
From source file:com.vgi.mafscaling.OpenLoop.java
private void calculateCorrectedGS(TreeMap<Integer, ArrayList<Double>> result) { ArrayList<Double> closestVolatageArray; double gs = 0; double avgError = 0; int lastErrIndex = 0; int i;// w w w . j a va 2 s . c om gsCorrected.addAll(gsArray); for (i = 0; i < gsCorrected.size(); ++i) { gs = gsCorrected.get(i); avgError = 0; closestVolatageArray = result.get(i); if (closestVolatageArray != null) { for (int j = 0; j < closestVolatageArray.size(); ++j) avgError += closestVolatageArray.get(j); avgError /= closestVolatageArray.size(); lastErrIndex = i; } gsCorrected.set(i, gs * (1 + avgError / 100.0)); } avgError = 0; ArrayList<Double> sortedAfrArray = result.get(lastErrIndex); Collections.sort(sortedAfrArray, Collections.reverseOrder()); for (i = 0; i < 10 && i < sortedAfrArray.size(); ++i) avgError += sortedAfrArray.get(i); if (i > 0) avgError /= i; for (i = lastErrIndex + 1; i < gsCorrected.size(); ++i) { gs = gsCorrected.get(i); gsCorrected.set(i, gs + (gs * 0.01 * avgError)); } }
From source file:io.mapzone.arena.refine.RefinePanel.java
@Override public void createContents(final Composite parent) { parent.setLayout(FormLayoutFactory.defaults().create()); final TreeMap<String, RefineFunction> functions = Maps.newTreeMap(); for (Class<RefineFunction> cl : availableFunctions) { try {/*from w w w . j a v a 2 s . c om*/ RefineFunction function = cl.newInstance(); function.init(map); functions.put(function.title(), function); } catch (Exception e) { throw new RuntimeException(e); } } Combo combo = new Combo(parent, SWT.SINGLE | SWT.BORDER | SWT.DROP_DOWN); @SuppressWarnings("hiding") final Composite functionContainer = tk().createComposite(parent, SWT.NONE); final List<String> content = Lists.newArrayList(functions.keySet()); combo.setItems(content.stream().toArray(String[]::new)); combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String functionTitle = content.get(combo.getSelectionIndex()); RefineFunction function = functions.get(functionTitle); UIUtils.disposeChildren(functionContainer); // create panel IPanelSection section = tk().createPanelSection(functionContainer, function.description(), SWT.BORDER); section.setExpanded(true); section.getBody().setLayout(FormLayoutFactory.defaults().create()); function.createContents(tk(), section.getBody()); FormDataFactory.on(section.getBody()).fill(); functionContainer.layout(); } }); // layout final Label selectLabel = tk().createLabel(parent, i18n.get("selectFunction"), SWT.NONE); FormDataFactory.on(selectLabel).top(1).left(1); FormDataFactory.on(combo).top(selectLabel, 3).left(1).noBottom(); FormDataFactory.on(functionContainer).fill().top(combo, 5); }
From source file:org.opendatakit.database.data.ColumnDefinitionTest.java
@SuppressWarnings("unchecked") private void recursiveMatch(String parent, TreeMap<String, Object> value, Map<String, Object> xlsxValue) { for (String key : value.keySet()) { assertTrue("Investigating " + parent + "." + key, xlsxValue.containsKey(key)); Object ov = value.get(key); Object oxlsxv = xlsxValue.get(key); if (ov instanceof Map) { TreeMap<String, Object> rv = (TreeMap<String, Object>) ov; Map<String, Object> xlsrv = (Map<String, Object>) oxlsxv; List<String> ignoredKeys = new ArrayList<String>(); for (String rvkey : xlsrv.keySet()) { if (rvkey.startsWith("_")) { ignoredKeys.add(rvkey); }/*from w ww .j a v a 2 s . c o m*/ if (rvkey.equals("prompt_type_name")) { ignoredKeys.add(rvkey); } } for (String rvkey : ignoredKeys) { xlsrv.remove(rvkey); } assertEquals("Investigating " + parent + "." + key, rv.size(), xlsrv.size()); recursiveMatch(parent + "." + key, rv, xlsrv); } else { assertEquals("Investigating " + parent + "." + key, ov, oxlsxv); } } }
From source file:gda.scan.ConcurrentScan.java
public String reportDevicesByLevel() { TreeMap<Integer, Scannable[]> devicesToMoveByLevel = generateDevicesToMoveByLevel(scannableLevels, allDetectors);// ww w .j av a 2 s . c om // e.g. "| lev4 | lev4a lev4b | *det9 || mon1, mon2 String sMoved = ""; List<String> toMonitor = new ArrayList<String>(); for (Integer level : devicesToMoveByLevel.keySet()) { sMoved += " | "; List<String> toMove = new ArrayList<String>(); for (Scannable scn : devicesToMoveByLevel.get(level)) { if (scn instanceof Detector) { toMove.add("*" + scn.getName()); } else if (isScannableActuallyToBeMoved(scn)) { toMove.add(scn.getName()); } else { // Scannable is acting like a monitor toMonitor.add(scn.getName()); } } sMoved += StringUtils.join(toMove, ", "); } String sMonitor = StringUtils.join(toMonitor, ", "); return (sMoved + ((sMonitor.equals("")) ? " |" : (" || " + sMonitor + " |"))).trim(); }