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.RuleName

java.lang.Object
  |
  +--javax.speech.recognition.Rule
        |
        +--javax.speech.recognition.RuleName

public class RuleName
extends Rule
A RuleName is a reference to a named rule. A RuleName is equivalent to the various forms of rulename syntax in the Java Speech Grammar Format (JSGF).

A fully-qualified rulename consists of a full grammar name plus the simple rulename. A full grammar name consists of a package name and a simple grammar name. The three legal forms of a rulename allowed by the Java Speech Grammar Format and in the RuleName object are:

The full grammar name is the following portion of the fully-qualified rulename: packageName.simpleGrammarName. For example, <com.sun.numbers> <com.acme.places>.

There are two special rules are defined in JSGF, <NULL> and <VOID>. Both have static instances in this class for convenience. These rulenames can be referenced in any grammar without an import statement.

There is a special case of using a RuleName to declare and manage imports of a RuleGrammar. This form is used with the addImport and removeImport methods of a RuleGrammar. It requires a full grammar name plus the string "*" for the simple rulename. For example: <com.acme.places.*>

The angle brackets placed around rulenames are syntactic constructs in JSGF but are not a part of the rulename. For clarity of code, the angle brackets may be included in calls to this class but they are automatically stripped.

The following referencing and name resolution conditions of JSGF apply.

See Also:
Rule, addImport, Serialized Form

Field Summary
String fullRuleName
          The complete specified rulename.
static RuleName NULL
          Special <NULL> rule of JSGF defining a rule that is always matched.
String packageName
          The rule's package name or null if not specified.
String simpleGrammarName
          The rule's simple grammar name or null if not specified.
String simpleRuleName
          The simple rulename.
static RuleName VOID
          Special <VOID> rule of JSGF defining a rule that can never be matched.
 
Constructor Summary
RuleName(String ruleName)
          Construct a RuleName from a string.
RuleName()
          Empty constructor which sets the rule to <NULL>.
RuleName(String packageName, String simpleGrammarName, String simpleRuleName)
          Construct a RuleName from its package-, grammar- and simple-name components.
 
Method Summary
Rule copy()
          Return a deep copy of this rule.
String getFullGrammarName()
          Get the full grammar name.
String getPackageName()
          Get the rule's package name.
String getRuleName()
          Get therulename including the package and grammar name if they are non-null.
String getSimpleGrammarName()
          Get the simple grammar name.
String getSimpleRuleName()
          Get the simple rulename.
boolean isLegalRuleName()
          Tests whether this RuleName is a legal JSGF rulename.
static boolean isLegalRuleName(String name)
          Tests whether a string is a legal JSGF rulename format.
static boolean isRuleNamePart(char c)
          Tests whether a character is a legal part of a Java Speech Grammar Format rulename.
void setRuleName(String ruleName)
          Set the rulename.
void setRuleName(String packageName, String simpleGrammarName, String simpleRuleName)
          Set the rule's name with package name, simple grammar name and simple rulename components.
String toString()
          Return a String representing the RuleName as partial Java Speech Grammar Format text.
 
Methods inherited from class javax.speech.recognition.Rule
copy, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

fullRuleName

protected String fullRuleName
The complete specified rulename. Maybe a fully-qualified rulename, qualified rulename, or simple rulename depending upon how the object is constructed.

packageName

protected String packageName
The rule's package name or null if not specified.

simpleGrammarName

protected String simpleGrammarName
The rule's simple grammar name or null if not specified.

simpleRuleName

protected String simpleRuleName
The simple rulename.

NULL

public static RuleName NULL
Special <NULL> rule of JSGF defining a rule that is always matched.

VOID

public static RuleName VOID
Special <VOID> rule of JSGF defining a rule that can never be matched.
Constructor Detail

RuleName

public RuleName(String ruleName)
Construct a RuleName from a string. Leading and trailing angle brackets are stripped if found. The rulename may be a simple rulename, qualified rulename or full-qualified rulename.

RuleName

public RuleName()
Empty constructor which sets the rule to <NULL>.

RuleName

public RuleName(String packageName,
                String simpleGrammarName,
                String simpleRuleName)
         throws IllegalArgumentException
Construct a RuleName from its package-, grammar- and simple-name components. Leading and trailing angle brackets are stripped from ruleName if found. The package name may be null. The grammar name may be null only if packageName is null.

Parameters:
packageName - the package name of a fully-qualified rulename or null
simpleGrammarName - the grammar name of a fully-qualified or qualified rule or null
simpleRuleName - the simple rulename
Throws:
IllegalArgumentException - null simpleGrammarName with non-null packageName
Method Detail

getRuleName

public String getRuleName()
Get therulename including the package and grammar name if they are non-null. The return value may be a fully-qualified rulename, qualified rulename, or simple rulename.

setRuleName

public void setRuleName(String ruleName)
Set the rulename. The rulename may be a simple-, qualified- or fully-qualified rulename. Leading and trailing angle brackets are stripped if found.

setRuleName

public void setRuleName(String packageName,
                        String simpleGrammarName,
                        String simpleRuleName)
                throws IllegalArgumentException
Set the rule's name with package name, simple grammar name and simple rulename components. Leading and trailing angle brackets are stripped from ruleName. The package name may be null. The simple grammar name may be null only if packageName is null.

Throws:
IllegalArgumentException - null simpleGrammarName with non-null packageName

getSimpleRuleName

public String getSimpleRuleName()
Get the simple rulename.

getSimpleGrammarName

public String getSimpleGrammarName()
Get the simple grammar name. May be null.

getFullGrammarName

public String getFullGrammarName()
Get the full grammar name. If the packageName is null, the return value is the simple grammar name. May return null.

getPackageName

public String getPackageName()
Get the rule's package name.

isLegalRuleName

public boolean isLegalRuleName()
Tests whether this RuleName is a legal JSGF rulename. The isLegalRuleName(java.lang.String) method defines legal rulename forms.

See Also:
isLegalRuleName(java.lang.String), isRuleNamePart(char)

isLegalRuleName

public static boolean isLegalRuleName(String name)
Tests whether a string is a legal JSGF rulename format. The legal patterns for rulenames are defined above. The method does not test whether the rulename exists or is resolvable (see the resolve method of RuleGrammar).

An import string (e.g. "com.acme.*") is considered legal even though the "*" character is not a legal rulename character. If present, starting and ending angle brackets are ignored.

See Also:
isLegalRuleName(), isRuleNamePart(char)

isRuleNamePart

public static boolean isRuleNamePart(char c)
Tests whether a character is a legal part of a Java Speech Grammar Format rulename.

See Also:
isLegalRuleName(), isLegalRuleName(java.lang.String)

copy

public Rule copy()
Return a deep copy of this rule.
Overrides:
copy in class Rule

toString

public String toString()
Return a String representing the RuleName as partial Java Speech Grammar Format text. The return value is <RuleName>.
Overrides:
toString in class Rule

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