Пример #1
1
 public Set /*<PCNode>*/ matchClass(Pattern simple_name_pattern) {
   Set this_class = matchSpecific(simple_name_pattern);
   Set this_class_names = new HashSet();
   Iterator tsi = this_class.iterator();
   while (tsi.hasNext()) {
     PCNode pc = (PCNode) tsi.next();
     this_class_names.add(pc.name);
   }
   Iterator pi = parents.iterator();
   while (pi.hasNext()) {
     PCNode parent = (PCNode) pi.next();
     // System.out.println("Parent: "+parent);
     Set parent_class = parent.matchClass(simple_name_pattern);
     Iterator osi = parent_class.iterator();
     while (osi.hasNext()) {
       PCNode pc = (PCNode) osi.next();
       if (!this_class_names.contains(pc.name)) {
         this_class.add(pc);
       }
     }
   }
   if (abc.main.Debug.v().namePatternProcessing)
     System.out.println(this + ".matchClass " + simple_name_pattern.pattern() + ": " + this_class);
   return this_class;
 }
Пример #2
0
  public void processMethodMapping(
      String className,
      int firstLineNumber,
      int lastLineNumber,
      String methodReturnType,
      String methodName,
      String methodArguments,
      String newMethodName) {
    // Original class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap == null) {
      methodMap = new HashMap();
      classMethodMap.put(className, methodMap);
    }

    // Obfuscated method name -> methods.
    Set methodSet = (Set) methodMap.get(newMethodName);
    if (methodSet == null) {
      methodSet = new LinkedHashSet();
      methodMap.put(newMethodName, methodSet);
    }

    // Add the method information.
    methodSet.add(
        new MethodInfo(
            firstLineNumber, lastLineNumber, methodReturnType, methodArguments, methodName));
  }
Пример #3
0
  private void checkStartup(
      Map<String, ServiceData> map,
      List<ServiceData> start,
      ServiceData sd,
      Set<ServiceData> cyclic) {
    if (sd.after.isEmpty() || start.contains(sd)) return;

    if (cyclic.contains(sd)) {
      reporter.error("Cyclic dependency for " + sd.name);
      return;
    }

    cyclic.add(sd);

    for (String dependsOn : sd.after) {
      if (dependsOn.equals("boot")) continue;

      ServiceData deps = map.get(dependsOn);
      if (deps == null) {
        reporter.error("No such service " + dependsOn + " but " + sd.name + " depends on it");
      } else {
        checkStartup(map, start, deps, cyclic);
      }
    }
    start.add(sd);
  }
  /** TODO */
  public AnnotatedLexicalEntry integrate(LexicalEntry e) {

    String gloss = e.getAnnotations().get(CrownAnnotations.Gloss.class);
    POS pos = e.getPos();

    List<Relation> relations = e.getAnnotations().get(CrownAnnotations.Relations.class);

    // Try getting a synonym operation first
    Set<String> synonyms = new HashSet<String>();
    for (Relation r : relations) {
      if (r.getType().equals(Relation.RelationType.SYNONYM)) synonyms.add(r.getTargetLemma());
    }
    if (synonyms.size() > 0) {
      Duple<CrownOperations.Reason, ISynset> synonymOp =
          getEstimatedSynonym(e.getLemma(), synonyms, pos, gloss);

      if (synonymOp != null && synonymOp.y != null) {
        AnnotatedLexicalEntry ale = new AnnotatedLexicalEntryImpl(e);
        ale.setOp(CrownOperations.Synonym.class, synonymOp.x, synonymOp.y);
        return ale;
      }
    }

    return null;
  }
Пример #5
0
  public GeneOrthologyEntry(String line) {
    String[] a = line.split("\\s");
    geneName = a[0];
    s288cCoords = parseCoordsString(a[1]);
    sigmaCoords = parseCoordsString(a[2]);
    try {
      identity = Double.parseDouble(a[3]);
    } catch (NumberFormatException e) {
      identity = null;
    }
    flags = new HashSet<Flag>();
    orfCoords = null;

    if (a.length > 4) {
      String[] fa = a[4].split(",");
      for (int i = 0; i < fa.length; i++) {
        try {
          if (fa[i].length() > 0) {
            flags.add(Flag.valueOf(fa[i]));
          } else {
            flags.add(Flag.UNKNOWN);
          }
        } catch (IllegalArgumentException e) {
          System.err.println(String.format("Unknown FLAG: \"%s\"", fa[i]));
          flags.add(Flag.UNKNOWN);
        }
      }

      if (a.length > 5) {
        orfCoords = parseCoordsString(a[5]);
      }
    }
  }
Пример #6
0
 static {
   BAD_GLOBALS.add("db");
   BAD_GLOBALS.add("local");
   BAD_GLOBALS.add("core");
   BAD_GLOBALS.add("args"); // TODO: should we get rid of this
   BAD_GLOBALS.add("obj"); // TODO: get rid of this
 }
 void showDiagnostics(boolean showAll) {
   Set<JCDiagnostic.Kind> kinds = EnumSet.allOf(JCDiagnostic.Kind.class);
   if (!showAll) {
     // suppress errors, which are all presumed to be transient resolve errors
     kinds.remove(JCDiagnostic.Kind.ERROR);
   }
   log.reportDeferredDiagnostics(kinds);
 }
Пример #8
0
  /**
   * Finds the original field name(s), appending the first one to the out line, and any additional
   * alternatives to the extra lines.
   */
  private void originalFieldName(
      String className,
      String obfuscatedFieldName,
      String type,
      StringBuffer outLine,
      List extraOutLines) {
    int extraIndent = -1;

    // Class name -> obfuscated field names.
    Map fieldMap = (Map) classFieldMap.get(className);
    if (fieldMap != null) {
      // Obfuscated field names -> fields.
      Set fieldSet = (Set) fieldMap.get(obfuscatedFieldName);
      if (fieldSet != null) {
        // Find all matching fields.
        Iterator fieldInfoIterator = fieldSet.iterator();
        while (fieldInfoIterator.hasNext()) {
          FieldInfo fieldInfo = (FieldInfo) fieldInfoIterator.next();
          if (fieldInfo.matches(type)) {
            // Is this the first matching field?
            if (extraIndent < 0) {
              extraIndent = outLine.length();

              // Append the first original name.
              if (verbose) {
                outLine.append(fieldInfo.type).append(' ');
              }
              outLine.append(fieldInfo.originalName);
            } else {
              // Create an additional line with the proper
              // indentation.
              StringBuffer extraBuffer = new StringBuffer();
              for (int counter = 0; counter < extraIndent; counter++) {
                extraBuffer.append(' ');
              }

              // Append the alternative name.
              if (verbose) {
                extraBuffer.append(fieldInfo.type).append(' ');
              }
              extraBuffer.append(fieldInfo.originalName);

              // Store the additional line.
              extraOutLines.add(extraBuffer);
            }
          }
        }
      }
    }

    // Just append the obfuscated name if we haven't found any matching
    // fields.
    if (extraIndent < 0) {
      outLine.append(obfuscatedFieldName);
    }
  }
Пример #9
0
  @Override
  public String toString() {
    Set<NonTerminal> nts = getNonTerminals();
    Iterator<NonTerminal> i = nts.iterator();
    String s = "";
    String start = getNonTerminalDef(getStartSymbol()) + "\n";

    while (i.hasNext()) {
      s += getNonTerminalDef(i.next()) + "\n";
    }

    return start + s.replace(start, "");
  }
Пример #10
0
 public Set /*<PCNode>*/ matchSpecific(Pattern simple_name_pattern) {
   Set matches = new HashSet();
   Iterator ii = inners.keySet().iterator();
   while (ii.hasNext()) {
     String inner = (String) ii.next();
     // System.out.print("Matching "+inner+" against "+simple_name_pattern.pattern()+": ");
     if (simple_name_pattern.matcher(inner).matches()) {
       // System.out.println("true");
       matches.add(inners.get(inner));
     } else {
       // System.out.println("false");
     }
   }
   return matches;
 }
Пример #11
0
  /** Method to dump debugging information */
  private void dumpAll(Map map, int lvmid) {
    if (DEBUG) {
      Set keys = map.keySet();

      System.err.println("Dump for " + lvmid);
      int j = 0;
      for (Iterator i = keys.iterator(); i.hasNext(); j++) {
        Monitor monitor = (Monitor) map.get(i.next());
        System.err.println(j + "\t" + monitor.getName() + "=" + monitor.getValue());
      }
      System.err.println("nextEntry = " + nextEntry + " pollForEntry = " + pollForEntry);
      System.err.println("Buffer info:");
      System.err.println("buffer = " + buffer);
    }
  }
Пример #12
0
  public static void dfs(int x) {
    Set<Integer> L = new HashSet<Integer>();
    while (!L.contains(x)) {
      if (S[x]) return;
      L.add(x);
      S[x] = true;
      x = f[x];
    }
    if (cycle[x]) return;

    cycle_cnt++;
    do {
      cycle[x] = true;
      x = f[x];
    } while (!cycle[x]);
  }
Пример #13
0
 @Override
 public Set<TypeElement> scan(Element e, Set<TypeElement> p) {
   for (AnnotationMirror annotationMirror : elements.getAllAnnotationMirrors(e)) {
     Element e2 = annotationMirror.getAnnotationType().asElement();
     p.add((TypeElement) e2);
   }
   return super.scan(e, p);
 }
Пример #14
0
 public void addParent(PCNode parent) {
   // Polyglot thinks java.lang.Object is a superclass of itself.
   // We don't want that.
   if (!is_object) {
     parents.add(parent);
     parent.children.add(this);
   }
 }
Пример #15
0
  /**
   * Handles chat room presence status updates.
   *
   * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance containing the chat room
   *     and the type, and reason of the change
   */
  @Override
  public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt) {
    ChatRoom sourceChatRoom = evt.getChatRoom();

    String eventType = evt.getEventType();

    boolean existingContact = false;
    ChatRoomSourceContact foundContact = null;
    synchronized (contactResults) {
      for (ChatRoomSourceContact contact : contactResults) {
        if (contactEqualsChatRoom(contact, sourceChatRoom)) {
          existingContact = true;
          foundContact = contact;
          contactResults.remove(contact);
          break;
        }
      }
    }

    if (LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED.equals(eventType)) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      } else {
        ChatRoomWrapper chatRoom =
            MUCActivator.getMUCService().findChatRoomWrapperFromChatRoom(sourceChatRoom);
        if (chatRoom != null) addChatRoom(sourceChatRoom, false, chatRoom.isAutojoin());
      }
    } else if ((LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED.equals(eventType))) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      }
    }
  }
Пример #16
0
  public void processFieldMapping(
      String className, String fieldType, String fieldName, String newFieldName) {
    // Original class name -> obfuscated field names.
    Map fieldMap = (Map) classFieldMap.get(className);
    if (fieldMap == null) {
      fieldMap = new HashMap();
      classFieldMap.put(className, fieldMap);
    }

    // Obfuscated field name -> fields.
    Set fieldSet = (Set) fieldMap.get(newFieldName);
    if (fieldSet == null) {
      fieldSet = new LinkedHashSet();
      fieldMap.put(newFieldName, fieldSet);
    }

    // Add the field information.
    fieldSet.add(new FieldInfo(fieldType, fieldName));
  }
Пример #17
0
 @Override
 public Variable resolveVariable(org.exist.dom.QName qname) throws XPathException {
   Variable var = super.resolveVariable(qname);
   if (var == null) {
     requiredVariables.add(
         new QName(qname.getNamespaceURI(), qname.getLocalName(), qname.getPrefix()));
     var = new VariableImpl(qname);
   }
   return var;
 }
Пример #18
0
 /**
  * Returns the index of the contact in the contact results list.
  *
  * @param contact the contact.
  * @return the index of the contact in the contact results list.
  */
 public synchronized int indexOf(ChatRoomSourceContact contact) {
   Iterator<ChatRoomSourceContact> it = contactResults.iterator();
   int i = 0;
   while (it.hasNext()) {
     if (contact.equals(it.next())) {
       return i;
     }
     i++;
   }
   return -1;
 }
Пример #19
0
  public static void loadPermissions(URL url) throws IOException, PermissionParseException {

    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    Pattern ignore = Pattern.compile("^\\s*(//.*)?$");
    Pattern valid =
        Pattern.compile("^\\s*permission\\s+(\\S+)" + "(\\s+\"([^\"]*)\"(,\\s+\"([^\"]*)\")?)?;$");

    Set<Permission> perms = new HashSet<Permission>();

    while ((line = in.readLine()) != null) {
      if (ignore.matcher(line).matches()) {
        continue;
      }

      Matcher matcher = valid.matcher(line);
      if (!matcher.matches()) {
        throw new PermissionParseException("invalid syntax: " + line);
      }

      int nGroups = matcher.groupCount();
      String type = matcher.group(1);
      String name = expand(nGroups >= 3 ? matcher.group(3) : null);
      String actions = expand(nGroups >= 5 ? matcher.group(5) : null);

      try {
        Permission perm = getPermission(type, name, actions);
        perms.add(perm);
      } catch (Throwable e) {
        String message =
            String.format(
                "could not instantiate permission: " + "type=%s name=%s actions=",
                type, name, actions);
        throw new PermissionParseException(message, e);
      }
    }

    in.close();

    permSet.addAll(perms);
  }
Пример #20
0
 private Set<String> initPlatformAnnotations() {
   Set<String> platformAnnotations = new HashSet<String>();
   platformAnnotations.add("java.lang.Deprecated");
   platformAnnotations.add("java.lang.Override");
   platformAnnotations.add("java.lang.SuppressWarnings");
   platformAnnotations.add("java.lang.annotation.Documented");
   platformAnnotations.add("java.lang.annotation.Inherited");
   platformAnnotations.add("java.lang.annotation.Retention");
   platformAnnotations.add("java.lang.annotation.Target");
   return Collections.unmodifiableSet(platformAnnotations);
 }
Пример #21
0
  @Override
  public void chatRoomProviderWrapperRemoved(ChatRoomProviderWrapper provider) {
    LinkedList<ChatRoomSourceContact> tmpContactResults;
    synchronized (contactResults) {
      tmpContactResults = new LinkedList<ChatRoomSourceContact>(contactResults);

      for (ChatRoomSourceContact contact : tmpContactResults) {
        if (contact.getProvider().equals(provider.getProtocolProvider())) {
          contactResults.remove(contact);
          fireContactRemoved(contact);
        }
      }
    }
  }
Пример #22
0
  public Collection<NamedRegion> parseProbes() throws IOException {
    double ethreshold = 1.0e-3;
    Parser<BlastTabEntry> parser =
        new Parser<BlastTabEntry>(blasttab, new BlastTabEntry.ParsingMapper());
    Iterator<BlastTabEntry> itr =
        new FilterIterator<BlastTabEntry, BlastTabEntry>(
            new BlastTabEntry.ExpectedScoreFilter(ethreshold), parser);

    Map<String, Set<Region>> primerHits = new TreeMap<String, Set<Region>>();
    Set<String> primerNames = new TreeSet<String>();

    while (itr.hasNext()) {
      BlastTabEntry entry = itr.next();
      NamedRegion r = createNamedRegion(entry);
      if (!primerHits.containsKey(entry.getQuery())) {
        primerHits.put(entry.getQuery(), new HashSet<Region>());
      }
      primerHits.get(entry.getQuery()).add(r);
      primerNames.add(removePrimerLR(entry.getQuery()));
    }

    LinkedList<NamedRegion> probes = new LinkedList<NamedRegion>();

    for (String primerName : primerNames) {
      Pair<Region, Region> hits = findProbePair(primerName, primerHits);
      if (hits != null) {
        Region left = hits.getFirst(), right = hits.getLast();
        int start = Math.min(left.getStart(), right.getStart());
        int end = Math.max(left.getEnd(), right.getEnd());

        NamedRegion probe = new NamedRegion(genome, left.getChrom(), start, end, primerName);
        probes.addLast(probe);
      }
    }

    return probes;
  }
Пример #23
0
  /**
   * Adds found result to the query results.
   *
   * @param room the chat room.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   * @param isAutoJoin the auto join state of the contact.
   */
  private void addChatRoom(ChatRoom room, boolean addQueryResult, boolean isAutoJoin) {
    if (queryString == null
        || ((room.getName().contains(queryString) || room.getIdentifier().contains(queryString)))) {
      ChatRoomSourceContact contact = new ChatRoomSourceContact(room, this, isAutoJoin);
      synchronized (contactResults) {
        contactResults.add(contact);
      }

      if (addQueryResult) {
        addQueryResult(contact, false);
      } else {
        fireContactReceived(contact, false);
      }
    }
  }
Пример #24
0
 @Override
 public UserDefinedFunction resolveFunction(org.exist.dom.QName qname, int argCount)
     throws XPathException {
   UserDefinedFunction func = super.resolveFunction(qname, argCount);
   if (func == null) {
     requiredFunctions.add(
         new QName(qname.getNamespaceURI(), qname.getLocalName(), qname.getPrefix()));
     func =
         new UserDefinedFunction(
             this,
             new FunctionSignature(
                 qname,
                 null,
                 new SequenceType(Type.ITEM, org.exist.xquery.Cardinality.ZERO_OR_MORE),
                 true));
     func.setFunctionBody(new SequenceConstructor(this));
   }
   return func;
 }
Пример #25
0
  /**
   * Adds found result to the query results.
   *
   * @param pps the protocol provider associated with the found chat room.
   * @param chatRoomName the name of the chat room.
   * @param chatRoomID the id of the chat room.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   * @param isAutoJoin the auto join state of the contact.
   */
  private void addChatRoom(
      ProtocolProviderService pps,
      String chatRoomName,
      String chatRoomID,
      boolean addQueryResult,
      boolean isAutoJoin) {
    if (queryString == null
        || ((chatRoomName.contains(queryString) || chatRoomID.contains(queryString)))) {
      ChatRoomSourceContact contact =
          new ChatRoomSourceContact(chatRoomName, chatRoomID, this, pps, isAutoJoin);
      synchronized (contactResults) {
        contactResults.add(contact);
      }

      if (addQueryResult) {
        addQueryResult(contact, false);
      } else {
        fireContactReceived(contact, false);
      }
    }
  }
Пример #26
0
  /**
   * Indicates that a change has occurred in the chat room data list.
   *
   * @param evt the event that describes the change.
   */
  @Override
  public void contentChanged(final ChatRoomListChangeEvent evt) {
    ChatRoomWrapper chatRoom = evt.getSourceChatRoom();
    switch (evt.getEventID()) {
      case ChatRoomListChangeEvent.CHAT_ROOM_ADDED:
        addChatRoom(chatRoom.getChatRoom(), false, chatRoom.isAutojoin());
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_REMOVED:
        LinkedList<ChatRoomSourceContact> tmpContactResults;
        synchronized (contactResults) {
          tmpContactResults = new LinkedList<ChatRoomSourceContact>(contactResults);

          for (ChatRoomSourceContact contact : tmpContactResults) {
            if (contactEqualsChatRoom(contact, chatRoom)) {
              contactResults.remove(contact);
              fireContactRemoved(contact);
              break;
            }
          }
        }
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_CHANGED:
        synchronized (contactResults) {
          for (ChatRoomSourceContact contact : contactResults) {
            if (contactEqualsChatRoom(contact, chatRoom.getChatRoom())) {
              if (chatRoom.isAutojoin() != contact.isAutoJoin()) {
                contact.setAutoJoin(chatRoom.isAutojoin());
                fireContactChanged(contact);
              }
              break;
            }
          }
        }
        break;
      default:
        break;
    }
  }
Пример #27
0
 public boolean hasFlag(Flag f) {
   return flags.contains(f);
 }
Пример #28
0
  /*
     public String transformedName() {
  if (outer != null) {
      String ps = outer.toString();
      if (ps.equals("")) {
  	return name;
      } else {
  	if (outer.isClass()) {
  	    return ps+"$"+name;
  	} else {
  	    return ps+"."+name;
  	}
      }
  }
  return "";
     }
     */
  public Set /*<PCNode>*/ matchScope(
      Pattern simple_name_pattern, Set /*<PCNode>*/ classes, Set /*<PCNode>*/ packages) {
    Set this_scope = matchClass(simple_name_pattern);
    Set this_scope_names = new HashSet();
    Iterator tsi = this_scope.iterator();
    while (tsi.hasNext()) {
      PCNode pc = (PCNode) tsi.next();
      // Add name to shadow outer classes
      this_scope_names.add(pc.name);
    }
    if (is_class) {
      // Match inner classes of outer classes or same package
      Set outer_scope = outer.matchScope(simple_name_pattern, classes, packages);
      Iterator osi = outer_scope.iterator();
      while (osi.hasNext()) {
        PCNode pc = (PCNode) osi.next();
        if (!this_scope_names.contains(pc.name)) {
          this_scope.add(pc);
          // Nothing to shadow here
        }
      }
    } else {
      // Match specifically imported classes
      Iterator ci = classes.iterator();
      while (ci.hasNext()) {
        PCNode c = (PCNode) ci.next();
        if (!this_scope_names.contains(c.name)) {
          // Add name to list to shadow nonspecifically imported classes
          this_scope_names.add(c.name);
          // If it matches the pattern, add it to the list of matches
          if (simple_name_pattern.matcher(c.name).matches()) {
            this_scope.add(c);
          }
        }
      }
      // Match nonspecifically imported classes
      Set /*<String>*/ new_names = new HashSet();
      Iterator pi = packages.iterator();
      while (pi.hasNext()) {
        PCNode p = (PCNode) pi.next();
        Set /*<PCNode>*/ p_matches = p.matchSpecific(simple_name_pattern);
        Iterator pci = p_matches.iterator();
        while (pci.hasNext()) {
          PCNode pc = (PCNode) pci.next();
          if (!this_scope_names.contains(pc.name)) {
            // Nonspecifically imported classes do not shadow each other,
            // but they may shadow toplevel packages
            new_names.add(pc.name);
            // If it matches the pattern, add it to the list of matches
            if (simple_name_pattern.matcher(pc.name).matches()) {
              this_scope.add(pc);
            }
          }
        }
      }
      this_scope_names.addAll(new_names);

      // Finally, match toplevel classes and packages
      Iterator tli = root.root.matchSpecific(simple_name_pattern).iterator();
      while (tli.hasNext()) {
        PCNode tl = (PCNode) tli.next();
        if (!this_scope_names.contains(tl.name)) {
          // If it matches the pattern, add it to the list of matches
          if (simple_name_pattern.matcher(tl.name).matches()) {
            this_scope.add(tl);
          }
        }
      }
    }
    if (abc.main.Debug.v().namePatternProcessing)
      System.out.println(this + ".matchScope " + simple_name_pattern.pattern() + ": " + this_scope);
    return this_scope;
  }
Пример #29
0
  /**
   * Finds the original method name(s), appending the first one to the out line, and any additional
   * alternatives to the extra lines.
   */
  private void originalMethodName(
      String className,
      String obfuscatedMethodName,
      int lineNumber,
      String type,
      String arguments,
      StringBuffer outLine,
      List extraOutLines) {
    int extraIndent = -1;

    // Class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap != null) {
      // Obfuscated method names -> methods.
      Set methodSet = (Set) methodMap.get(obfuscatedMethodName);
      if (methodSet != null) {
        // Find all matching methods.
        Iterator methodInfoIterator = methodSet.iterator();
        while (methodInfoIterator.hasNext()) {
          MethodInfo methodInfo = (MethodInfo) methodInfoIterator.next();
          if (methodInfo.matches(lineNumber, type, arguments)) {
            // Is this the first matching method?
            if (extraIndent < 0) {
              extraIndent = outLine.length();

              // Append the first original name.
              if (verbose) {
                outLine.append(methodInfo.type).append(' ');
              }
              outLine.append(methodInfo.originalName);
              if (verbose) {
                outLine.append('(').append(methodInfo.arguments).append(')');
              }
            } else {
              // Create an additional line with the proper
              // indentation.
              StringBuffer extraBuffer = new StringBuffer();
              for (int counter = 0; counter < extraIndent; counter++) {
                extraBuffer.append(' ');
              }

              // Append the alternative name.
              if (verbose) {
                extraBuffer.append(methodInfo.type).append(' ');
              }
              extraBuffer.append(methodInfo.originalName);
              if (verbose) {
                extraBuffer.append('(').append(methodInfo.arguments).append(')');
              }

              // Store the additional line.
              extraOutLines.add(extraBuffer);
            }
          }
        }
      }
    }

    // Just append the obfuscated name if we haven't found any matching
    // methods.
    if (extraIndent < 0) {
      outLine.append(obfuscatedMethodName);
    }
  }
  private Duple<CrownOperations.Reason, ISynset> getEstimatedSynonym(
      String targetLemma, Set<String> synonyms, POS pos, String gloss) {

    Counter<ISynset> synsetCounts = new ObjectCounter<ISynset>();

    List<String> lemmasInWn = new ArrayList<String>();
    for (String lemma : synonyms) {
      // Get the WordNet sysnet if it exists
      Set<ISynset> senses = WordNetUtils.getSynsets(dict, lemma, pos);
      if (senses.isEmpty()) continue;

      lemmasInWn.add(lemma);
      synsetCounts.countAll(senses);

      // Get the hypernyms of the synset and count their occurrence too
      for (ISynset synset : senses) {
        // Do a sanity check that avoids attaching this Entry if its
        // lemma appears anywhere near the synonoyms.  This check
        // potentially has some false positives since we might avoid
        // putting the lemma somewhere valid (in which case it would
        // have more than would valid location) but is used to avoid
        // noisy integration
        if (WordNetUtils.isAlreadyInWordNet(dict, targetLemma, pos, synset)) {
          return null;
        }

        for (ISynsetID hyper : synset.getRelatedSynsets(Pointer.HYPERNYM)) {
          ISynset hyperSyn = dict.getSynset(hyper);
          if (WordNetUtils.isAlreadyInWordNet(dict, targetLemma, pos, hyperSyn)) {
            return null;
          }
          synsetCounts.count(hyperSyn);
        }
      }
    }

    // Return null if we couldn't find any of the lemma's synonyms or
    // hyponyms in WordNet
    if (synsetCounts.items().isEmpty()) return null;

    // If there was only one lemma in this list in WordNet, try comparing
    // the glosses for just that word to find a match
    if (lemmasInWn.size() == 1) {
      double maxScore = 0;
      ISynset best = null;
      String bestGloss = null;
      Set<ISynset> candidateSynonymSynsets = WordNetUtils.getSynsets(dict, lemmasInWn.get(0), pos);
      for (ISynset candidate : candidateSynonymSynsets) {

        String wnExtendedGloss = WordNetUtils.getGlossWithoutExamples(candidate);
        double score = simFunc.compare(gloss, wnExtendedGloss);
        if (maxScore < score) {
          maxScore = score;
          best = candidate;
          bestGloss = wnExtendedGloss;
        }
      }

      CrownOperations.Reason r = new CrownOperations.Reason(getClass());
      r.set("relation_type", "synonym");
      r.set("heuristic", "single-synonym");
      r.set("max_score", maxScore);
      return new Duple<CrownOperations.Reason, ISynset>(r, best);
    } else {
      // Check for whether there were ties in the max
      ISynset mostFreq = synsetCounts.max();
      int mostFreqCount = synsetCounts.getCount(mostFreq);
      List<ISynset> ties = new ArrayList<ISynset>();
      for (ISynset syn : synsetCounts.items()) {
        int c = synsetCounts.getCount(syn);
        if (c == mostFreqCount) ties.add(syn);
      }

      // If there was only one synset that had the maximum count, then we
      // report this
      if (ties.size() == 1) {

        CrownOperations.Reason r = new CrownOperations.Reason(getClass());
        r.set("relation_type", "synonym");
        r.set("heuristic", "unambiguous-max");
        r.set("count", mostFreqCount);
        return new Duple<CrownOperations.Reason, ISynset>(r, mostFreq);
      }
      // Otherwise, we try breaking ties between the synsets using gloss
      // similarity
      else {

        double maxScore = 0;
        ISynset best = null;
        String bestGloss = null;
        for (ISynset candidate : ties) {
          String wnExtendedGloss = WordNetUtils.getGlossWithoutExamples(candidate);
          double score = simFunc.compare(gloss, wnExtendedGloss);
          if (maxScore < score) {
            maxScore = score;
            best = candidate;
            bestGloss = wnExtendedGloss;
          }
        }

        CrownOperations.Reason r = new CrownOperations.Reason(getClass());
        r.set("relation_type", "synonym");
        r.set("heuristic", "tied-synonyms");
        r.set("max_score", maxScore);
        return new Duple<CrownOperations.Reason, ISynset>(r, best);
      }
    }
  }