Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
     }
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 6
0
 protected InvertedIndex() {
   map = Helper.newHashMap();
 }
Exemplo n.º 7
0
 public Query(String name) {
   this.name = name;
   resultsByHeuristic = Helper.newHashMap();
   results = Helper.newHashSet();
 }
Exemplo n.º 8
0
 public MatchStatus(File file) {
   this.file = file;
   this.map = Helper.newEnumMap(DetectionMethod.class);
 }