Esempio n. 1
0
 @Override
 public void visitType(TransactionType type) {
   if ("URL".equals(type.getId())) {
     super.visitType(type);
   }
 }
Esempio n. 2
0
  @Override
  public void visitType(TransactionType type) {
    if ("URL".equals(type.getId())) {
      Map<String, TransactionName> transactionNames = type.getNames();

      Set<String> names = transactionNames.keySet();
      Set<String> invalidates = new HashSet<String>();

      for (String temp : names) {
        int length = temp.length();

        for (int i = 0; i < length; i++) {
          // invalidate char
          if (temp.charAt(i) > 126 || temp.charAt(i) < 33) {
            invalidates.add(temp);
            continue;
          }
        }
      }

      for (String name : invalidates) {
        transactionNames.remove(name);
      }

      int size = transactionNames.size();

      if (size > m_maxItems) {
        List<TransactionName> all = new ArrayList<TransactionName>(transactionNames.values());

        Collections.sort(all, new TransactionNameCompator());
        type.getNames().clear();

        for (int i = 0; i < m_maxItems; i++) {
          type.addName(all.get(i));
        }

        TransactionName other = type.findOrCreateName("OTHERS");
        for (int i = m_maxItems; i < size; i++) {
          mergeName(other, all.get(i));
        }
      }

      List<String> toRemove = new ArrayList<String>();
      TransactionName other = type.findOrCreateName("OTHERS");

      transactionNames = type.getNames();
      names = transactionNames.keySet();
      for (String temp : names) {
        TransactionName tansactionName = transactionNames.get(temp);

        if (tansactionName.getTotalCount() == 1) {
          toRemove.add(temp);
          mergeName(other, tansactionName);
        }
      }

      for (String temp : toRemove) {
        transactionNames.remove(temp);
      }
    }
    super.visitType(type);
  }