001package com.hfg.html;
002
003
004//------------------------------------------------------------------------------
005/**
006 * Represents a radio form element (<input type='radio'>) tag.
007 *
008 * @author J. Alex Taylor, hairyfatguy.com
009 */
010//------------------------------------------------------------------------------
011// com.hfg XML/HTML Coding Library
012//
013// This library is free software; you can redistribute it and/or
014// modify it under the terms of the GNU Lesser General Public
015// License as published by the Free Software Foundation; either
016// version 2.1 of the License, or (at your option) any later version.
017//
018// This library is distributed in the hope that it will be useful,
019// but WITHOUT ANY WARRANTY; without even the implied warranty of
020// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
021// Lesser General Public License for more details.
022//
023// You should have received a copy of the GNU Lesser General Public
024// License along with this library; if not, write to the Free Software
025// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026//
027// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
028// jataylor@hairyfatguy.com
029//------------------------------------------------------------------------------
030
031public class InputRadio extends HTMLTagWithFormEvents
032{
033
034    //##########################################################################
035    // PRIVATE FIELDS
036    //##########################################################################
037
038    private static String sTagName   = HTML.INPUT;
039
040    //##########################################################################
041    // CONSTRUCTORS
042    //##########################################################################
043
044    //--------------------------------------------------------------------------
045    public InputRadio()
046    {
047        super(sTagName);
048        setAttribute(HTML.TYPE, "radio");
049    }
050
051    //--------------------------------------------------------------------------
052    public InputRadio(String inName, String inValue)
053    {
054        this();
055        setName(inName);
056        setValue(inValue);
057    }
058
059    //--------------------------------------------------------------------------
060    public InputRadio(String inName, String inValue, boolean checked)
061    {
062        this(inName, inValue);
063        setChecked(checked);
064    }
065
066    //##########################################################################
067    // PUBLIC METHODS
068    //##########################################################################
069
070    //--------------------------------------------------------------------------
071    public InputRadio setName(String inValue)
072    {
073        setAttribute(HTML.NAME, inValue);
074
075        return this;
076    }
077
078    //--------------------------------------------------------------------------
079    public String getName()
080    {
081        return getAttributeValue(HTML.NAME);
082    }
083
084    //--------------------------------------------------------------------------
085    public InputRadio setValue(String inValue)
086    {
087        setAttribute(HTML.VALUE, inValue);
088
089        return this;
090    }
091
092    //--------------------------------------------------------------------------
093    public String getValue()
094    {
095        return getAttributeValue(HTML.VALUE);
096    }
097
098    //--------------------------------------------------------------------------
099    public InputRadio setChecked(boolean checked)
100    {
101        if (checked) {
102            setAttribute(HTML.CHECKED, "true");
103        }
104        else {
105            removeAttribute(HTML.CHECKED);
106        }
107
108        return this;
109    }
110
111    //--------------------------------------------------------------------------
112    public boolean isChecked()
113    {
114        return hasAttribute(HTML.CHECKED);
115    }
116
117    //--------------------------------------------------------------------------
118    public InputRadio setDisabled(boolean disabled)
119    {
120        if (disabled) {
121            setAttribute(HTML.DISABLED, HTML.DISABLED);
122        }
123        else {
124            removeAttribute(HTML.DISABLED);
125        }
126
127        return this;
128    }
129
130    //--------------------------------------------------------------------------
131    public boolean isDisabled()
132    {
133        return hasAttribute(HTML.DISABLED);
134    }
135
136    // Overrides for HTMLTag setters to allow method chaining.
137
138    //--------------------------------------------------------------------------
139    @Override
140    public InputRadio setId(String inValue)
141    {
142        return (InputRadio) super.setId(inValue);
143    }
144
145    //--------------------------------------------------------------------------
146    @Override
147    public InputRadio setStyle(CharSequence inValue)
148    {
149        return (InputRadio) super.setStyle(inValue);
150    }
151
152    //--------------------------------------------------------------------------
153    @Override
154    public InputRadio addStyle(String inValue)
155    {
156        return (InputRadio) super.addStyle(inValue);
157    }
158
159    // Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
160
161    //--------------------------------------------------------------------------
162    @Override
163    public InputRadio setOnClick(String inValue)
164    {
165        return (InputRadio) super.setOnClick(inValue);
166    }
167
168    //--------------------------------------------------------------------------
169    @Override
170    public InputRadio setOnDblClick(String inValue)
171    {
172        return (InputRadio) super.setOnDblClick(inValue);
173    }
174
175    //--------------------------------------------------------------------------
176    @Override
177    public InputRadio setOnMouseDown(String inValue)
178    {
179        return (InputRadio) super.setOnMouseDown(inValue);
180    }
181
182    //--------------------------------------------------------------------------
183    @Override
184    public InputRadio setOnMouseMove(String inValue)
185    {
186        return (InputRadio) super.setOnMouseMove(inValue);
187    }
188
189    //--------------------------------------------------------------------------
190    @Override
191    public InputRadio setOnMouseOut(String inValue)
192    {
193        return (InputRadio) super.setOnMouseOut(inValue);
194    }
195
196    //--------------------------------------------------------------------------
197    @Override
198    public InputRadio setOnMouseOver(String inValue)
199    {
200        return (InputRadio) super.setOnMouseOver(inValue);
201    }
202
203    //--------------------------------------------------------------------------
204    @Override
205    public InputRadio setOnMouseUp(String inValue)
206    {
207        return (InputRadio) super.setOnMouseUp(inValue);
208    }
209
210    //--------------------------------------------------------------------------
211    @Override
212    public InputRadio setOnKeyDown(String inValue)
213    {
214        return (InputRadio) super.setOnKeyDown(inValue);
215    }
216
217    //--------------------------------------------------------------------------
218    @Override
219    public InputRadio setOnKeyPress(String inValue)
220    {
221        return (InputRadio) super.setOnKeyPress(inValue);
222    }
223
224    //--------------------------------------------------------------------------
225    @Override
226    public InputRadio setOnKeyUp(String inValue)
227    {
228        return (InputRadio) super.setOnKeyUp(inValue);
229    }
230
231    // Overrides for HTMLTagWithFormEvents setters to allow method chaining.
232
233    //--------------------------------------------------------------------------
234    @Override
235    public InputRadio setOnBlur(String inValue)
236    {
237        return (InputRadio) super.setOnBlur(inValue);
238    }
239
240    //--------------------------------------------------------------------------
241    @Override
242    public InputRadio setOnChange(String inValue)
243    {
244        return (InputRadio) super.setOnChange(inValue);
245    }
246
247    //--------------------------------------------------------------------------
248    @Override
249    public InputRadio setOnFocus(String inValue)
250    {
251        return (InputRadio) super.setOnFocus(inValue);
252    }
253
254}