public Set<String> clearPopularNames(TablePrettyPrinter printer, int maxSize) { Set<String> removed = Helper.newHashSet(); Set<Counter<String>> sorted = Helper.newTreeSet(Counter.<String>getReverseComparator()); Iterator<Map.Entry<String, Collection<T>>> iter = map.entrySet().iterator(); for (Map.Entry<String, Collection<T>> entry = iter.next(); iter.hasNext(); entry = iter.next()) { if (entry.getValue().size() > maxSize) { removed.add(entry.getKey()); sorted.add(new Counter<String>(entry.getKey(), entry.getValue().size())); iter.remove(); } } printer.beginTable(2); printer.addDividerRow(); printer.addRow("Name", "Count"); printer.addDividerRow(); for (Counter<String> counter : sorted) { printer.beginRow(); printer.addCell(counter.getObject()); printer.addCell(counter.getCount()); } printer.addDividerRow(); printer.endTable(); return removed; }
public ClassFileExtractor(WriterBundle writers) { fileWriter = writers.getClassFileWriter(); entityWriter = writers.getJarEntityWriter(); localVariableWriter = writers.getLocalVariableWriter(); relationWriter = writers.getJarRelationWriter(); fqnStack = Helper.newStack(); }
public Set<String> getTopResults(String heuristic, int top) { Collection<String> results = resultsByHeuristic.get(heuristic); Set<String> topResults = Helper.newHashSet(); for (String result : results) { if (top-- <= 0) { break; } topResults.add(result); } return topResults; }
public void addFingerprint(T fingerprint, String[] strings) { for (String string : strings) { Collection<T> fingerprints = map.get(string); if (fingerprints == null) { fingerprints = Helper.newArrayList(); map.put(string, fingerprints); } if (!fingerprints.contains(fingerprint)) { fingerprints.add(fingerprint); } } }
public void addResults(File file) { String heuristic = file.getName(); heuristic = heuristic.substring(0, heuristic.lastIndexOf('.')); Collection<String> queryResult = Helper.getLinkedListFromMap(resultsByHeuristic, heuristic); try { BufferedReader br = new BufferedReader(new FileReader(file)); for (String line = br.readLine(); line != null; line = br.readLine()) { String[] parts = line.split(" "); queryResult.add(parts[0]); results.add(parts[0]); } br.close(); } catch (IOException e) { logger.log(Level.SEVERE, "Error reading scs file: " + file.getPath(), e); } }
protected InvertedIndex() { map = Helper.newHashMap(); }
public Query(String name) { this.name = name; resultsByHeuristic = Helper.newHashMap(); results = Helper.newHashSet(); }
public MatchStatus(File file) { this.file = file; this.map = Helper.newEnumMap(DetectionMethod.class); }