/** * 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); } }
/** * @param buffer * @param name */ private void entrySetToString(FastStringBuffer buffer, Set<Entry<String, List<IInfo>>> name) { synchronized (lock) { for (Entry<String, List<IInfo>> entry : name) { List<IInfo> value = entry.getValue(); for (IInfo info : value) { buffer.append(info.toString()); buffer.append("\n"); } } } }
/** 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"); }
/** * @param moduleName * @param initialsToInfo */ private void removeInfoFromMap(String moduleName, TreeMap<String, List<IInfo>> initialsToInfo) { Iterator<List<IInfo>> itListOfInfo = initialsToInfo.values().iterator(); while (itListOfInfo.hasNext()) { Iterator<IInfo> it = itListOfInfo.next().iterator(); while (it.hasNext()) { IInfo info = it.next(); if (info != null && info.getDeclaringModuleName() != null) { if (info.getDeclaringModuleName().equals(moduleName)) { it.remove(); } } } } }
/** @return a set with the module names that have tokens. */ public Set<String> getAllModulesWithTokens() { HashSet<String> ret = new HashSet<String>(); synchronized (lock) { Set<Entry<String, List<IInfo>>> entrySet = this.topLevelInitialsToInfo.entrySet(); for (Entry<String, List<IInfo>> entry : entrySet) { List<IInfo> value = entry.getValue(); for (IInfo info : value) { ret.add(info.getDeclaringModuleName()); } } entrySet = this.innerInitialsToInfo.entrySet(); for (Entry<String, List<IInfo>> entry : entrySet) { List<IInfo> value = entry.getValue(); for (IInfo info : value) { ret.add(info.getDeclaringModuleName()); } } } return ret; }
public boolean doCompare(String lowerCaseQual, IInfo info) { return doCompare(lowerCaseQual, info.getName()); }
public boolean doCompare(String qualifier, IInfo info) { return doCompare(qualifier, info.getName()); }
public boolean doCompare(String qualifier, IInfo info) { return info.getName().equals(qualifier); }