001 /*
002 * File: $HeadURL: https://svn.sourceforge.net/svnroot/jvoicexml/trunk/src/org/jvoicexml/Application.java$
003 * Version: $LastChangedRevision: 2325 $
004 * Date: $LastChangedDate $
005 * Author: $LastChangedBy: schnelle $
006 *
007 * JVoiceXML - A free VoiceXML implementation.
008 *
009 * Copyright (C) 2005-2008 JVoiceXML group - http://jvoicexml.sourceforge.net
010 *
011 * This library is free software; you can redistribute it and/or
012 * modify it under the terms of the GNU Library General Public
013 * License as published by the Free Software Foundation; either
014 * version 2 of the License, or (at your option) any later version.
015 *
016 * This library is distributed in the hope that it will be useful,
017 * but WITHOUT ANY WARRANTY; without even the implied warranty of
018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 * Library General Public License for more details.
020 *
021 * You should have received a copy of the GNU Library General Public
022 * License along with this library; if not, write to the Free Software
023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024 *
025 */
026
027 package org.jvoicexml.xml.srgs;
028
029 import java.util.ArrayList;
030 import java.util.Collection;
031
032 import org.jvoicexml.xml.VoiceXmlNode;
033 import org.jvoicexml.xml.XmlNode;
034 import org.jvoicexml.xml.XmlNodeFactory;
035 import org.w3c.dom.Node;
036
037 /**
038 * An SRGS document may reference one or more external pronunciation lexicon
039 * documents. A lexicon document is identified by a URI with an optional
040 * media type. No standard lexicon media type has yet been defined as the
041 * default for this specification.
042 *
043 * @author Steve Doyle
044 * @version $Revision: 2325 $
045 *
046 * <p>
047 * Copyright © 2005-2008 JVoiceXML group -
048 * <a href="http://jvoicexml.sourceforge.net">http://jvoicexml.sourceforge.net/
049 * </a>
050 * </p>
051 */
052 public final class Lexicon
053 extends AbstractSrgsNode implements VoiceXmlNode {
054
055 /** Name of the tag. */
056 public static final String TAG_NAME = "lexicon";
057
058 /**
059 * Identifies the location of the pronunciation lexicon document.
060 */
061 public static final String ATTRIBUTE_URI = "uri";
062
063 /**
064 * Specifies the media type of the pronunciation lexicon document.
065 */
066 public static final String ATTRIBUTE_TYPE = "type";
067
068 /**
069 * Supported attribute names for this node.
070 */
071 protected static final ArrayList<String> ATTRIBUTE_NAMES;
072
073 /**
074 * Set the valid attributes for this node.
075 */
076 static {
077 ATTRIBUTE_NAMES = new java.util.ArrayList<String>();
078
079 ATTRIBUTE_NAMES.add(ATTRIBUTE_TYPE);
080 ATTRIBUTE_NAMES.add(ATTRIBUTE_URI);
081 }
082
083 /**
084 * Construct a new lexicon object without a node.
085 * <p>
086 * This is necessary for the node factory.
087 * </p>
088 *
089 * @see org.jvoicexml.xml.vxml.VoiceXmlNodeFactory
090 */
091 public Lexicon() {
092 super(null);
093 }
094
095 /**
096 * Construct a new lexicon object.
097 * @param node The encapsulated node.
098 */
099 Lexicon(final Node node) {
100 super(node);
101 }
102
103 /**
104 * Constructs a new node.
105 *
106 * @param n
107 * The encapsulated node.
108 * @param factory
109 * The node factory to use.
110 */
111 private Lexicon(final Node n,
112 final XmlNodeFactory<? extends XmlNode> factory) {
113 super(n, factory);
114 }
115
116 /**
117 * Get the name of the tag for the derived node.
118 *
119 * @return name of the tag.
120 */
121 public String getTagName() {
122 return TAG_NAME;
123 }
124
125 /**
126 * {@inheritDoc}
127 */
128 public XmlNode newInstance(final Node n,
129 final XmlNodeFactory<? extends XmlNode> factory) {
130 return new Lexicon(n, factory);
131 }
132
133 /**
134 * Retrieve the uri attribute.
135 * @return Value of the uri attribute.
136 * @see #ATTRIBUTE_URI
137 */
138 public String getUri() {
139 return getAttribute(ATTRIBUTE_URI);
140 }
141
142 /**
143 * Set the uri attribute.
144 * @param uri Value of the uri attribute.
145 * @see #ATTRIBUTE_URI
146 */
147 public void setUri(final String uri) {
148 setAttribute(ATTRIBUTE_URI, uri);
149 }
150
151 /**
152 * Retrieve the type attribute.
153 * @return Value of the type attribute.
154 * @see #ATTRIBUTE_TYPE
155 */
156 public String getType() {
157 return getAttribute(ATTRIBUTE_TYPE);
158 }
159
160 /**
161 * Set the type attribute.
162 * @param type Value of the type attribute.
163 * @see #ATTRIBUTE_TYPE
164 */
165 public void setType(final String type) {
166 setAttribute(ATTRIBUTE_TYPE, type);
167 }
168
169 /**
170 * {@inheritDoc}
171 */
172 protected boolean canContainChild(final String tagName) {
173 return false;
174 }
175
176 /**
177 * {@inheritDoc}
178 */
179 public Collection<String> getAttributeNames() {
180 return ATTRIBUTE_NAMES;
181 }
182 }