public virtual void resolveAllRules() { StringBuilder stringBuilder = new StringBuilder(); Iterator iterator = this.__imports.iterator(); while (iterator.hasNext()) { JSGFRuleName jsgfruleName = (JSGFRuleName)iterator.next(); string fullGrammarName = jsgfruleName.getFullGrammarName(); if (this.manager.retrieveGrammar(fullGrammarName) == null) { stringBuilder.append("Undefined grammar ").append(fullGrammarName).append(" imported in ").append(this.name).append('\n'); } } if (stringBuilder.length() > 0) { string message = stringBuilder.toString(); throw new JSGFGrammarException(message); } iterator = this.__rules.values().iterator(); while (iterator.hasNext()) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState)iterator.next(); this.resolveRule(jsgfruleState.rule); } }
public virtual void setEnabled(string ruleName, bool enabled) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); if (jsgfruleState.isEnabled != enabled) { jsgfruleState.isEnabled = enabled; } }
public virtual void addSampleSentence(string ruleName, string sample) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); if (jsgfruleState == null) { return; } jsgfruleState.samples.add(sample); }
public virtual JSGFRule getRule(string ruleName) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); if (jsgfruleState == null) { return(null); } return(jsgfruleState.rule); }
public virtual void setEnabled(bool enabled) { Iterator iterator = this.__rules.values().iterator(); while (iterator.hasNext()) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState)iterator.next(); jsgfruleState.isEnabled = enabled; } }
private JSGFRule getKnownRule(string text) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(text); if (jsgfruleState == null) { string text2 = new StringBuilder().append("Unknown Rule: ").append(text).toString(); throw new IllegalArgumentException(text2); } return(jsgfruleState.rule); }
public override string toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("#JSGF V1.0;").append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(this.formatComment(this.grammarDocComment)); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append("grammar ").append(this.name).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); Set set = this.importDocComments.keySet(); for (int i = 0; i < this.__imports.size(); i++) { string text = new StringBuilder().append('<').append(((JSGFRuleName)this.__imports.get(i)).getRuleName()).append('>').toString(); if (set.contains(text)) { stringBuilder.append(this.formatComment((string)this.importDocComments.get(text))); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append("import ").append(new StringBuilder().append(text).append(';').toString()).append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); } } set = this.ruleDocComments.keySet(); Iterator iterator = this.__rules.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); object key = entry.getKey(); if (set.size() > 0 && set.contains(key)) { stringBuilder.append(this.formatComment((string)this.ruleDocComments.get(key))).append(JSGFRuleGrammar.LINE_SEPARATOR); } JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState)entry.getValue(); if (jsgfruleState.isPublic) { stringBuilder.append("public "); } stringBuilder.append('<').append(key).append("> = ").append(jsgfruleState.rule).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR); stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR); } return(stringBuilder.toString()); }
public virtual void setRuleChanged(string ruleName, bool changed) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); jsgfruleState.isChanged = changed; }
public virtual bool isRuleChanged(string ruleName) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); return(jsgfruleState.isChanged); }
public virtual void setRule(string ruleName, JSGFRule rule, bool isPublic) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = new JSGFRuleGrammar.JSGFRuleState(this, rule, true, isPublic); this.__rules.put(ruleName, jsgfruleState); }
public virtual bool isEnabled(string ruleName) { JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState) this.__rules.get(ruleName); return(jsgfruleState != null && jsgfruleState.isEnabled); }