Overview | Package | Class | Tree | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.speech.recognition.Rule | +--javax.speech.recognition.RuleName
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:
<simpleRulename>
<digits>
, <date>
<simpleGrammarName.simpleRulename>
<numbers.digits>
, <places.cities>
<packageName.simpleGrammarName.simpleRulename>
<com.sun.numbers.digits>
<com.acme.places.zipCodes>
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.
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 |
protected String fullRuleName
protected String packageName
null
if not specified.protected String simpleGrammarName
null
if not specified.protected String simpleRuleName
public static RuleName NULL
<NULL>
rule of JSGF
defining a rule that is always matched.public static RuleName VOID
<VOID>
rule of JSGF
defining a rule that can never be matched.Constructor Detail |
public RuleName(String ruleName)
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.public RuleName()
<NULL>
.public RuleName(String packageName, String simpleGrammarName, String simpleRuleName) throws IllegalArgumentException
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
.
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 rulenamesimpleGrammarName
with non-null packageName
Method Detail |
public String getRuleName()
public void setRuleName(String ruleName)
public void setRuleName(String packageName, String simpleGrammarName, String simpleRuleName) throws IllegalArgumentException
ruleName
.
The package name may be null
.
The simple grammar name may be null only if packageName
is null
.
simpleGrammarName
with non-null packageName
public String getSimpleRuleName()
public String getSimpleGrammarName()
null
.public String getFullGrammarName()
packageName
is null
,
the return value is the simple grammar name.
May return null
.public String getPackageName()
public boolean isLegalRuleName()
RuleName
is a legal JSGF rulename.
The isLegalRuleName(java.lang.String)
method defines
legal rulename forms.
public static boolean isLegalRuleName(String name)
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.
public static boolean isRuleNamePart(char c)
public Rule copy()
public String toString()
RuleName
as
partial Java Speech Grammar Format text.
The return value is <RuleName>
.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