1 /* DomHTMLInputElement.java --
2    Copyright (C) 2005 Free Software Foundation, Inc.
3 
4 This file is part of GNU Classpath.
5 
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20 
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25 
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37 
38 package gnu.xml.dom.html2;
39 
40 import org.w3c.dom.html2.HTMLFormElement;
41 import org.w3c.dom.html2.HTMLInputElement;
42 
43 /**
44  * An HTML 'INPUT' element node.
45  *
46  * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
47  */
48 public class DomHTMLInputElement
49   extends DomHTMLElement
50   implements HTMLInputElement
51 {
52 
53   protected String value;
54   protected Boolean checked;
55 
DomHTMLInputElement(DomHTMLDocument owner, String namespaceURI, String name)56   protected DomHTMLInputElement(DomHTMLDocument owner, String namespaceURI,
57                                 String name)
58   {
59     super(owner, namespaceURI, name);
60   }
61 
getDefaultValue()62   public String getDefaultValue()
63   {
64     return getHTMLAttribute("value");
65   }
66 
setDefaultValue(String defaultValue)67   public void setDefaultValue(String defaultValue)
68   {
69     setHTMLAttribute("value", defaultValue);
70   }
71 
getDefaultChecked()72   public boolean getDefaultChecked()
73   {
74     return getBooleanHTMLAttribute("checked");
75   }
76 
setDefaultChecked(boolean defaultChecked)77   public void setDefaultChecked(boolean defaultChecked)
78   {
79     setBooleanHTMLAttribute("checked", defaultChecked);
80   }
81 
getForm()82   public HTMLFormElement getForm()
83   {
84     return (HTMLFormElement) getParentElement("form");
85   }
86 
getAccept()87   public String getAccept()
88   {
89     return getHTMLAttribute("accept");
90   }
91 
setAccept(String accept)92   public void setAccept(String accept)
93   {
94     setHTMLAttribute("accept", accept);
95   }
96 
getAccessKey()97   public String getAccessKey()
98   {
99     return getHTMLAttribute("accesskey");
100   }
101 
setAccessKey(String accessKey)102   public void setAccessKey(String accessKey)
103   {
104     setHTMLAttribute("accesskey", accessKey);
105   }
106 
getAlign()107   public String getAlign()
108   {
109     return getHTMLAttribute("align");
110   }
111 
setAlign(String align)112   public void setAlign(String align)
113   {
114     setHTMLAttribute("align", align);
115   }
116 
getAlt()117   public String getAlt()
118   {
119     return getHTMLAttribute("alt");
120   }
121 
setAlt(String alt)122   public void setAlt(String alt)
123   {
124     setHTMLAttribute("alt", alt);
125   }
126 
getChecked()127   public boolean getChecked()
128   {
129     if (checked == null)
130       {
131         checked = Boolean.valueOf(getDefaultChecked());
132       }
133     return checked.booleanValue();
134   }
135 
setChecked(boolean checked)136   public void setChecked(boolean checked)
137   {
138     this.checked = Boolean.valueOf(checked);
139   }
140 
getDisabled()141   public boolean getDisabled()
142   {
143     return getBooleanHTMLAttribute("disabled");
144   }
145 
setDisabled(boolean disabled)146   public void setDisabled(boolean disabled)
147   {
148     setBooleanHTMLAttribute("disabled", disabled);
149   }
150 
getMaxLength()151   public int getMaxLength()
152   {
153     return getIntHTMLAttribute("maxLength");
154   }
155 
setMaxLength(int maxLength)156   public void setMaxLength(int maxLength)
157   {
158     setIntHTMLAttribute("maxLength", maxLength);
159   }
160 
getName()161   public String getName()
162   {
163     return getHTMLAttribute("name");
164   }
165 
setName(String name)166   public void setName(String name)
167   {
168     setHTMLAttribute("name", name);
169   }
170 
getReadOnly()171   public boolean getReadOnly()
172   {
173     return getBooleanHTMLAttribute("readonly");
174   }
175 
setReadOnly(boolean readOnly)176   public void setReadOnly(boolean readOnly)
177   {
178     setBooleanHTMLAttribute("readonly", readOnly);
179   }
180 
getSize()181   public int getSize()
182   {
183     return getIntHTMLAttribute("size");
184   }
185 
setSize(int size)186   public void setSize(int size)
187   {
188     setIntHTMLAttribute("size", size);
189   }
190 
getSrc()191   public String getSrc()
192   {
193     return getHTMLAttribute("src");
194   }
195 
setSrc(String src)196   public void setSrc(String src)
197   {
198     setHTMLAttribute("src", src);
199   }
200 
getTabIndex()201   public int getTabIndex()
202   {
203     return getIntHTMLAttribute("tabindex");
204   }
205 
setTabIndex(int tabIndex)206   public void setTabIndex(int tabIndex)
207   {
208     setIntHTMLAttribute("tabindex", tabIndex);
209   }
210 
getType()211   public String getType()
212   {
213     return getHTMLAttribute("type");
214   }
215 
setType(String type)216   public void setType(String type)
217   {
218     setHTMLAttribute("type", type);
219   }
220 
getUseMap()221   public String getUseMap()
222   {
223     return getHTMLAttribute("usemap");
224   }
225 
setUseMap(String useMap)226   public void setUseMap(String useMap)
227   {
228     setHTMLAttribute("usemap", useMap);
229   }
230 
getValue()231   public String getValue()
232   {
233     if (value == null)
234       {
235         value = getDefaultValue();
236       }
237     return value;
238   }
239 
setValue(String value)240   public void setValue(String value)
241   {
242     this.value = value;
243   }
244 
blur()245   public void blur()
246   {
247     dispatchUIEvent("blur");
248   }
249 
focus()250   public void focus()
251   {
252     dispatchUIEvent("focus");
253   }
254 
select()255   public void select()
256   {
257     dispatchUIEvent("select");
258   }
259 
click()260   public void click()
261   {
262     dispatchUIEvent("click");
263   }
264 
265 }
266