public final class Grammar extends AbstractXmlNode implements VoiceXmlNode
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ATTRIBUTE_FETCHHINT
This defaults to the grammarfetchhint property.
|
static java.lang.String |
ATTRIBUTE_FETCHTIMEOUT
This defaults to the fetchtimeout property.
|
static java.lang.String |
ATTRIBUTE_MAXAGE
This defaults to the grammarmaxage property.
|
static java.lang.String |
ATTRIBUTE_MAXSTALE
This defaults to the grammarmaxstale property.
|
static java.lang.String |
ATTRIBUTE_MODE
Defines the mode of the grammar following the modes of the W3C Speech
Recognition Grammar Specification.
|
protected static java.util.ArrayList<java.lang.String> |
ATTRIBUTE_NAMES
Supported attribute names for this node.
|
static java.lang.String |
ATTRIBUTE_ROOT
Defines the rule which acts as the root rule of the grammar.
|
static java.lang.String |
ATTRIBUTE_SCOPE
Either "document", which makes the grammar active in all dialogs of the
current document (and relevant application leaf documents), or "dialog",
to make the grammar active throughout the current form.
|
static java.lang.String |
ATTRIBUTE_SRC
The URI specifying the location of the grammar and optionally a rulename
within that grammar, if it is external.
|
static java.lang.String |
ATTRIBUTE_SRCEXPR
Equivalent to src, except that the URI is dynamically determined by
evaluating the given ECMAScript expression in the current scope (e.g. the
current form item).
|
static java.lang.String |
ATTRIBUTE_TAG_FORMAT
Defines the tag content format for all tags within the grammar.
|
static java.lang.String |
ATTRIBUTE_TYPE
The preferred media type of the grammar.
|
static java.lang.String |
ATTRIBUTE_VERSION
Defines the version of the grammar.
|
static java.lang.String |
ATTRIBUTE_WEIGHT
Specifies the weight of the grammar.
|
static java.lang.String |
ATTRIBUTE_XML_BASE
Declares the base URI from which relative URIs in the grammar are
resolved.
|
static java.lang.String |
ATTRIBUTE_XML_LANG
The language identifier for the grammar.
|
static java.lang.String |
ATTRIBUTE_XMLNS
The designated namespace for VoiceXXML (required).
|
static java.lang.String |
DEFAULT_VERSION
Constant for version 1.0.
|
static java.lang.String |
DEFAULT_XMLNS
Default namespace.
|
static java.lang.String |
SCOPE_DIALOG
Scope dialog, which makes the grammar active throughout the
current form..
|
static java.lang.String |
SCOPE_DOCUMENT
Scope document, which makes the grammar active in all dialogs
of the current document (and relevant application leaf documents).
|
static java.lang.String |
TAG_NAME
Name of the grammar tag.
|
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 and Description |
|---|
Grammar()
Construct a new grammar object without a node.
|
| Modifier and Type | Method and Description |
|---|---|
org.w3c.dom.CDATASection |
addCData(java.lang.String data)
Creates a new CDATA section within this grammar.
|
Text |
addText(java.lang.String text)
Create a new text within this grammar.
|
protected boolean |
canContainChild(java.lang.String tagName)
Can the specified sub-tag be contained within this node?
|
java.util.Collection<java.lang.String> |
getAttributeNames()
Returns a collection of permitted attribute names for the node.
|
java.lang.String |
getFetchhint()
Retrieve the fetchhint attribute.
|
java.lang.String |
getFetchtimeout()
Retrieve the fetchtimeout attribute.
|
long |
getFetchTimeoutAsMsec()
Retrieves the fetchtimeout attribute as msec.
|
java.lang.String |
getMaxage()
Retrieve the maxage attribute.
|
long |
getMaxageAsMsec()
Retrieves the maxage attribute as msec.
|
java.lang.String |
getMaxstale()
Retrieve the maxstale attribute.
|
long |
getMaxstaleAsMsec()
Retrieves the maxstale attribute as msec.
|
ModeType |
getMode()
Retrieves the mode attribute.
|
java.lang.String |
getModename()
Retrieves the mode attribute.
|
java.util.Collection<Rule> |
getPublicRules()
Retrieves all public rule nodes.
|
java.lang.String |
getRoot()
Retrieve sthe root attribute.
|
Rule |
getRootRule()
Retrieves the root rule node.
|
Rule |
getRule(java.lang.String name)
Retrieves the rule node with the given name.
|
java.util.Collection<Rule> |
getRules()
Retrieves all rule nodes.
|
java.lang.String |
getScope()
Retrieve the scope attribute.
|
java.lang.String |
getSrc()
Retrieve the src attribute.
|
java.lang.String |
getSrcexpr()
Retrieve the srcexpr attribute.
|
java.net.URI |
getSrcUri()
Retrieve the src attribute as a URI.
|
java.net.URL |
getSrcUrl()
Retrieve the src attribute as a URL.
|
java.lang.String |
getTagFormat()
Retrieve the tag-format attribute.
|
java.lang.String |
getTagName()
Get the name of the tag for the derived node.
|
GrammarType |
getType()
Retrieves the type attribute.
|
java.lang.String |
getTypename()
Retrieves the type attribute.
|
java.lang.String |
getVersion()
Retrieve the version attribute.
|
java.lang.String |
getWeight()
Retrieve the weight attribute.
|
java.lang.String |
getXmlBase()
Retrieve the xml:base attribute.
|
java.lang.String |
getXmlLang()
Retrieve the xml:lang attribute.
|
java.util.Locale |
getXmlLangObject()
Retrieve the xml:lang attribute.
|
boolean |
isExternalGrammar()
This method checks, if this grammar is an external grammar or an
inline grammar.
|
XmlNode |
newInstance(org.w3c.dom.Node n,
XmlNodeFactory<? extends XmlNode> factory)
Create a new instance for the given node.
|
void |
setFetchhint(java.lang.String fetchhint)
Set the fetchhint attribute.
|
void |
setFetchtimeout(java.lang.String fetchtimeout)
Set the fetchtimeout attribute.
|
void |
setMaxage(java.lang.String maxage)
Set the maxage attribute.
|
void |
setMaxstale(java.lang.String maxstale)
Set the maxstale attribute.
|
void |
setMode(ModeType mode)
Sets the mode attribute.
|
void |
setMode(java.lang.String mode)
Set the mode attribute.
|
void |
setRoot(Rule rule)
Sets the root attribute to the id of the given rule.
|
void |
setRoot(java.lang.String root)
Sets the root attribute.
|
void |
setScope(java.lang.String scope)
Set the scope attribute.
|
void |
setSrc(java.lang.String src)
Set the src attribute.
|
void |
setSrc(java.net.URI uri)
Set the src attribute to the given URL.
|
void |
setSrc(java.net.URL url)
Set the src attribute to the given URL.
|
void |
setSrcexpr(java.lang.String srcexpr)
Set the srcexpr attribute.
|
void |
setTagFormat(java.lang.String tagFormat)
Set the tag-format attribute.
|
void |
setType(GrammarType type)
Sets the type attribute.
|
void |
setType(java.lang.String type)
Sets the type attribute.
|
void |
setVersion(java.lang.String version)
Set the version attribute.
|
void |
setWeight(java.lang.String weight)
Set the weight attribute.
|
void |
setXmlBase(java.lang.String xmlBase)
Set the xml:base attribute.
|
void |
setXmlLang(java.util.Locale locale)
Set the xml:lang attribute.
|
void |
setXmlLang(java.lang.String xmlLang)
Set the xml:lang attribute.
|
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, hasAttribute, hasAttributes, hasChildNodes, hashCode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setNodeValue, setPrefix, setTextContent, setUserData, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddChild, getAttribute, getChildNodes, getChildren, getNode, setAttributeappendChild, 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, setUserDatapublic static final java.lang.String TAG_NAME
public static final java.lang.String DEFAULT_XMLNS
ATTRIBUTE_XMLNS,
Constant Field Valuespublic static final java.lang.String ATTRIBUTE_XMLNS
DEFAULT_XMLNSpublic static final java.lang.String ATTRIBUTE_VERSION
public static final java.lang.String DEFAULT_VERSION
public static final java.lang.String ATTRIBUTE_XML_LANG
public static final java.lang.String ATTRIBUTE_MODE
public static final java.lang.String ATTRIBUTE_ROOT
public static final java.lang.String ATTRIBUTE_TAG_FORMAT
public static final java.lang.String ATTRIBUTE_XML_BASE
<vxml> base URI declaration. If a local declaration
is omitted, the value is inherited down the document hierarchy.public static final java.lang.String ATTRIBUTE_SRC
public static final java.lang.String ATTRIBUTE_SCOPE
SCOPE_DOCUMENT,
SCOPE_DIALOG,
Constant Field Valuespublic static final java.lang.String SCOPE_DOCUMENT
ATTRIBUTE_SCOPE,
SCOPE_DIALOG,
Constant Field Valuespublic static final java.lang.String SCOPE_DIALOG
ATTRIBUTE_SCOPE,
SCOPE_DOCUMENT,
Constant Field Valuespublic static final java.lang.String ATTRIBUTE_TYPE
public static final java.lang.String ATTRIBUTE_WEIGHT
public static final java.lang.String ATTRIBUTE_FETCHHINT
public static final java.lang.String ATTRIBUTE_FETCHTIMEOUT
public static final java.lang.String ATTRIBUTE_MAXAGE
public static final java.lang.String ATTRIBUTE_MAXSTALE
public static final java.lang.String ATTRIBUTE_SRCEXPR
protected static final java.util.ArrayList<java.lang.String> ATTRIBUTE_NAMES
public Grammar()
This is necessary for the node factory.
SrgsNodeFactorypublic java.lang.String getTagName()
getTagName in interface XmlNodepublic XmlNode newInstance(org.w3c.dom.Node n, XmlNodeFactory<? extends XmlNode> factory)
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.
newInstance in interface XmlNoden - The node to encapsulate.factory - the factroy that calls this method.XmlNodeFactorypublic java.lang.String getVersion()
ATTRIBUTE_VERSIONpublic void setVersion(java.lang.String version)
version - Value of the version attribute.ATTRIBUTE_VERSIONpublic java.lang.String getModename()
ATTRIBUTE_MODEpublic ModeType getMode()
ATTRIBUTE_MODEpublic void setMode(java.lang.String mode)
mode - Value of the mode attribute.ATTRIBUTE_MODEpublic void setMode(ModeType mode)
mode - Value of the mode attribute.ATTRIBUTE_MODEpublic java.lang.String getRoot()
ATTRIBUTE_ROOTpublic void setRoot(java.lang.String root)
root - Value of the root attribute.ATTRIBUTE_ROOTpublic void setRoot(Rule rule)
rule - the root rulepublic Rule getRootRule()
null if the node could not be found.public java.util.Collection<Rule> getRules()
public java.util.Collection<Rule> getPublicRules()
public Rule getRule(java.lang.String name)
name - name of the rule to retrieve.null if there is
no rule with that name.public java.lang.String getTagFormat()
ATTRIBUTE_TAG_FORMATpublic void setTagFormat(java.lang.String tagFormat)
tagFormat - Value of the tag-format attribute.ATTRIBUTE_TAG_FORMATpublic java.lang.String getXmlLang()
ATTRIBUTE_XML_LANGpublic java.util.Locale getXmlLangObject()
ATTRIBUTE_XML_LANGpublic void setXmlLang(java.lang.String xmlLang)
xmlLang - Value of the xml:lang attribute.ATTRIBUTE_XML_LANGpublic void setXmlLang(java.util.Locale locale)
locale - Value of the xml:lang attribute.ATTRIBUTE_XML_LANGpublic java.lang.String getXmlBase()
ATTRIBUTE_XML_BASEpublic void setXmlBase(java.lang.String xmlBase)
xmlBase - Value of the xml:base attribute.ATTRIBUTE_XML_BASEpublic java.lang.String getSrc()
ATTRIBUTE_SRCpublic java.net.URL getSrcUrl()
throws java.net.MalformedURLException
java.net.MalformedURLException - src value can not be evaluated to a URL.ATTRIBUTE_SRCpublic java.net.URI getSrcUri()
throws java.net.URISyntaxException
java.net.URISyntaxException - src value can not be evaluated to a URL.ATTRIBUTE_SRCpublic void setSrc(java.lang.String src)
src - Value of the src attribute.ATTRIBUTE_SRCpublic void setSrc(java.net.URL url)
url - URL of the src attribute.ATTRIBUTE_SRCpublic void setSrc(java.net.URI uri)
uri - URI of the src attribute.ATTRIBUTE_SRCpublic java.lang.String getScope()
ATTRIBUTE_SCOPEpublic void setScope(java.lang.String scope)
scope - Value of the scope attribute.ATTRIBUTE_SCOPEpublic java.lang.String getTypename()
ATTRIBUTE_TYPEpublic GrammarType getType()
ATTRIBUTE_TYPEpublic void setType(java.lang.String type)
type - Value of the type attribute.ATTRIBUTE_TYPEpublic void setType(GrammarType type)
type - Value of the type attribute.ATTRIBUTE_TYPEpublic java.lang.String getWeight()
ATTRIBUTE_WEIGHTpublic void setWeight(java.lang.String weight)
weight - Value of the weight attribute.ATTRIBUTE_WEIGHTpublic java.lang.String getFetchhint()
ATTRIBUTE_FETCHHINTpublic void setFetchhint(java.lang.String fetchhint)
fetchhint - Value of the fetchhint attribute.ATTRIBUTE_FETCHHINTpublic java.lang.String getFetchtimeout()
ATTRIBUTE_FETCHTIMEOUTpublic long getFetchTimeoutAsMsec()
-1 if the value can not
be converted to a number.public void setFetchtimeout(java.lang.String fetchtimeout)
fetchtimeout - Value of the fetchtimeout attribute.ATTRIBUTE_FETCHTIMEOUTpublic java.lang.String getMaxage()
ATTRIBUTE_MAXAGEpublic long getMaxageAsMsec()
-1 if the value can not
be converted to a number.public void setMaxage(java.lang.String maxage)
maxage - Value of the maxage attribute.ATTRIBUTE_MAXAGEpublic java.lang.String getMaxstale()
ATTRIBUTE_MAXSTALEpublic long getMaxstaleAsMsec()
-1 if the value can not
be converted to a number.public void setMaxstale(java.lang.String maxstale)
maxstale - Value of the maxstale attribute.ATTRIBUTE_MAXSTALEpublic java.lang.String getSrcexpr()
ATTRIBUTE_SRCEXPRpublic void setSrcexpr(java.lang.String srcexpr)
srcexpr - Value of the srcexpr attribute.ATTRIBUTE_SRCEXPRpublic Text addText(java.lang.String text)
text - The text to be added.public org.w3c.dom.CDATASection addCData(java.lang.String data)
data - the CDATA to be addedprotected boolean canContainChild(java.lang.String tagName)
canContainChild in class AbstractXmlNodetagName - Name of child.public java.util.Collection<java.lang.String> getAttributeNames()
getAttributeNames in interface XmlNodegetAttributeNames in class AbstractXmlNodepublic boolean isExternalGrammar()
throws IllegalAttributeException
true, if the grammar is external, else
falseIllegalAttributeException - Exactly one of "src", "srcexpr", or an inline grammar
must be specified; otherwise, an error.badfetch event
is thrown.