Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class javax.speech.recognition.GrammarEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--javax.speech.SpeechEvent
              |
              +--javax.speech.recognition.GrammarEvent

public class GrammarEvent
extends SpeechEvent
A GrammarEvent is issued to each GrammarListener attached to a Grammar when major events associated with that Grammar occur.

The source for a GrammarEvent is always a Grammar object.

See Also:
Grammar, GrammarListener, Serialized Form

Field Summary
boolean definitionChanged
          True if the grammar's definition has changed with a GRAMMAR_CHANGES_COMMITTED event.
boolean enabledChanged
          True if the grammar's enabled property has changed with a GRAMMAR_CHANGES_COMMITTED event.
static int GRAMMAR_ACTIVATED
          A GRAMMAR_ACTIVATED event is issued when a grammar changes state from deactivated to activated.
static int GRAMMAR_CHANGES_COMMITTED
          A GRAMMAR_CHANGES_COMMITTED event is issued when a Recognizer completes committing changes to a Grammar.
static int GRAMMAR_DEACTIVATED
          A GRAMMAR_DEACTIVATED event is issued when a grammar changes state from activated to deactivated.
GrammarException grammarException
          Non-null if any error is detected in a grammar's definition while producing a GRAMMAR_CHANGES_COMMITTED event.
 
Fields inherited from class javax.speech.SpeechEvent
id
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
GrammarEvent(Grammar source, int id, boolean enabledChanged, boolean definitionChanged, GrammarException grammarException)
          Constructs a GrammarEvent event with a specified event identifier plus state change and exception values.
GrammarEvent(Grammar source, int id)
          Constructs a GrammarEvent event with a specified event identifier.
 
Method Summary
boolean getDefinitionChanged()
          Returns true for a GRAMMAR_CHANGES_COMMITTED event if the definition of the source Grammar has changed.
boolean getEnabledChanged()
          Returns true for a GRAMMAR_CHANGES_COMMITTED event if the enabled property of the Grammar changed.
GrammarException getGrammarException()
          Returns non-null for a GRAMMAR_CHANGES_COMMITTED event if an error is found in the grammar definition.
String paramString()
          Returns a parameter string identifying this event.
 
Methods inherited from class javax.speech.SpeechEvent
getId, paramString, toString
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

GRAMMAR_CHANGES_COMMITTED

public static final int GRAMMAR_CHANGES_COMMITTED
A GRAMMAR_CHANGES_COMMITTED event is issued when a Recognizer completes committing changes to a Grammar. The event is issued immediately following the CHANGES_COMMITTED event that is issued to RecognizerListeners. That event indicates that changes have been applied to all grammars of a Recognizer. The GRAMMAR_CHANGES_COMMITTED event is specific to each individual grammar.

The event is issued when the definition of the grammar is changed, when its enabled property is changed, or both. The enabledChanged and definitionChanged flags are set accordingly.

A GRAMMAR_CHANGES_COMMITTED event can triggered without an explicit call to commitChanges - there is usually an implicit commitChanges at the completion of result finalization event processing. If any syntactic or logical errors are detected for a Grammar during the commit, the generated GrammarException is included with this event. If no problem is found the value is null.

See Also:
grammarChangesCommitted, CHANGES_COMMITTED, commitChanges, getDefinitionChanged, getEnabledChanged, getGrammarException

GRAMMAR_ACTIVATED

public static final int GRAMMAR_ACTIVATED
A GRAMMAR_ACTIVATED event is issued when a grammar changes state from deactivated to activated. The isActive method of the Grammar will now return true.

Grammar activation changes follow one of two RecognizerEvents: (1) a CHANGES_COMMITTED event in which a grammar's enabled flag is set true or (2) a FOCUS_GAINED event. The full details of the activation conditions under which a Grammar is activated are described in the documentation for the Grammar interface.

See Also:
grammarActivated, CHANGES_COMMITTED, FOCUS_GAINED

GRAMMAR_DEACTIVATED

public static final int GRAMMAR_DEACTIVATED
A GRAMMAR_DEACTIVATED event is issued when a grammar changes state from activated to deactivated. The isActive method of the Grammar will now return false.

Grammar deactivation changes follow one of two RecognizerEvents: (1) a CHANGES_COMMITTED event in which a grammar's enabled flag is set false or (2) a FOCUS_LOST event. The full details of the activation conditions under which a Grammar is deactivated are described in the documentation for the Grammar interface.

See Also:
grammarDeactivated, CHANGES_COMMITTED, FOCUS_LOST

enabledChanged

protected boolean enabledChanged
True if the grammar's enabled property has changed with a GRAMMAR_CHANGES_COMMITTED event. False for other event types.

See Also:
getEnabledChanged

definitionChanged

protected boolean definitionChanged
True if the grammar's definition has changed with a GRAMMAR_CHANGES_COMMITTED event. False for other event types.

See Also:
getDefinitionChanged

grammarException

protected GrammarException grammarException
Non-null if any error is detected in a grammar's definition while producing a GRAMMAR_CHANGES_COMMITTED event. null for other event types.

See Also:
getGrammarException
Constructor Detail

GrammarEvent

public GrammarEvent(Grammar source,
                    int id,
                    boolean enabledChanged,
                    boolean definitionChanged,
                    GrammarException grammarException)
Constructs a GrammarEvent event with a specified event identifier plus state change and exception values. For a GRAMMAR_CHANGES_COMMITTED event, the enabledChanged and definitionChanged parameters should indicate what properties of the Grammar has changed, otherwise they should be false. For a GRAMMAR_CHANGES_COMMITTED event, the grammarException parameter should be non-null only if an error is encountered in the grammar definition.

Parameters:
source - the object that issued the event
id - the identifier for the event type
enabledChanged - true if the grammar's enabled property changed
definitionChanged - true if the grammar's definition has changed
grammarException - non-null if an error is detected in a grammar's definition

GrammarEvent

public GrammarEvent(Grammar source,
                    int id)
Constructs a GrammarEvent event with a specified event identifier. The enabledChanged and definitionChanged fields are set to false. The grammarException field is set to null.

Parameters:
source - the object that issued the event
id - the identifier for the event type
Method Detail

getEnabledChanged

public boolean getEnabledChanged()
Returns true for a GRAMMAR_CHANGES_COMMITTED event if the enabled property of the Grammar changed.

getDefinitionChanged

public boolean getDefinitionChanged()
Returns true for a GRAMMAR_CHANGES_COMMITTED event if the definition of the source Grammar has changed.

getGrammarException

public GrammarException getGrammarException()
Returns non-null for a GRAMMAR_CHANGES_COMMITTED event if an error is found in the grammar definition.

paramString

public String paramString()
Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.

Returns:
a string identifying the event
Overrides:
paramString in class SpeechEvent

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

JavaTM Speech API
Copyright 1997-1998 Sun Microsystems, Inc. All rights reserved
Send comments to javaspeech-comments@sun.com