JSAPI 2.0

javax.speech.recognition
Class RuleReference

Object
  extended by RuleComponent
      extended by RuleReference

public class RuleReference
extends RuleComponent

Specifies a reference to a RuleGrammar or a named Rule in a RuleGrammar.

The following table summarizes the various forms of rule reference in SRGS:

Local rule reference <ruleref uri="#rulename"/>
Reference to a named rule of a grammar identified by a URI with optional media type <ruleref uri="grammarURI#rulename" type="media-type"/>
Reference to the root rule of a grammar identified by a URI with optional media type <ruleref uri="grammarURI" type="media-type"/>

Rule names must match the "Name" Production of XML 1.0 [XML ยง2.3] and be a legal XML ID.

The RuleSpecial class defines the special definitions NULL, VOID, and GARBAGE.

See Also:
Grammar, RuleGrammar, RuleSpecial, NULL, VOID, GARBAGE

Constructor Summary
RuleReference(String ruleName)
          Constructs a RuleReference given a rule name.
RuleReference(String grammarReference, String ruleName)
          Constructs a RuleReference given a grammar reference and rule name.
RuleReference(String grammarReference, String ruleName, String mediaType)
          Constructs a RuleReference from a grammar reference, rule name, and media type.
 
Method Summary
 String getGrammarReference()
          Gets the grammar reference part of this RuleReference.
 String getMediaType()
          Gets the media type part of this RuleReference.
 String getRuleName()
          Gets the rule name part of this RuleReference.
 String toString()
          Returns a String representing this RuleComponent as grammar text.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RuleReference

public RuleReference(String ruleName)
              throws IllegalArgumentException
Constructs a RuleReference given a rule name. The rule name is local to the RuleGrammar context used.

Parameters:
ruleName - the name of a rule
Throws:
IllegalArgumentException - if ruleName is not valid grammar text or is null
See Also:
getRuleName

RuleReference

public RuleReference(String grammarReference,
                     String ruleName)
              throws IllegalArgumentException
Constructs a RuleReference given a grammar reference and rule name. The rule name is considered in the context of the grammar reference.

Parameters:
grammarReference - the grammar reference for the desired grammar
ruleName - the name of a rule
Throws:
IllegalArgumentException - if the arguments are not valid grammar text or if both arguments are null
See Also:
getGrammarReference, getRuleName

RuleReference

public RuleReference(String grammarReference,
                     String ruleName,
                     String mediaType)
              throws IllegalArgumentException
Constructs a RuleReference from a grammar reference, rule name, and media type. The rule name is considered in the context of the grammar reference. The media type should match the media type of the grammar being referenced.

If the media type is null, the default media type is used. The default media type is "application/srgs+xml".

Parameters:
grammarReference - the grammar reference for the desired grammar
ruleName - the name of a rule
mediaType - the media type of the containing grammar
Throws:
IllegalArgumentException - if the arguments are not valid grammar text or if grammarReference and ruleName are both null
See Also:
getGrammarReference, getRuleName, getMediaType
Method Detail

getGrammarReference

public String getGrammarReference()
Gets the grammar reference part of this RuleReference. This can return null if this is a local RuleReference.

Returns:
the grammar reference
See Also:
getRuleName

getRuleName

public String getRuleName()
Gets the rule name part of this RuleReference. This can return null if this RuleReference refers to the root rule of the grammar reference.

Returns:
the rule name
See Also:
getGrammarReference

getMediaType

public String getMediaType()
Gets the media type part of this RuleReference. This returns null if not specified in the constructor.

Returns:
the media type
See Also:
getGrammarReference, getRuleName

toString

public String toString()
Returns a String representing this RuleComponent as grammar text. The String represents a portion of a grammar that could appear on the right hand side of a Rule definition.

Overrides:
toString in class RuleComponent
Returns:
printable String representing grammar text.
See Also:
RuleComponent, Rule

JSAPI 2.0

JavaTM Speech API 2.0, Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.

Free Web Hosting