org.jvoicexml.xml.srgs
Class Item

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

public final class Item
extends AbstractXmlNode
implements VoiceXmlNode

Define an expansion with optional repeating and probability. An item element can surround any expansion to permit a repeat attribute or language identifier to be attached.

Version:
$Revision: 2325 $
Author:
Steve Doyle, Dirk Schnelle-Walka

Field Summary
protected static ArrayList<String> ATTRIBUTE_NAMES
          Supported attribute names for this node.
static String ATTRIBUTE_REPEAT
          Defines a legal rule expansion as being another sub-expansion that is optional, that is repeated zero or more times, that is repeated one or more times, or that is repeated some range of times.
static String ATTRIBUTE_REPEAT_PROB
          Any repeat operator may specify an optional repeat probability.
static String ATTRIBUTE_WEIGHT
          A weight may be optionally provided for any number of alternatives in an alternative expansion.
static String ATTRIBUTE_XML_LANG
          The language identifier for the grammar.
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
Item()
          Construct a new item 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.
 int getMaxRepeat()
          Retrieves the maximal number of repetitions.
 int getMinRepeat()
          Retrieves the minimal number of repetitions.
 String getRepeat()
          Retrieve the repeat attribute.
 String getRepeatProb()
          Retrieve the repeatProb attribute.
 String getTagName()
          Get the name of the tag for the derived node.
 String getWeight()
          Retrieve the weight attribute.
 String getXmlLang()
          Retrieve the xmlLang attribute.
 Locale getXmlLangObject()
          Retrieve the xml:lang attribute.
 boolean isOptional()
          Checks if this item is optional.This means the value of the repeat attribute equals 0-1.
 XmlNode newInstance(Node n, XmlNodeFactory<? extends XmlNode> factory)
          Create a new instance for the given node.
 void setOptional()
          Sets the repeat attribute to optional, this means to a value 0-1.
 void setRepeat(int repeat)
          Set the repeat attribute.
 void setRepeat(int min, int max)
          Set the repeat attribute.
 void setRepeat(String repeat)
          Set the repeat attribute.
 void setRepeatProb(String repeatProb)
          Set the repeatProb attribute.
 void setWeight(String weight)
          Set the weight attribute.
 void setXmlLang(Locale locale)
          Set the xml:lang attribute.
 void setXmlLang(String xmlLang)
          Set the xmlLang 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_REPEAT

public static final String ATTRIBUTE_REPEAT
Defines a legal rule expansion as being another sub-expansion that is optional, that is repeated zero or more times, that is repeated one or more times, or that is repeated some range of times.

See Also:
Constant Field Values

ATTRIBUTE_REPEAT_PROB

public static final String ATTRIBUTE_REPEAT_PROB
Any repeat operator may specify an optional repeat probability. The value indicates the probability of successive repetition of the repeated expansion.

See Also:
Constant Field Values

ATTRIBUTE_WEIGHT

public static final String ATTRIBUTE_WEIGHT
A weight may be optionally provided for any number of alternatives in an alternative expansion. Weights are simple positive floating point values without exponentials. Legal formats are "n", "n.", ".n" and "n.n" where "n" is a sequence of one or many digits. A weight is nominally a multiplying factor in the likelihood domain of a speech recognition search. A weight of 1.0 is equivalent to providing no weight at all. A weight greater than "1.0" positively biases the alternative and a weight less than "1.0" negatively biases the alternative.

See Also:
Constant Field Values

ATTRIBUTE_XML_LANG

public static final String ATTRIBUTE_XML_LANG
The language identifier for the grammar. If omitted, the value is inherited down from the document hierarchy.

See Also:
Constant Field Values

ATTRIBUTE_NAMES

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

Constructor Detail

Item

public Item()
Construct a new item 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

getRepeat

public String getRepeat()
Retrieve the repeat attribute.

Returns:
Value of the repeat attribute.
See Also:
ATTRIBUTE_REPEAT

getMinRepeat

public int getMinRepeat()
Retrieves the minimal number of repetitions.

Returns:
minimal number of repetitions.
Since:
0.7

getMaxRepeat

public int getMaxRepeat()
Retrieves the maximal number of repetitions.

Returns:
maximal number of repetitions, -1 if there is no maximum.
Since:
0.7

setRepeat

public void setRepeat(int repeat)
Set the repeat attribute.

Parameters:
repeat - number of repetitions
Since:
0.7
See Also:
ATTRIBUTE_REPEAT

setRepeat

public void setRepeat(int min,
                      int max)
Set the repeat attribute.

Throws an IllegalArgumentException for illegal values, i.e. min < 0 or min < max.

Parameters:
min - minimal number of repetitions
max - maximal number of repetitions, a value of -1 denotes an infinite maximum.
Since:
0.7
See Also:
ATTRIBUTE_REPEAT

setRepeat

public void setRepeat(String repeat)
Set the repeat attribute.

Parameters:
repeat - Value of the repeat attribute.
See Also:
ATTRIBUTE_REPEAT

setOptional

public void setOptional()
Sets the repeat attribute to optional, this means to a value 0-1.

Since:
0.6

isOptional

public boolean isOptional()
Checks if this item is optional.This means the value of the repeat attribute equals 0-1.

Returns:
true if this item is optional.
Since:
0.6

getRepeatProb

public String getRepeatProb()
Retrieve the repeatProb attribute.

Returns:
Value of the repeatProb attribute.
See Also:
ATTRIBUTE_REPEAT_PROB

setRepeatProb

public void setRepeatProb(String repeatProb)
Set the repeatProb attribute.

Parameters:
repeatProb - Value of the repeatProb attribute.
See Also:
ATTRIBUTE_REPEAT_PROB

getWeight

public String getWeight()
Retrieve the weight attribute.

Returns:
Value of the weight attribute.
See Also:
ATTRIBUTE_WEIGHT

setWeight

public void setWeight(String weight)
Set the weight attribute.

Parameters:
weight - Value of the weight attribute.
See Also:
ATTRIBUTE_WEIGHT

getXmlLang

public String getXmlLang()
Retrieve the xmlLang attribute.

Returns:
Value of the xmlLang attribute.
See Also:
ATTRIBUTE_XML_LANG

getXmlLangObject

public Locale getXmlLangObject()
Retrieve the xml:lang attribute.

Returns:
Value of the xml:lang attribute.
Since:
0.7.1
See Also:
ATTRIBUTE_XML_LANG

setXmlLang

public void setXmlLang(String xmlLang)
Set the xmlLang attribute.

Parameters:
xmlLang - Value of the xmlLang attribute.
See Also:
ATTRIBUTE_XML_LANG

setXmlLang

public void setXmlLang(Locale locale)
Set the xml:lang attribute.

Parameters:
locale - Value of the xml:lang attribute.
Since:
0.7.1
See Also:
ATTRIBUTE_XML_LANG

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.