org.jvoicexml.xml.vxml
Class Option

java.lang.Object
  extended by org.jvoicexml.xml.AbstractXmlNode
      extended by org.jvoicexml.xml.vxml.Option
All Implemented Interfaces:
VoiceXmlNode, XmlNode, XmlWritable, Node

public final class Option
extends AbstractXmlNode

Specify an option in a <field>.

When a simple set of alternatives is all that is needed to specify the legal input values for a field, it may be more convenient to use an option list than a grammar. An option list is represented by a set of <option> elements contained in a <field> element. Each <option> element contains PCDATA that is used to generate a speech grammar.

Version:
$Revision: 197 $

Copyright © 2005-2007 JVoiceXML group - http://jvoicexml.sourceforge.net/

Author:
Steve Doyle
See Also:
Field

Field Summary
static String ATTRIBUTE_ACCEPT
          When set to "exact" (the default), the text of the option element defines the exact phrase to be recognized.
static String ATTRIBUTE_DTMF
          An optional DTMF sequence for this option.
protected static ArrayList<String> ATTRIBUTE_NAMES
          Supported attribute names for this node.
static String ATTRIBUTE_VALUE
          The string to assign to the field's form item variable when a user selects this option, whether by speech or DTMF.
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
Option()
          Construct a new option 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?
 String getAccept()
          Retrieve the accept attribute.
 Collection<String> getAttributeNames()
          Returns a collection of permitted attribute names for the node.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 String getDtmf()
          Retrieve the dtmf attribute.
 String getTagName()
          Get the name of the tag for the derived node.
 String getValue()
          Retrieve the value attribute.
 VoiceXmlNode newInstance(Node n)
          Create a new instance for the given node.
 void setAccept(String accept)
          Set the accept attribute.
 void setDtmf(String dtmf)
          Set the dtmf attribute.
 void setValue(String value)
          Set the value attribute.
 
Methods inherited from class org.jvoicexml.xml.AbstractXmlNode
addChild, addChild, appendChild, cloneNode, compareDocumentPosition, getAttribute, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeFactory, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setNodeValue, setPrefix, setTextContent, setUserData, toString, writeChildrenXml, writeXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jvoicexml.xml.XmlNode
addChild, getAttribute, getChildNodes, getNode, setAttribute
 
Methods inherited from interface org.jvoicexml.xml.XmlWritable
writeChildrenXml, writeXml
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, 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_DTMF

public static final String ATTRIBUTE_DTMF
An optional DTMF sequence for this option. It is equivalent to a simple DTMF <grammar> and DTMF properties apply to recognition of the sequence. Unlike DTMF grammars, whitespace is optional: dtmf="123#" is equivalent to dtmf="1 2 3 #". If unspecified, no DTMF sequence is associated with this option so it cannot be matched using DTMF.

See Also:
Constant Field Values

ATTRIBUTE_ACCEPT

public static final String ATTRIBUTE_ACCEPT
When set to "exact" (the default), the text of the option element defines the exact phrase to be recognized. When set to "approximate", the text of the option element defines an approximate recognition phrase.

See Also:
Constant Field Values

ATTRIBUTE_VALUE

public static final String ATTRIBUTE_VALUE
The string to assign to the field's form item variable when a user selects this option, whether by speech or DTMF. The default assignment is the CDATA content of the <option> element with leading and trailing white space removed. If this does not exist, then the DTMF sequence is used instead. If neither CDATA content nor a dtmf sequence is specified, then the default assignment is undefined and the field's form item variable is not filled.

See Also:
Constant Field Values

ATTRIBUTE_NAMES

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

Constructor Detail

Option

public Option()
Construct a new option 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.

Returns:
name of the tag.

newInstance

public VoiceXmlNode newInstance(Node n)
Create a new instance for the given node.

Parameters:
n - The node to encapsulate.
Returns:
The new instance.
See Also:
XmlNodeFactory

getDtmf

public String getDtmf()
Retrieve the dtmf attribute.

Returns:
Value of the dtmf attribute.
See Also:
ATTRIBUTE_DTMF

setDtmf

public void setDtmf(String dtmf)
Set the dtmf attribute.

Parameters:
dtmf - Value of the dtmf attribute.
See Also:
ATTRIBUTE_DTMF

getAccept

public String getAccept()
Retrieve the accept attribute.

Returns:
Value of the accept attribute.
See Also:
ATTRIBUTE_ACCEPT

setAccept

public void setAccept(String accept)
Set the accept attribute.

Parameters:
accept - Value of the accept attribute.
See Also:
ATTRIBUTE_ACCEPT

getValue

public String getValue()
Retrieve the value attribute.

Returns:
Value of the value attribute.
See Also:
ATTRIBUTE_VALUE

setValue

public void setValue(String value)
Set the value attribute.

Parameters:
value - Value of the value attribute.
See Also:
ATTRIBUTE_VALUE

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

getChildNodes

public final NodeList getChildNodes()
A NodeList that contains all children of this node.

Specified by:
getChildNodes in interface Node
Returns:
NodeList


Copyright © 2005-2007 JVoiceXML group.