/**
   * That's the function actually used to add some info
   *
   * @param info information to be added
   */
  protected void add(IInfo info, int doOn) {
    synchronized (lock) {
      String name = info.getName();
      String initials = getInitials(name);
      TreeMap<String, List<IInfo>> initialsToInfo;

      if (doOn == TOP_LEVEL) {
        if (info.getPath() != null && info.getPath().length() > 0) {
          throw new RuntimeException(
              "Error: the info being added is added as an 'top level' info, but has path. Info:"
                  + info);
        }
        initialsToInfo = topLevelInitialsToInfo;

      } else if (doOn == INNER) {
        if (info.getPath() == null || info.getPath().length() == 0) {
          throw new RuntimeException(
              "Error: the info being added is added as an 'inner' info, but does not have a path. Info: "
                  + info);
        }
        initialsToInfo = innerInitialsToInfo;

      } else {
        throw new RuntimeException("List to add is invalid: " + doOn);
      }
      List<IInfo> listForInitials = getAndCreateListForInitials(initials, initialsToInfo);
      listForInitials.add(info);
    }
  }
Esempio n. 2
0
  /** Tree is written as: line 1= tree size cub|2|CubeColourDialog!13&999@CUBIC!263@cube!202&999@ */
  public static void dumpTreeToBuffer(
      SortedMap<String, Set<IInfo>> tree, FastStringBuffer tempBuf, Map<String, Integer> strToInt) {
    Set<Entry<String, Set<IInfo>>> entrySet = tree.entrySet();
    Iterator<Entry<String, Set<IInfo>>> it = entrySet.iterator();
    tempBuf.append(entrySet.size());
    tempBuf.append('\n');
    while (it.hasNext()) {
      Entry<String, Set<IInfo>> next = it.next();
      tempBuf.append(next.getKey());
      Set<IInfo> value = next.getValue();

      tempBuf.append('|');
      tempBuf.append(value.size());
      tempBuf.append('|');

      Iterator<IInfo> it2 = value.iterator();
      Integer integer;
      while (it2.hasNext()) {
        IInfo info = it2.next();
        tempBuf.append(info.getName());
        tempBuf.append('!');

        String path = info.getPath();
        if (path != null) {
          integer = strToInt.get(path);
          if (integer == null) {
            integer = strToInt.size() + 1;
            strToInt.put(path, integer);
          }
          tempBuf.append(integer);
          tempBuf.append('&');
        }

        String modName = info.getDeclaringModuleName();

        integer = strToInt.get(modName);
        if (integer == null) {
          integer = strToInt.size() + 1;
          strToInt.put(modName, integer);
        }

        int v = integer << 3;
        v |= info.getType();
        tempBuf.append(v); // Write a single for name+type

        tempBuf.append('@');
      }
      tempBuf.append('\n');
    }
    tempBuf.append("-- END TREE\n");
  }
 public boolean doCompare(String qualifier, IInfo info) {
   return doCompare(qualifier, info.getName());
 }
 public boolean doCompare(String lowerCaseQual, IInfo info) {
   return doCompare(lowerCaseQual, info.getName());
 }
 public boolean doCompare(String qualifier, IInfo info) {
   return info.getName().equals(qualifier);
 }