001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package js.user;
021 
022 import js.*;
023 import js.core.*;
024 
025 /**
026  * <p>An <b>opaque</b> class representing JavaScript client-side objects of the global 
027  * {@link JsClient#HTMLRadioElement} class.</p>
028  * <p>This class represents a push button 
029  * in an HTML page, or a {@link JsHTMLInputElement} object created with the HTML 
030  * <tt>&lt;input&gt;</tt> tag with its <tt>type</tt> 
031  * attribute of the value "radio".</p>
032  * <p>An input element of this class displays a single graphical radio button. A radio 
033  * button is a button in a group of buttons that represents a set of mutually exclusive 
034  * choices. When one button is selected, the previously selected button is deselected, 
035  * as in the mechanical station preset buttons of old car radios. In order for a group 
036  * of radio buttons to exhibit this mutually exclusive behavior, they must appear in the 
037  * same {@link JsHTMLInputElement#form} and must have the same {@link JsHTMLInputElement#name}. 
038  * For toggle buttons without mutual exclusion, use a type of "checkbox" or {@link JsHTMLCheckBoxElement}. 
039  * Note that the HTML <tt>&lt;select&gt;</tt> tag creating {@link JsHTMLSelectElement} 
040  * can also be used for presenting exclusive or non-exclusive choices.</p>
041  * <p>The {@link JsHTMLInputElement#checked} property indicates whether a radio button 
042  * is selected. There is no way to determine which button in a mutually exclusive group 
043  * of radio buttons is selected. You must examine the {@link JsHTMLInputElement#checked} 
044  * property of each one. Radio buttons trigger the {@link JsHTMLInputElement#onclick} 
045  * event handler when selected or deselected.</p>
046  * <p>The {@link JsHTMLInputElement#value} property specifies a value to be submitted 
047  * to a web server and is not displayed within the form. To specify a label for a radio 
048  * button, do so externally to the <tt>&lt;input&gt;</tt> tag, such as with a <tt>&lt;label&gt;</tt> 
049  * tag.</p>
050  *  
051  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
052  *
053  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
054  * generated into the target codes. Re-compilers must exit with error on the operations of
055  * accessing that kind of class objects.
056  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
057  * and <tt>instanceof</tt> to it always <tt>true</tt>.
058  */
059 public class JsHTMLRadioElement extends JsClient.HTMLRadioElement.Prototype
060 {
061     /**
062      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
063      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
064      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
065      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
066      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
067      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
068      * either circumstance, the field names must be exactly same as the member names, as 
069      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
070      * based on the field names.</p>
071      *
072      * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
073      * 
074      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
075      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
076      * of class objects.
077      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
078      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
079      * <pre>q.m</pre>
080      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
081      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
082      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
083      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
084      * <pre>m</pre>
085      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
086      * error on the access to <b>opaque</b> fields declared by this class under any other 
087      * circumstances.
088      */
089     public static class Member extends JsClient.HTMLRadioElement.Prototype.Member
090     {
091         /**
092          * <p>Internally constructs a member based on a qualifying member.</p>
093          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
094          * or <b>internal</b> classes or class members.</p>
095          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
096          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
097          * declared in the declaring class of this constructor itself or its subclasses. 
098          * Under this circumstance, the field names must be exactly same as the member 
099          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
100          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
101          * to their names appending to the name resolved from the specified qualifying 
102          * member with a dot in between.</p>
103          * @param q A qualifying member
104          * @param mid The ID of the member to construct
105          * @since 1.0
106          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
107          */
108         public Member(JsObject.Member q, Mid mid) {
109             super(q, mid);
110         }
111         /**
112          * <p>Internally constructs a member without a qualifying member.</p>
113          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
114          * or <b>internal</b> classes or class members.</p>
115          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
116          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
117          * declared in <b>opaque</b> types other than the declaring class of this constructor 
118          * itself and its subclasses. Under this circumstance, the field names must be
119          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
120          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
121          * @param mid The ID of the member to construct
122          * @since 1.0
123          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
124          */
125         public Member(Mid mid) {
126             super(mid);
127         }
128         @Override
129         /**
130          * <p>Evaluates the property, represented by the current member instance, of the
131          * argument object.</p>
132          * @param o The argument object
133          * @return The value of the current member based on the object argument.
134          * @since 1.0
135          * @javascript Re-compilers must convert the instance invocation of this method into
136          * the JavaScript expression: 
137          * <pre>o.m</pre>
138          * where <tt>m</tt> is the identifier name resolved from the current member
139          * instance of the invocation.
140          */
141         public JsHTMLRadioElement with(ObjectLike o) {
142             return new JsHTMLRadioElement(super.with(o));
143         }
144     }
145 
146     /**
147      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
148      * with the wrapping constructor.</p>
149      * @param var The argument of an <b>opaque</b> object.
150      * @since 1.0
151      * @javascript Re-compilers must ignore the construction operation of this constructor,
152      * that is, replacing it with its only argument.
153      */
154     public JsHTMLRadioElement(JsObject var) {
155         super(var);
156     }
157 
158     @Override
159     /**
160      * <p>Returns the primitive value associated with the current instance, if there is one.
161      * This invocation simply returns the instance itself for the current instance is an 
162      * object and there is no primitive value for it.</p>
163      * @return The current object itself.
164      * @since 1.0
165      * @javascript Re-compilers must convert the instance invocation of this method directly
166      * into a JavaScript invocation on its current object instance without changing the 
167      * method name, but expanding variable arguments, if any, into comma-separated values. 
168      */
169     public JsHTMLRadioElement valueOf() {
170         return new JsHTMLRadioElement((JsObject)var().valueOf());
171     }
172 }