public virtual JSGFRuleName resolve(JSGFRuleName ruleName) { JSGFRuleName jsgfruleName = new JSGFRuleName(ruleName.getRuleName()); string simpleRuleName = jsgfruleName.getSimpleRuleName(); string simpleGrammarName = jsgfruleName.getSimpleGrammarName(); string packageName = jsgfruleName.getPackageName(); string fullGrammarName = jsgfruleName.getFullGrammarName(); if (packageName != null && simpleGrammarName == null) { string message = new StringBuilder().append("Error: badly formed rulename ").append(jsgfruleName).toString(); throw new JSGFGrammarException(message); } if (String.instancehelper_equals(ruleName.getSimpleRuleName(), "NULL")) { return(JSGFRuleName.__NULL); } if (String.instancehelper_equals(ruleName.getSimpleRuleName(), "VOID")) { return(JSGFRuleName.__VOID); } if (fullGrammarName == null && this.getRule(simpleRuleName) != null) { return(new JSGFRuleName(new StringBuilder().append(this.name).append('.').append(simpleRuleName).toString())); } if (fullGrammarName != null) { JSGFRuleGrammar jsgfruleGrammar = this.manager.retrieveGrammar(fullGrammarName); if (jsgfruleGrammar != null && jsgfruleGrammar.getRule(simpleRuleName) != null) { return(new JSGFRuleName(new StringBuilder().append(fullGrammarName).append('.').append(simpleRuleName).toString())); } } ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(this.__imports); List list = arrayList2; list.add(new JSGFRuleName(new StringBuilder().append(this.name).append(".*").toString())); Iterator iterator = arrayList2.iterator(); while (iterator.hasNext()) { JSGFRuleName jsgfruleName2 = (JSGFRuleName)iterator.next(); string simpleRuleName2 = jsgfruleName2.getSimpleRuleName(); string simpleGrammarName2 = jsgfruleName2.getSimpleGrammarName(); string fullGrammarName2 = jsgfruleName2.getFullGrammarName(); if (fullGrammarName2 == null) { string message2 = new StringBuilder().append("Error: badly formed import ").append(ruleName).toString(); throw new JSGFGrammarException(message2); } JSGFRuleGrammar jsgfruleGrammar2 = this.manager.retrieveGrammar(fullGrammarName2); if (jsgfruleGrammar2 == null) { [email protected](new StringBuilder().append("Warning: import of unknown grammar ").append(ruleName).append(" in ").append(this.name).toString()); } else if (!String.instancehelper_equals(simpleRuleName2, "*") && jsgfruleGrammar2.getRule(simpleRuleName2) == null) { [email protected](new StringBuilder().append("Warning: import of undefined rule ").append(ruleName).append(" in ").append(this.name).toString()); } else if (String.instancehelper_equals(fullGrammarName2, fullGrammarName) || String.instancehelper_equals(simpleGrammarName2, fullGrammarName)) { if (String.instancehelper_equals(simpleRuleName2, "*")) { if (jsgfruleGrammar2.getRule(simpleRuleName) != null) { List list2 = arrayList; list2.add(new JSGFRuleName(new StringBuilder().append(fullGrammarName2).append('.').append(simpleRuleName).toString())); } } else if (String.instancehelper_equals(simpleRuleName2, simpleRuleName)) { List list3 = arrayList; list3.add(new JSGFRuleName(new StringBuilder().append(fullGrammarName2).append('.').append(simpleRuleName).toString())); } } else if (fullGrammarName == null) { if (String.instancehelper_equals(simpleRuleName2, "*")) { if (jsgfruleGrammar2.getRule(simpleRuleName) != null) { List list4 = arrayList; list4.add(new JSGFRuleName(new StringBuilder().append(fullGrammarName2).append('.').append(simpleRuleName).toString())); } } else if (String.instancehelper_equals(simpleRuleName2, simpleRuleName)) { List list5 = arrayList; list5.add(new JSGFRuleName(new StringBuilder().append(fullGrammarName2).append('.').append(simpleRuleName).toString())); } } } int num = arrayList.size(); if (num == 0) { return(null); } if (num == 1) { return((JSGFRuleName)arrayList.get(0)); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Warning: ambiguous reference ").append(jsgfruleName).append(" in ").append(this.name).append(" to "); Iterator iterator2 = arrayList.iterator(); while (iterator2.hasNext()) { JSGFRuleName jsgfruleName3 = (JSGFRuleName)iterator2.next(); stringBuilder.append(jsgfruleName3).append(" and "); } stringBuilder.setLength(stringBuilder.length() - 5); string message3 = stringBuilder.toString(); throw new JSGFGrammarException(message3); }