示例#1
0
  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();
 }
示例#3
0
 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;
 }
示例#4
0
 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);
     }
   }
 }
示例#5
0
 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);
   }
 }
示例#6
0
 protected InvertedIndex() {
   map = Helper.newHashMap();
 }
示例#7
0
 public Query(String name) {
   this.name = name;
   resultsByHeuristic = Helper.newHashMap();
   results = Helper.newHashSet();
 }
示例#8
0
 public MatchStatus(File file) {
   this.file = file;
   this.map = Helper.newEnumMap(DetectionMethod.class);
 }