com.cloudgarden.speech
Class CGRuleGrammar

java.lang.Object
  |
  +--com.cloudgarden.speech.CGGrammar
        |
        +--com.cloudgarden.speech.CGRuleGrammar
All Implemented Interfaces:
Grammar, RuleGrammar

public class CGRuleGrammar
extends com.cloudgarden.speech.CGGrammar
implements RuleGrammar


Field Summary
protected  boolean active
           
protected  boolean enabled
           
protected  int mode
           
protected  java.lang.String name
           
protected  com.cloudgarden.speech.CGRecognizer rec
           
 
Fields inherited from interface javax.speech.recognition.Grammar
GLOBAL, RECOGNIZER_FOCUS, RECOGNIZER_MODAL
 
Constructor Summary
CGRuleGrammar(java.lang.String name, int gramId, com.cloudgarden.speech.CGRecognizer rec)
           
 
Method Summary
 void addGrammarListener(GrammarListener listener)
           
 void addImport(RuleName importName)
           
 void addResultListener(ResultListener listener)
           
 boolean areUniqueGuessesAccepted()
           
 void deleteRule(java.lang.String ruleName)
           
 int getActivationMode()
           
 java.lang.String getName()
           
 Recognizer getRecognizer()
           
 java.util.Vector getResultListeners()
           
 Rule getRule(java.lang.String ruleName)
           
protected  long getRuleID(Rule rule)
           
protected  long getRuleID(java.lang.String name)
           
 Rule getRuleInternal(java.lang.String ruleName)
           
protected  java.lang.String getRuleName(java.lang.Long ruleID)
           
protected  void grammarCommitted()
           
 boolean isActive()
           
 boolean isEnabled()
           
 boolean isEnabled(java.lang.String ruleName)
           
 boolean isRulePublic(java.lang.String ruleName)
           
 boolean joinTokensAsSeq()
           
 RuleName[] listImports()
           
 java.lang.String[] listRuleNames()
           
 void loadCFGGrammarFromFile(java.lang.String fileName)
           
protected  void notifyGrammarListener(GrammarListener l, int state)
           
protected  void notifyGrammarListeners(int state)
           
 RuleParse parse(FinalRuleResult finalRuleResult, int nBest, java.lang.String ruleName)
           
 RuleParse parse(java.lang.String[] tokens, java.lang.String ruleName)
           
 RuleParse parse(java.lang.String text, java.lang.String ruleName)
           
 RuleParse parse(java.lang.String text, java.lang.String ruleName, com.cloudgarden.speech.RuleParser rp)
           
 void removeGrammarListener(GrammarListener listener)
           
 void removeImport(RuleName importName)
           
 void removeResultListener(ResultListener listener)
           
 RuleName resolve(RuleName ruleName)
           
 Rule ruleForJSGF(java.lang.String text)
           
 void setActivationMode(int mode)
           
 void setActive(boolean active)
           
 void setEnabled(boolean enabled)
           
 void setEnabled(java.lang.String[] ruleNames, boolean enabled)
           
 void setEnabled(java.lang.String ruleName, boolean enabled)
           
 void setJoinTokensAsSeq(boolean joinTokensAsSeq)
           
 void setRule(java.lang.String name, Rule rule, boolean isPublic)
           
 void setUniqueGuessesAccepted(boolean accept)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.speech.recognition.RuleGrammar
isEnabled, toString
 
Methods inherited from interface javax.speech.recognition.Grammar
addGrammarListener, addResultListener, getActivationMode, getName, getRecognizer, isActive, removeGrammarListener, removeResultListener, setActivationMode
 

Field Detail

enabled

protected boolean enabled

name

protected java.lang.String name

active

protected boolean active

mode

protected int mode

rec

protected com.cloudgarden.speech.CGRecognizer rec
Constructor Detail

CGRuleGrammar

public CGRuleGrammar(java.lang.String name,
                     int gramId,
                     com.cloudgarden.speech.CGRecognizer rec)
Method Detail

areUniqueGuessesAccepted

public boolean areUniqueGuessesAccepted()

setUniqueGuessesAccepted

public void setUniqueGuessesAccepted(boolean accept)

joinTokensAsSeq

public boolean joinTokensAsSeq()

setJoinTokensAsSeq

public void setJoinTokensAsSeq(boolean joinTokensAsSeq)

grammarCommitted

protected void grammarCommitted()

getRuleID

protected long getRuleID(java.lang.String name)

getRuleID

protected long getRuleID(Rule rule)

getRuleName

protected java.lang.String getRuleName(java.lang.Long ruleID)

addImport

public void addImport(RuleName importName)
Specified by:
addImport in interface RuleGrammar

deleteRule

public void deleteRule(java.lang.String ruleName)
                throws java.lang.IllegalArgumentException
Specified by:
deleteRule in interface RuleGrammar

getRule

public Rule getRule(java.lang.String ruleName)
Specified by:
getRule in interface RuleGrammar

getRuleInternal

public Rule getRuleInternal(java.lang.String ruleName)
Specified by:
getRuleInternal in interface RuleGrammar

isEnabled

public boolean isEnabled(java.lang.String ruleName)
Specified by:
isEnabled in interface RuleGrammar

setEnabled

public void setEnabled(java.lang.String ruleName,
                       boolean enabled)
                throws java.lang.IllegalArgumentException
Specified by:
setEnabled in interface RuleGrammar

setEnabled

public void setEnabled(java.lang.String[] ruleNames,
                       boolean enabled)
                throws java.lang.IllegalArgumentException
Specified by:
setEnabled in interface RuleGrammar

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface RuleGrammar
Overrides:
setEnabled in class com.cloudgarden.speech.CGGrammar

isRulePublic

public boolean isRulePublic(java.lang.String ruleName)
Specified by:
isRulePublic in interface RuleGrammar

listImports

public RuleName[] listImports()
Specified by:
listImports in interface RuleGrammar

listRuleNames

public java.lang.String[] listRuleNames()
Specified by:
listRuleNames in interface RuleGrammar

parse

public RuleParse parse(java.lang.String text,
                       java.lang.String ruleName)
                throws GrammarException
Specified by:
parse in interface RuleGrammar

parse

public RuleParse parse(java.lang.String text,
                       java.lang.String ruleName,
                       com.cloudgarden.speech.RuleParser rp)
                throws GrammarException

parse

public RuleParse parse(java.lang.String[] tokens,
                       java.lang.String ruleName)
                throws GrammarException
Specified by:
parse in interface RuleGrammar

parse

public RuleParse parse(FinalRuleResult finalRuleResult,
                       int nBest,
                       java.lang.String ruleName)
                throws GrammarException
Specified by:
parse in interface RuleGrammar

removeImport

public void removeImport(RuleName importName)
Specified by:
removeImport in interface RuleGrammar

resolve

public RuleName resolve(RuleName ruleName)
                 throws GrammarException
Specified by:
resolve in interface RuleGrammar

ruleForJSGF

public Rule ruleForJSGF(java.lang.String text)
                 throws GrammarException
Specified by:
ruleForJSGF in interface RuleGrammar

setRule

public void setRule(java.lang.String name,
                    Rule rule,
                    boolean isPublic)
Specified by:
setRule in interface RuleGrammar

loadCFGGrammarFromFile

public void loadCFGGrammarFromFile(java.lang.String fileName)
Specified by:
loadCFGGrammarFromFile in interface RuleGrammar

addGrammarListener

public void addGrammarListener(GrammarListener listener)
Specified by:
addGrammarListener in interface Grammar

addResultListener

public void addResultListener(ResultListener listener)
Specified by:
addResultListener in interface Grammar

getActivationMode

public int getActivationMode()
Specified by:
getActivationMode in interface Grammar

getName

public java.lang.String getName()
Specified by:
getName in interface Grammar

isActive

public boolean isActive()
Specified by:
isActive in interface Grammar

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Grammar

setActive

public void setActive(boolean active)

removeGrammarListener

public void removeGrammarListener(GrammarListener listener)
Specified by:
removeGrammarListener in interface Grammar

getRecognizer

public Recognizer getRecognizer()
Specified by:
getRecognizer in interface Grammar

removeResultListener

public void removeResultListener(ResultListener listener)
Specified by:
removeResultListener in interface Grammar

setActivationMode

public void setActivationMode(int mode)
Specified by:
setActivationMode in interface Grammar

getResultListeners

public java.util.Vector getResultListeners()

notifyGrammarListeners

protected void notifyGrammarListeners(int state)

notifyGrammarListener

protected void notifyGrammarListener(GrammarListener l,
                                     int state)