List of usage examples for java.util TreeMap values
public Collection<V> values()
From source file:com.celements.menu.MenuService.java
public List<BaseObject> getSubMenuItems(Integer headerId) { TreeMap<Integer, BaseObject> menuItemsMap = new TreeMap<Integer, BaseObject>(); addMenuItems(menuItemsMap, headerId); getContext().setDatabase("celements2web"); addMenuItems(menuItemsMap, headerId); getContext().setDatabase(getContext().getOriginalDatabase()); ArrayList<BaseObject> resultList = new ArrayList<BaseObject>(); resultList.addAll(menuItemsMap.values()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("getSubMenuItems_internal returning: " + Arrays.deepToString(resultList.toArray())); }//w w w . jav a 2 s. c o m LOGGER.debug("getSubMenuItems_internal end"); return resultList; }
From source file:org.xwiki.extension.test.ExtensionPackager.java
public void generateExtension(String classPackageFolder, URL descriptorUrl) throws IOException { String descriptorUrlStr = descriptorUrl.toString(); String descriptorFolderURL = descriptorUrlStr.substring(0, descriptorUrlStr.length() - PACKAGEFILE_DESCRIPTOR.length()); Properties descriptorProperties = new Properties(); InputStream descriptorStream = descriptorUrl.openStream(); try {/*from w w w.ja va 2 s .c om*/ descriptorProperties.load(descriptorStream); } finally { descriptorStream.close(); } String type = descriptorProperties.getProperty("type"); if (type == null) { type = "zip"; } String id = descriptorProperties.getProperty("id"); if (id == null) { id = descriptorFolderURL.substring(0, descriptorFolderURL.length() - 1); id = id.substring(id.lastIndexOf('/') + 1); } String version = descriptorProperties.getProperty("version"); if (version == null) { version = "1.0"; } File packageFile; String directory = descriptorProperties.getProperty("directory"); String fileName = descriptorProperties.getProperty("fileName"); String repositoryName = descriptorProperties.getProperty("repository"); if (directory == null) { if (fileName == null) { packageFile = new File(this.repositories.get(repositoryName), URLEncoder.encode(id + '-' + version + '.' + type, "UTF-8")); } else { packageFile = new File(this.repositories.get(repositoryName), fileName); } } else { if (fileName == null) { fileName = URLEncoder.encode(id + '-' + version + '.' + type, "UTF-8"); } packageFile = new File(this.workingDirectory, directory); packageFile = new File(packageFile, fileName); } // generate // Make sure the folder exists packageFile.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(packageFile); try { ZipOutputStream zos; if (type.equals("jar")) { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); zos = new JarOutputStream(fos, manifest); } else { zos = new ZipOutputStream(fos); } try { // Order files TreeMap<String, Vfs.File> files = new TreeMap<>(); for (Vfs.File resourceFile : Vfs.fromURL(new URL(descriptorFolderURL)).getFiles()) { files.put(resourceFile.getRelativePath(), resourceFile); } // Add files to zip for (Vfs.File resourceFile : files.values()) { if (!resourceFile.getRelativePath().equals(PACKAGEFILE_DESCRIPTOR)) { addZipEntry(classPackageFolder, resourceFile, zos, type); } } } finally { zos.close(); } // Register the extension this.extensionsFiles.put(new ExtensionId(id, version), packageFile); } finally { fos.close(); } }
From source file:com.adobe.acs.commons.analysis.jcrchecksum.impl.JSONGenerator.java
@SuppressWarnings("squid:S3776") private static void outputProperty(Property property, ChecksumGeneratorOptions opts, JsonWriter out) throws RepositoryException, IOException { Set<String> sortValues = opts.getSortedProperties(); if (property.isMultiple()) { out.name(property.getName());//w w w . jav a2 s .co m // create an array for multi value output out.beginArray(); boolean isSortedValues = sortValues.contains(property.getName()); Value[] values = property.getValues(); TreeMap<String, Value> sortedValueMap = new TreeMap<String, Value>(); for (Value v : values) { int type = v.getType(); if (type == PropertyType.BINARY) { if (isSortedValues) { try { java.io.InputStream stream = v.getBinary().getStream(); String ckSum = DigestUtils.shaHex(stream); stream.close(); sortedValueMap.put(ckSum, v); } catch (IOException e) { sortedValueMap.put("ERROR: generating hash for binary of " + property.getPath() + " : " + e.getMessage(), v); } } else { outputPropertyValue(property, v, out); } } else { String val = v.getString(); if (isSortedValues) { sortedValueMap.put(val, v); } else { outputPropertyValue(property, v, out); } } } if (isSortedValues) { for (Value v : sortedValueMap.values()) { outputPropertyValue(property, v, out); } } out.endArray(); // end multi value property output } else { out.name(property.getName()); outputPropertyValue(property, property.getValue(), out); } }
From source file:org.rhq.enterprise.gui.admin.plugin.InstalledPluginsUIBean.java
private <T extends AbstractPlugin> List<T> sort(List<T> plugins) { TreeMap<String, T> map = new TreeMap<String, T>(); for (T plugin : plugins) { map.put(plugin.getName(), plugin); }//ww w.j av a 2 s . c o m return new ArrayList<T>(map.values()); }
From source file:com.jaeksoft.searchlib.learning.StandardLearner.java
private Collection<TargetField> checkDataFields(final FieldMap sourceFieldMap) throws SearchLibException, IOException { if (learnerClient == null || sourceFieldMap == null) return null; Schema schema = learnerClient.getSchema(); TreeMap<Float, TargetField> boostMap = new TreeMap<Float, TargetField>(); sourceFieldMap.populateBoosts(FIELD_SOURCE_DATA, boostMap); for (TargetField targetField : boostMap.values()) { String fieldName = targetField.getBoostedName(); if (schema.getField(fieldName) != null) continue; schema.setField(fieldName, Stored.NO, Indexed.YES, TermVector.YES, "StandardAnalyzer"); }//from w w w.j a va 2 s . co m TermVectorCache termVectorCache = ((IndexLucene) learnerClient.getIndex()).getTermVectorCache(); termVectorCache.setMaxSize((int) learnerClient.getStatistics().getNumDocs()); return boostMap.values(); }
From source file:org.cloudata.core.client.Row.java
/** * Return cell list /*from www .ja v a 2 s . com*/ * @param columnName * @return */ public List<Cell> getCellList(String columnName) { TreeMap<Cell.Key, Cell> cellList = cells.get(columnName); if (cellList == null) { return null; } return new ArrayList<Cell>(cellList.values()); }
From source file:decision_tree_learning.Matrix.java
public void postmodifyMetadata() { Iterator<TreeMap<Integer, String>> s_m_enum_to_str = this.m_enum_to_str.iterator(); for (int i = 0; i < this.m_str_to_enum.size() - 1; i++) { // we don't wanna touch last attribute's metadata TreeMap<String, Integer> s_m_str_to_enum = this.m_str_to_enum.get(i); int max = Collections.max(s_m_str_to_enum.values()); s_m_str_to_enum.put("MISSING", max + 1); s_m_enum_to_str.next().put(max + 1, "MISSING"); }// w ww . j ava2s.co m }
From source file:com.att.aro.ui.view.diagnostictab.plot.VideoChunksPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { if (analysis != null) { VideoUsage videousage = analysis.getAnalyzerResult().getVideoUsage(); if (!isReDraw) { boPlot.clearPlot(this.bufferOccupancyPlot); boTimePlot.clearPlot(this.bufferTimePlot); analysis.getAnalyzerResult().setBufferTimeResult(null); analysis.getAnalyzerResult().setBufferOccupancyResult(null); }//w w w . j a v a2 s . c o m videoChunksData.removeAllSeries(); for (XYSeriesCollection seriesColl : startUpDelayCollection) { seriesColl.removeAllSeries(); } startUpDelayCollection.clear(); imgSeries = new ArrayList<BufferedImage>(); // create the dataset... int index = 0; series = new XYSeries("Chunks"); seriesDataSets = new TreeMap<>(); seriesDataSets = videoChunkPlotter.populateDataSet(analysis.getAnalyzerResult().getVideoUsage()); imgSeries = videoChunkPlotter.getImageSeries(); filteredChunks = videousage.getFilteredSegments(); segmentsToBePlayed.clear(); if (videousage.getAllSegments() != null) { for (VideoEvent ve : videousage.getAllSegments()) { segmentsToBePlayed.add(ve); } } for (double timeStamp : seriesDataSets.values()) { series.add(timeStamp, 0); } XYSeriesCollection playTimeStartSeries; int first = 0; List<VideoEvent> chunkPlayBackTimeList = new ArrayList<VideoEvent>(chunkPlayTime.keySet()); Collections.sort(chunkPlayBackTimeList, new VideoEventComparator(SortSelection.SEGMENT)); for (VideoEvent ve : chunkPlayBackTimeList) { playTimeStartSeries = new XYSeriesCollection(); seriesStartUpDelay = new XYSeries("StartUpDelay" + (index++)); seriesStartUpDelay.add(ve.getDLTimeStamp(), 0); seriesStartUpDelay.add((double) chunkPlayTime.get(ve), 0); if (first == 0) { VideoUsage videoUsage = analysis.getAnalyzerResult().getVideoUsage(); TreeMap<Double, AROManifest> videoEventList = videoUsage.getAroManifestMap(); setDelayAROManifest((double) chunkPlayTime.get(ve) - ve.getEndTS(), videoEventList.values());//Set start up delay in AROManifest getDLTimeStamp() } playTimeStartSeries.addSeries(seriesStartUpDelay); startUpDelayCollection.add(playTimeStartSeries); first++; } videoChunksData.addSeries(series); VideoChunckImageRenderer renderer = new VideoChunckImageRenderer(); XYLineAndShapeRenderer rendererDelay = new XYLineAndShapeRenderer(); for (int i = 0; i < startUpDelayCollection.size(); i++) { rendererDelay.setSeriesStroke(i, new BasicStroke(1.0f)); rendererDelay.setSeriesPaint(i, Color.red); } XYToolTipGenerator xyToolTipGenerator = new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { StringBuffer tooltipValue = new StringBuffer(); VideoEvent currentVEvent = segmentsToBePlayed.get(item); DecimalFormat decimalFormat = new DecimalFormat("0.##"); tooltipValue.append(decimalFormat.format(currentVEvent.getSegment()) + "," + String.format("%.2f", currentVEvent.getStartTS()) + "," + String.format("%.2f", currentVEvent.getEndTS()) + ","); if (!chunkPlayTime.isEmpty()) { if (videoChunkPlotter.getSegmentPlayStartTime(currentVEvent) == -1) { tooltipValue.append("- ,"); } else { tooltipValue.append( String.format("%.2f", videoChunkPlotter.getSegmentPlayStartTime(currentVEvent)) + " s,"); } } else { tooltipValue.append("- ,"); } tooltipValue.append(currentVEvent.getTotalBytes() / 1000); //Converting to KB String[] value = tooltipValue.toString().split(","); return (MessageFormat.format(VIDEOCHUNK_TOOLTIP, value[0], value[1], value[2], value[3], value[4])); } }; renderer.setBaseToolTipGenerator(xyToolTipGenerator); renderer.setSeriesShape(0, shape); plot.setRenderer(index, renderer); for (int i = 0; i < startUpDelayCollection.size(); i++) plot.setRenderer(i, rendererDelay); } isReDraw = false; int seriesIndex = 0; for (XYSeriesCollection seriesColl : startUpDelayCollection) { plot.setDataset(seriesIndex, seriesColl); seriesIndex++; } plot.setDataset(seriesIndex, videoChunksData); }
From source file:dk.statsbiblioteket.doms.licensemodule.validation.LicenseValidator.java
public static ArrayList<UserGroupDTO> filterGroupsWithPresentationtype(ArrayList<License> licenses) { TreeMap<String, UserGroupDTO> groups = new TreeMap<String, UserGroupDTO>(); for (License currentLicense : licenses) { for (LicenseContent currentGroup : currentLicense.getLicenseContents()) { String name = currentGroup.getName(); UserGroupDTO group = groups.get(name); if (group == null) { group = new UserGroupDTO(); group.setPresentationTypes(new ArrayList<String>()); group.setGroupName(name); groups.put(name, group); }/*from w w w. j av a 2 s. c om*/ for (Presentation currentPresentation : currentGroup.getPresentations()) { String presentation_key = currentPresentation.getKey(); if (group.getPresentationTypes().contains(presentation_key)) { //Already added } else { group.getPresentationTypes().add(presentation_key); } } } } return new ArrayList<UserGroupDTO>(groups.values()); }
From source file:org.loklak.data.DAO.java
private static ArrayList<String> getBestPeers(Collection<String> peers) { ArrayList<String> best = new ArrayList<>(); if (peers == null || peers.size() == 0) return best; // first check if any of the given peers has unknown latency TreeMap<Long, String> o = new TreeMap<>(); for (String peer : peers) { if (peerLatency.containsKey(peer)) { o.put(peerLatency.get(peer) * 1000 + best.size(), peer); } else {/* w ww. j av a 2s. co m*/ best.add(peer); } } best.addAll(o.values()); return best; }