org.jvoicexml.xml.srgs
Class Rule

java.lang.Object
  extended by org.jvoicexml.xml.AbstractXmlNode
      extended by org.jvoicexml.xml.srgs.Rule
All Implemented Interfaces:
SrgsNode, VoiceXmlNode, XmlNode, Node

public final class Rule
extends AbstractXmlNode
implements VoiceXmlNode

A rule definition associates a legal rule expansion with a rulename. The rule definition is also responsible for defining the scope of the rule definition: whether it is local to the grammar in which it is defined or whether it may be referenced within other grammars. Finally, the rule definition may additionally include documentation comments and other pragmatics.

The rulename for each rule definition must be unique within a grammar. The same rulename may be used in multiple grammars.

Version:
$Revision: 2895 $
Author:
Steve Doyle

Field Summary
static String ATTRIBUTE_ID
          Rule identifier.
protected static ArrayList<String> ATTRIBUTE_NAMES
          Supported attribute names for this node.
static String ATTRIBUTE_SCOPE
          defines the scope of the rule definition.
static String TAG_NAME
          Name of the tag.
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
Rule()
          Construct a new rule object without a node.
 
Method Summary
 Text addText(String text)
          Create a new text within this node.
protected  boolean canContainChild(String tagName)
          Can the specified sub-tag be contained within this node?
 Collection<String> getAttributeNames()
          Returns a collection of permitted attribute names for the node.
 String getId()
          Retrieve the id attribute.
 String getScope()
          Retrieve the scope attribute.
 String getTagName()
          Get the name of the tag for the derived node.
 boolean isPublic()
          Checks if the current rule is publicly visible.
 void makePrivate()
          .
 void makePublic()
          Marks this rule as public.
 XmlNode newInstance(Node n, XmlNodeFactory<? extends XmlNode> factory)
          Create a new instance for the given node.
 void setId(String id)
          Set the id attribute.
 void setScope(String scope)
          Set the scope attribute.
 
Methods inherited from class org.jvoicexml.xml.AbstractXmlNode
addChild, addChild, appendChild, appendChild, appendDeepClone, cloneNode, compareDocumentPosition, equals, getAttribute, getAttributes, getBaseURI, getChildNodes, getChildNodes, getChildren, getDefinedAttributeNames, getFeature, getFirstChild, getFirstLevelTextContent, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeFactory, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getOwnerXmlDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, hashCode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setNodeValue, setPrefix, setTextContent, setUserData, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jvoicexml.xml.XmlNode
addChild, getAttribute, getChildNodes, getChildren, getNode, setAttribute
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Field Detail

TAG_NAME

public static final String TAG_NAME
Name of the tag.

See Also:
Constant Field Values

ATTRIBUTE_ID

public static final String ATTRIBUTE_ID
Rule identifier.

See Also:
Constant Field Values

ATTRIBUTE_SCOPE

public static final String ATTRIBUTE_SCOPE
defines the scope of the rule definition. Defined values are public and private.

See Also:
Constant Field Values

ATTRIBUTE_NAMES

protected static final ArrayList<String> ATTRIBUTE_NAMES
Supported attribute names for this node.

Constructor Detail

Rule

public Rule()
Construct a new rule object without a node.

This is necessary for the node factory.

See Also:
VoiceXmlNodeFactory
Method Detail

getTagName

public String getTagName()
Get the name of the tag for the derived node.

Specified by:
getTagName in interface XmlNode
Returns:
name of the tag.

newInstance

public XmlNode newInstance(Node n,
                           XmlNodeFactory<? extends XmlNode> factory)
Create a new instance for the given node.

Each XmlNode can serve as a prototype in a XmlNodeFactory to produce a collection of child nodes. Factories can then use the prototype pattern to produce new nodes.

Specified by:
newInstance in interface XmlNode
Parameters:
n - The node to encapsulate.
factory - the factroy that calls this method.
Returns:
The new instance.
See Also:
XmlNodeFactory

getId

public String getId()
Retrieve the id attribute.

Returns:
Value of the id attribute.
See Also:
ATTRIBUTE_ID

setId

public void setId(String id)
Set the id attribute.

Parameters:
id - Value of the id attribute.
See Also:
ATTRIBUTE_ID

getScope

public String getScope()
Retrieve the scope attribute.

Returns:
Value of the scope attribute.
See Also:
ATTRIBUTE_SCOPE

setScope

public void setScope(String scope)
Set the scope attribute.

Parameters:
scope - Value of the scope attribute.
See Also:
ATTRIBUTE_SCOPE

makePrivate

public void makePrivate()
. Marks this rule as private

Since:
0.7.4

makePublic

public void makePublic()
Marks this rule as public.

Since:
0.7.4

isPublic

public boolean isPublic()
Checks if the current rule is publicly visible.

Returns:
true if the rule is public.
Since:
0.7.5

addText

public Text addText(String text)
Create a new text within this node.

Parameters:
text - The text to be added.
Returns:
The new created text.

canContainChild

protected boolean canContainChild(String tagName)
Can the specified sub-tag be contained within this node?

Specified by:
canContainChild in class AbstractXmlNode
Parameters:
tagName - Name of child.
Returns:
True if the sub-tag is allowed on this node.

getAttributeNames

public Collection<String> getAttributeNames()
Returns a collection of permitted attribute names for the node.

Specified by:
getAttributeNames in interface XmlNode
Overrides:
getAttributeNames in class AbstractXmlNode
Returns:
A collection of attribute names that are allowed for the node


Copyright © 2005-2009JVoiceXML group.