001: /*
002: * Copyright (c) 2002-2008 Gargoyle Software Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: * 2. Redistributions in binary form must reproduce the above copyright notice,
010: * this list of conditions and the following disclaimer in the documentation
011: * and/or other materials provided with the distribution.
012: * 3. The end-user documentation included with the redistribution, if any, must
013: * include the following acknowledgment:
014: *
015: * "This product includes software developed by Gargoyle Software Inc.
016: * (http://www.GargoyleSoftware.com/)."
017: *
018: * Alternately, this acknowledgment may appear in the software itself, if
019: * and wherever such third-party acknowledgments normally appear.
020: * 4. The name "Gargoyle Software" must not be used to endorse or promote
021: * products derived from this software without prior written permission.
022: * For written permission, please contact info@GargoyleSoftware.com.
023: * 5. Products derived from this software may not be called "HtmlUnit", nor may
024: * "HtmlUnit" appear in their name, without prior written permission of
025: * Gargoyle Software Inc.
026: *
027: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
028: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
029: * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
030: * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
031: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
032: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
033: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
036: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037: */
038: package com.gargoylesoftware.htmlunit.html;
039:
040: import com.gargoylesoftware.htmlunit.Assert;
041: import com.gargoylesoftware.htmlunit.KeyValuePair;
042:
043: import java.util.Map;
044:
045: /**
046: * Wrapper for the html element "isindex". Note that this element has been
047: * deprecated in the HTML spec.
048: *
049: * @version $Revision: 2132 $
050: * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
051: * @author David K. Taylor
052: * @author <a href="mailto:cse@dynabean.de">Christian Sell</a>
053: * @author Daniel Gredler
054: * @author Ahmed Ashour
055: */
056: public class HtmlIsIndex extends StyledElement implements
057: SubmittableElement {
058:
059: private static final long serialVersionUID = -7566440323983487259L;
060:
061: /** the HTML tag represented by this element */
062: public static final String TAG_NAME = "isindex";
063:
064: private String value_ = "";
065:
066: /**
067: * Create an instance of HtmlIsIndex
068: *
069: * @param page The HtmlPage that contains this element.
070: * @param attributes the initial attributes
071: * @deprecated You should not directly construct HtmlIsIndex.
072: */
073: //TODO: to be removed, deprecated after 1.11
074: public HtmlIsIndex(final HtmlPage page, final Map attributes) {
075: this (null, TAG_NAME, page, attributes);
076: }
077:
078: /**
079: * Create an instance of HtmlIsIndex
080: *
081: * @param namespaceURI the URI that identifies an XML namespace.
082: * @param qualifiedName The qualified name of the element type to instantiate
083: * @param page The HtmlPage that contains this element.
084: * @param attributes the initial attributes
085: */
086: HtmlIsIndex(final String namespaceURI, final String qualifiedName,
087: final HtmlPage page, final Map attributes) {
088: super (namespaceURI, qualifiedName, page, attributes);
089: }
090:
091: /**
092: * Set the value that will be returned during submission of a form.
093: *
094: * @param newValue The value.
095: */
096: public void setValue(final String newValue) {
097: Assert.notNull("newValue", newValue);
098: value_ = newValue;
099: }
100:
101: /**
102: * Return the value that would be send during submission of a form.
103: *
104: * @return The value
105: */
106: public String getValue() {
107: return value_;
108: }
109:
110: /**
111: * Return an array of KeyValuePairs that are the values that will be sent
112: * back to the server whenever the current form is submitted.<p>
113: *
114: * THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT
115: * BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK.
116: *
117: * @return See above
118: */
119: public KeyValuePair[] getSubmitKeyValuePairs() {
120: return new KeyValuePair[] { new KeyValuePair(
121: getPromptAttribute(), getValue()) };
122: }
123:
124: /**
125: * {@inheritDoc}
126: * @see SubmittableElement#reset()
127: */
128: public void reset() {
129: value_ = "";
130: }
131:
132: /**
133: * {@inheritDoc}
134: * @see SubmittableElement#setDefaultValue(String)
135: */
136: public void setDefaultValue(final String defaultValue) {
137: // The reset() method does nothing, so this method doesn't have to, either.
138: }
139:
140: /**
141: * {@inheritDoc}
142: * @see SubmittableElement#setDefaultValue(String)
143: */
144: public String getDefaultValue() {
145: // The reset() method does nothing, so this method doesn't have to, either.
146: return "";
147: }
148:
149: /**
150: * {@inheritDoc} This implementation is empty; only checkboxes and radio buttons
151: * really care what the default checked value is.
152: * @see SubmittableElement#setDefaultChecked(boolean)
153: * @see HtmlRadioButtonInput#setDefaultChecked(boolean)
154: * @see HtmlCheckBoxInput#setDefaultChecked(boolean)
155: */
156: public void setDefaultChecked(final boolean defaultChecked) {
157: // Empty.
158: }
159:
160: /**
161: * {@inheritDoc} This implementation returns <tt>false</tt>; only checkboxes and
162: * radio buttons really care what the default checked value is.
163: * @see SubmittableElement#isDefaultChecked()
164: * @see HtmlRadioButtonInput#isDefaultChecked()
165: * @see HtmlCheckBoxInput#isDefaultChecked()
166: */
167: public boolean isDefaultChecked() {
168: return false;
169: }
170:
171: /**
172: * Return the value of the attribute "lang". Refer to the
173: * <a href='http://www.w3.org/TR/html401/'>HTML 4.01</a>
174: * documentation for details on the use of this attribute.
175: *
176: * @return The value of the attribute "lang"
177: * or an empty string if that attribute isn't defined.
178: */
179: public final String getLangAttribute() {
180: return getAttributeValue("lang");
181: }
182:
183: /**
184: * Return the value of the attribute "xml:lang". Refer to the
185: * <a href='http://www.w3.org/TR/html401/'>HTML 4.01</a>
186: * documentation for details on the use of this attribute.
187: *
188: * @return The value of the attribute "xml:lang"
189: * or an empty string if that attribute isn't defined.
190: */
191: public final String getXmlLangAttribute() {
192: return getAttributeValue("xml:lang");
193: }
194:
195: /**
196: * Return the value of the attribute "dir". Refer to the
197: * <a href='http://www.w3.org/TR/html401/'>HTML 4.01</a>
198: * documentation for details on the use of this attribute.
199: *
200: * @return The value of the attribute "dir"
201: * or an empty string if that attribute isn't defined.
202: */
203: public final String getTextDirectionAttribute() {
204: return getAttributeValue("dir");
205: }
206:
207: /**
208: * Return the value of the attribute "prompt". Refer to the
209: * <a href='http://www.w3.org/TR/html401/'>HTML 4.01</a>
210: * documentation for details on the use of this attribute.
211: *
212: * @return The value of the attribute "prompt"
213: * or an empty string if that attribute isn't defined.
214: */
215: public final String getPromptAttribute() {
216: return getAttributeValue("prompt");
217: }
218: }
|