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#HTMLOptionElement} class.</p>
028  * <p>This class represents a selectable choice 
029  * in an HTML page, or a {@link JsHTMLElement} object created with the HTML 
030  * <tt>&lt;option&gt;</tt> tag.</p> 
031  *
032  * @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>
033  * @see JsHTMLOptGroupElement
034  * @see JsHTMLSelectElement
035  *
036  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
037  * generated into the target codes. Re-compilers must exit with error on the operations of
038  * accessing that kind of class objects.
039  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
040  * and <tt>instanceof</tt> to it always <tt>true</tt>.
041  */
042 public class JsHTMLOptionElement extends JsClient.HTMLOptionElement.Prototype
043 {
044     /**
045      * <p>An <b>internal</b> class containing membership data for its enclosing
046      * opaque class.</p>
047      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
048      * class members.</p>
049      *
050      * @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>
051      * 
052      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
053      */
054     protected static abstract class Members extends JsClient.HTMLOptionElement.Prototype.Members
055     {
056         /**
057          * <p>An <b>internal</b> static field defining a member ID of the field name and
058          * used internally to define a member of the same name.</p>
059          * @since 1.0
060          * @see JsHTMLOptionElement#defaultSelected
061          * @see JsHTMLOptionElement.Member#defaultSelected
062          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
063          */
064         public final static Mid defaultSelected  = id("defaultSelected");
065         /**
066          * <p>An <b>internal</b> static field defining a member ID of the field name and
067          * used internally to define a member of the same name.</p>
068          * @since 1.0
069          * @see JsHTMLOptionElement#disabled
070          * @see JsHTMLOptionElement.Member#disabled
071          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
072          */
073         public final static Mid disabled         = id("disabled"       );
074         /**
075          * <p>An <b>internal</b> static field defining a member ID of the field name and
076          * used internally to define a member of the same name.</p>
077          * @since 1.0
078          * @see JsHTMLOptionElement#form
079          * @see JsHTMLOptionElement.Member#form
080          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
081          */
082         public final static Mid form             = id("form"           );
083         /**
084          * <p>An <b>internal</b> static field defining a member ID of the field name and
085          * used internally to define a member of the same name.</p>
086          * @since 1.0
087          * @see JsHTMLOptionElement#index
088          * @see JsHTMLOptionElement.Member#index
089          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
090          */
091         public final static Mid index            = id("index"          );
092         /**
093          * <p>An <b>internal</b> static field defining a member ID of the field name and
094          * used internally to define a member of the same name.</p>
095          * @since 1.0
096          * @see JsHTMLOptionElement#label
097          * @see JsHTMLOptionElement.Member#label
098          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
099          */
100         public final static Mid label            = id("label"          );
101         /**
102          * <p>An <b>internal</b> static field defining a member ID of the field name and
103          * used internally to define a member of the same name.</p>
104          * @since 1.0
105          * @see JsHTMLOptionElement#selected
106          * @see JsHTMLOptionElement.Member#selected
107          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
108          */
109         public final static Mid selected         = id("selected"       );
110         /**
111          * <p>An <b>internal</b> static field defining a member ID of the field name and
112          * used internally to define a member of the same name.</p>
113          * @since 1.0
114          * @see JsHTMLOptionElement#text
115          * @see JsHTMLOptionElement.Member#text
116          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
117          */
118         public final static Mid text             = id("text"           );
119         /**
120          * <p>An <b>internal</b> static field defining a member ID of the field name and
121          * used internally to define a member of the same name.</p>
122          * @since 1.0
123          * @see JsHTMLOptionElement#value
124          * @see JsHTMLOptionElement.Member#value
125          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
126          */
127         public final static Mid value            = id("value"          );
128     }
129 
130     /**
131      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
132      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
133      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
134      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
135      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
136      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
137      * either circumstance, the field names must be exactly same as the member names, as 
138      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
139      * based on the field names.</p>
140      *
141      * @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>
142      * 
143      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
144      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
145      * of class objects.
146      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
147      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
148      * <pre>q.m</pre>
149      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
150      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
151      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
152      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
153      * <pre>m</pre>
154      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
155      * error on the access to <b>opaque</b> fields declared by this class under any other 
156      * circumstances.
157      */
158     public static class Member extends JsClient.HTMLOptionElement.Prototype.Member
159     {
160         /**
161          * <p>Internally constructs a member based on a qualifying member.</p>
162          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
163          * or <b>internal</b> classes or class members.</p>
164          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
165          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
166          * declared in the declaring class of this constructor itself or its subclasses. 
167          * Under this circumstance, the field names must be exactly same as the member 
168          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
169          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
170          * to their names appending to the name resolved from the specified qualifying 
171          * member with a dot in between.</p>
172          * @param q A qualifying member
173          * @param mid The ID of the member to construct
174          * @since 1.0
175          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
176          */
177         public Member(JsObject.Member q, Mid mid) {
178             super(q, mid);
179         }
180         /**
181          * <p>Internally constructs a member without a qualifying member.</p>
182          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
183          * or <b>internal</b> classes or class members.</p>
184          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
185          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
186          * declared in <b>opaque</b> types other than the declaring class of this constructor 
187          * itself and its subclasses. Under this circumstance, the field names must be
188          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
189          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
190          * @param mid The ID of the member to construct
191          * @since 1.0
192          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
193          */
194         public Member(Mid mid) {
195             super(mid);
196         }
197         @Override
198         /**
199          * <p>Evaluates the property, represented by the current member instance, of the
200          * argument object.</p>
201          * @param o The argument object
202          * @return The value of the current member based on the object argument.
203          * @since 1.0
204          * @javascript Re-compilers must convert the instance invocation of this method into
205          * the JavaScript expression: 
206          * <pre>o.m</pre>
207          * where <tt>m</tt> is the identifier name resolved from the current member
208          * instance of the invocation.
209          */
210         public JsHTMLOptionElement with(ObjectLike o) {
211             return new JsHTMLOptionElement(super.with(o));
212         }
213 
214         /**
215          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
216          * name of this field, qualified by the current member instance of the field, and 
217          * to access the property of the name on an object.</p>
218          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
219          * object refers to a boolean value that represents the value of the HTML 
220          * <tt>selected</tt> attribute. The value of this attribute does not change if 
221          * the state of the corresponding form control, in an interactive browser, 
222          * changes.</p> 
223          * @since 1.0
224          * @javascript Re-compilers must resolve the member of this instance field to the
225          * identifier of the field name appending to the identifier resolved from its 
226          * qualifying member with a dot in between.
227          */
228         public final Value.Boolean.Member defaultSelected  = new Value.Boolean.Member(this, Members.defaultSelected);
229         /**
230          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
231          * name of this field, qualified by the current member instance of the field, and 
232          * to access the property of the name on an object.</p>
233          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
234          * object refers to a boolean value that specifies whether the control is 
235          * unavailable in this context.</p> 
236          * @since 1.0
237          * @javascript Re-compilers must resolve the member of this instance field to the
238          * identifier of the field name appending to the identifier resolved from its 
239          * qualifying member with a dot in between.
240          */
241         public final Value.Boolean.Member disabled         = new Value.Boolean.Member(this, Members.disabled       );
242         /**
243          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
244          * name of this field, qualified by the current member instance of the field, and 
245          * to access the property of the name on an object.</p>
246          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
247          * object refers to a boolean value that represents the current state of the 
248          * corresponding form control, in an interactive browser. Changing this attribute 
249          * changes the state of the form control, but does not change the value of the 
250          * HTML <tt>selected</tt> attribute of the element.</p> 
251          * @since 1.0
252          * @javascript Re-compilers must resolve the member of this instance field to the
253          * identifier of the field name appending to the identifier resolved from its 
254          * qualifying member with a dot in between.
255          */
256         public final Value.Boolean.Member selected         = new Value.Boolean.Member(this, Members.selected       );
257         /**
258          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
259          * name of this field, qualified by the current member instance of the field, and 
260          * to access the property of the name on an object.</p>
261          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
262          * object is a read-only reference to the {@link JsHTMLFormElement} object 
263          * containing the control. It is <tt>null</tt> if the control is not within the 
264          * context of a form.</p>
265          * @since 1.0
266          * @javascript Re-compilers must resolve the member of this instance field to the
267          * identifier of the field name appending to the identifier resolved from its 
268          * qualifying member with a dot in between.
269          */
270         public final JsHTMLFormElement.Member form = new JsHTMLFormElement.Member(this, Members.form);
271         /**
272          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
273          * name of this field, qualified by the current member instance of the field, and 
274          * to access the property of the name on an object.</p>
275          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
276          * object refers to an integer value specifying the index of this option element 
277          * in its parent {@link JsHTMLSelectElement} element, starting from 0.</p> 
278          * @since 1.0
279          * @javascript Re-compilers must resolve the member of this instance field to the
280          * identifier of the field name appending to the identifier resolved from its 
281          * qualifying member with a dot in between.
282          */
283         public final Value.Number.Member index = new Value.Number.Member(this, Members.index);
284         /**
285          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
286          * name of this field, qualified by the current member instance of the field, and 
287          * to access the property of the name on an object.</p>
288          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
289          * object refers to a string value specifying the option label for use in 
290          * hierarchical menus.</p> 
291          * @since 1.0
292          * @javascript Re-compilers must resolve the member of this instance field to the
293          * identifier of the field name appending to the identifier resolved from its 
294          * qualifying member with a dot in between.
295          */
296         public final Value.String.Member label = new Value.String.Member(this, Members.label);
297         /**
298          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
299          * name of this field, qualified by the current member instance of the field, and 
300          * to access the property of the name on an object.</p>
301          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
302          * object refers to a string value specifying the text contained within the 
303          * option element.</p> 
304          * @since 1.0
305          * @javascript Re-compilers must resolve the member of this instance field to the
306          * identifier of the field name appending to the identifier resolved from its 
307          * qualifying member with a dot in between.
308          */
309         public final Value.String.Member text  = new Value.String.Member(this, Members.text );
310         /**
311          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
312          * name of this field, qualified by the current member instance of the field, and 
313          * to access the property of the name on an object.</p>
314          * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
315          * object refers to a string value specifying the current form control value.</p> 
316          * @since 1.0
317          * @javascript Re-compilers must resolve the member of this instance field to the
318          * identifier of the field name appending to the identifier resolved from its 
319          * qualifying member with a dot in between.
320          */
321         public final Value.String.Member value = new Value.String.Member(this, Members.value);
322     }
323 
324     /**
325      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
326      * with the wrapping constructor.</p>
327      * @param var The argument of an <b>opaque</b> object.
328      * @since 1.0
329      * @javascript Re-compilers must ignore the construction operation of this constructor,
330      * that is, replacing it with its only argument.
331      */
332     public JsHTMLOptionElement(JsObject var) {
333         super(var);
334     }
335 
336     /**
337      * <p>An <b>opaque</b> static field defining a member that is named by the field name
338      * without a qualifying member and to access the property of the name on an object.</p>
339      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
340      * object refers to a boolean value that represents the value of the HTML 
341      * <tt>selected</tt> attribute. The value of this attribute does not change if 
342      * the state of the corresponding form control, in an interactive browser, 
343      * changes.</p> 
344      * @since 1.0
345      * @javascript Re-compilers must resolve the member of this static field to the
346      * identifier of the field name.
347      */
348     public static final Value.Boolean.Member defaultSelected  = new Value.Boolean.Member(Members.defaultSelected);
349     /**
350      * <p>An <b>opaque</b> static field defining a member that is named by the field name
351      * without a qualifying member and to access the property of the name on an object.</p>
352      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
353      * object refers to a boolean value that specifies whether the control is 
354      * unavailable in this context.</p> 
355      * @since 1.0
356      * @javascript Re-compilers must resolve the member of this static field to the
357      * identifier of the field name.
358      */
359     public static final Value.Boolean.Member disabled         = new Value.Boolean.Member(Members.disabled       );
360     /**
361      * <p>An <b>opaque</b> static field defining a member that is named by the field name
362      * without a qualifying member and to access the property of the name on an object.</p>
363      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
364      * object refers to a boolean value that represents the current state of the 
365      * corresponding form control, in an interactive browser. Changing this attribute 
366      * changes the state of the form control, but does not change the value of the 
367      * HTML <tt>selected</tt> attribute of the element.</p> 
368      * @since 1.0
369      * @javascript Re-compilers must resolve the member of this static field to the
370      * identifier of the field name.
371      */
372     public static final Value.Boolean.Member selected         = new Value.Boolean.Member(Members.selected       );
373     /**
374      * <p>An <b>opaque</b> static field defining a member that is named by the field name
375      * without a qualifying member and to access the property of the name on an object.</p>
376      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
377      * object is a read-only reference to the {@link JsHTMLFormElement} object 
378      * containing the control. It is <tt>null</tt> if the control is not within the 
379      * context of a form.</p>
380      * @since 1.0
381      * @javascript Re-compilers must resolve the member of this static field to the
382      * identifier of the field name.
383      */
384     public static final JsHTMLFormElement.Member form = new JsHTMLFormElement.Member(Members.form);
385     /**
386      * <p>An <b>opaque</b> static field defining a member that is named by the field name
387      * without a qualifying member and to access the property of the name on an object.</p>
388      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
389      * object refers to an integer value specifying the index of this option element 
390      * in its parent {@link JsHTMLSelectElement} element, starting from 0.</p> 
391      * @since 1.0
392      * @javascript Re-compilers must resolve the member of this static field to the
393      * identifier of the field name.
394      */
395     public static final Value.Number.Member index = new Value.Number.Member(Members.index);
396     /**
397      * <p>An <b>opaque</b> static field defining a member that is named by the field name
398      * without a qualifying member and to access the property of the name on an object.</p>
399      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
400      * object refers to a string value specifying the option label for use in 
401      * hierarchical menus.</p> 
402      * @since 1.0
403      * @javascript Re-compilers must resolve the member of this static field to the
404      * identifier of the field name.
405      */
406     public static final Value.String.Member label = new Value.String.Member(Members.label);
407     /**
408      * <p>An <b>opaque</b> static field defining a member that is named by the field name
409      * without a qualifying member and to access the property of the name on an object.</p>
410      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
411      * object refers to a string value specifying the text contained within the 
412      * option element.</p> 
413      * @since 1.0
414      * @javascript Re-compilers must resolve the member of this static field to the
415      * identifier of the field name.
416      */
417     public static final Value.String.Member text  = new Value.String.Member(Members.text );
418     /**
419      * <p>An <b>opaque</b> static field defining a member that is named by the field name
420      * without a qualifying member and to access the property of the name on an object.</p>
421      * <p>The property, identified by this member, of a {@link JsHTMLOptionElement} 
422      * object refers to a string value specifying the current form control value.</p> 
423      * @since 1.0
424      * @javascript Re-compilers must resolve the member of this static field to the
425      * identifier of the field name.
426      */
427     public static final Value.String.Member value = new Value.String.Member(Members.value);
428 
429     @Override
430     /**
431      * <p>Returns the primitive value associated with the current instance, if there is one.
432      * This invocation simply returns the instance itself for the current instance is an 
433      * object and there is no primitive value for it.</p>
434      * @return The current object itself.
435      * @since 1.0
436      * @javascript Re-compilers must convert the instance invocation of this method directly
437      * into a JavaScript invocation on its current object instance without changing the 
438      * method name, but expanding variable arguments, if any, into comma-separated values. 
439      */
440     public JsHTMLOptionElement valueOf() {
441         return new JsHTMLOptionElement((JsObject)var().valueOf());
442     }
443 }