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#HTMLScriptElement} class.</p>
028  * <p>This class represents a script 
029  * in an HTML page, or a {@link JsHTMLElement} object created with the HTML 
030  * <tt>&lt;script&gt;</tt> tag which places a script within a document.</p>
031  * <p>The <tt>&lt;script&gt;</tt> elements may appear any number of times in the <tt>&lt;head&gt;</tt> or 
032  * <tt>&lt;body&gt;</tt> of an HTML document.</p> 
033  * <p>The script may be defined within the contents of the <tt>&lt;script&gt;</tt> element 
034  * or in an external file. If the {@link JsHTMLScriptElement#src} attribute is not set, 
035  * browsers must interpret the contents of the element as the script. If the {@link JsHTMLScriptElement#src} 
036  * has a URI value, browsers must ignore the element's contents and retrieve the script 
037  * via the URI. Note that the {@link JsHTMLScriptElement#charset} attribute refers to 
038  * the character encoding of the script designated by the {@link JsHTMLScriptElement#src} 
039  * attribute; it does not concern the content of the <tt>&lt;script&gt;</tt> element.</p>
040  * <p>Scripts are evaluated by script engines that must be known to a web browser.</p>
041  * <p>The syntax of script data depends on the scripting language.</p>
042  *
043  * @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>
044  *
045  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
046  * generated into the target codes. Re-compilers must exit with error on the operations of
047  * accessing that kind of class objects.
048  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
049  * and <tt>instanceof</tt> to it always <tt>true</tt>.
050  */
051 public class JsHTMLScriptElement extends JsClient.HTMLScriptElement.Prototype
052 {
053     /**
054      * <p>An <b>internal</b> class containing membership data for its enclosing
055      * opaque class.</p>
056      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
057      * class members.</p>
058      *
059      * @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>
060      * 
061      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
062      */
063     protected static abstract class Members extends JsClient.HTMLScriptElement.Prototype.Members
064     {
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 JsHTMLScriptElement#text
070          * @see JsHTMLScriptElement.Member#text
071          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
072          */
073         public final static Mid text    = id("text"   );
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 JsHTMLScriptElement#htmlFor
079          * @see JsHTMLScriptElement.Member#htmlFor
080          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
081          */
082         public final static Mid htmlFor = id("htmlFor");
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 JsHTMLScriptElement#event
088          * @see JsHTMLScriptElement.Member#event
089          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
090          */
091         public final static Mid event   = id("event"  );
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 JsHTMLScriptElement#charset
097          * @see JsHTMLScriptElement.Member#charset
098          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
099          */
100         public final static Mid charset = id("charset");
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 JsHTMLScriptElement#defer
106          * @see JsHTMLScriptElement.Member#defer
107          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
108          */
109         public final static Mid defer   = id("defer"  );
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 JsHTMLScriptElement#src
115          * @see JsHTMLScriptElement.Member#src
116          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
117          */
118         public final static Mid src     = id("src"    );
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 JsHTMLScriptElement#type
124          * @see JsHTMLScriptElement.Member#type
125          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
126          */
127         public final static Mid type    = id("type"   );
128     }
129     /**
130      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
131      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
132      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
133      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
134      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
135      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
136      * either circumstance, the field names must be exactly same as the member names, as 
137      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
138      * based on the field names.</p>
139      *
140      * @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>
141      * 
142      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
143      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
144      * of class objects.
145      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
146      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
147      * <pre>q.m</pre>
148      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
149      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
150      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
151      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
152      * <pre>m</pre>
153      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
154      * error on the access to <b>opaque</b> fields declared by this class under any other 
155      * circumstances.
156      */
157     public static class Member extends JsClient.HTMLScriptElement.Prototype.Member
158     {
159         /**
160          * <p>Internally constructs a member based on a qualifying member.</p>
161          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
162          * or <b>internal</b> classes or class members.</p>
163          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
164          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
165          * declared in the declaring class of this constructor itself or its subclasses. 
166          * Under this circumstance, the field names must be exactly same as the member 
167          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
168          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
169          * to their names appending to the name resolved from the specified qualifying 
170          * member with a dot in between.</p>
171          * @param q A qualifying member
172          * @param mid The ID of the member to construct
173          * @since 1.0
174          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
175          */
176         public Member(JsObject.Member q, Mid mid) {
177             super(q, mid);
178         }
179         /**
180          * <p>Internally constructs a member without a qualifying member.</p>
181          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
182          * or <b>internal</b> classes or class members.</p>
183          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
184          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
185          * declared in <b>opaque</b> types other than the declaring class of this constructor 
186          * itself and its subclasses. Under this circumstance, the field names must be
187          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
188          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
189          * @param mid The ID of the member to construct
190          * @since 1.0
191          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
192          */
193         public Member(Mid mid) {
194             super(mid);
195         }
196         @Override
197         /**
198          * <p>Evaluates the property, represented by the current member instance, of the
199          * argument object.</p>
200          * @param o The argument object
201          * @return The value of the current member based on the object argument.
202          * @since 1.0
203          * @javascript Re-compilers must convert the instance invocation of this method into
204          * the JavaScript expression: 
205          * <pre>o.m</pre>
206          * where <tt>m</tt> is the identifier name resolved from the current member
207          * instance of the invocation.
208          */
209         public JsHTMLScriptElement with(ObjectLike o) {
210             return new JsHTMLScriptElement(super.with(o));
211         }
212 
213         /**
214          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
215          * name of this field, qualified by the current member instance of the field, and 
216          * to access the property of the name on an object.</p>
217          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
218          * object refers to a string specifying the script content of the element.</p> 
219          * @since 1.0
220          * @javascript Re-compilers must resolve the member of this instance field to the
221          * identifier of the field name appending to the identifier resolved from its 
222          * qualifying member with a dot in between.
223          */
224         public final Value.String.Member text    = new Value.String.Member(this, Members.text   );
225         /**
226          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
227          * name of this field, qualified by the current member instance of the field, and 
228          * to access the property of the name on an object.</p>
229          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
230          * object is reserved for future use by DOM2 HTML.</p> 
231          * @since 1.0
232          * @javascript Re-compilers must resolve the member of this instance field to the
233          * identifier of the field name appending to the identifier resolved from its 
234          * qualifying member with a dot in between.
235          */
236         public final Value.String.Member htmlFor = new Value.String.Member(this, Members.htmlFor);
237         /**
238          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
239          * name of this field, qualified by the current member instance of the field, and 
240          * to access the property of the name on an object.</p>
241          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
242          * object is reserved for future use by DOM2 HTML.</p> 
243          * @since 1.0
244          * @javascript Re-compilers must resolve the member of this instance field to the
245          * identifier of the field name appending to the identifier resolved from its 
246          * qualifying member with a dot in between.
247          */
248         public final Value.String.Member event   = new Value.String.Member(this, Members.event  );
249         /**
250          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
251          * name of this field, qualified by the current member instance of the field, and 
252          * to access the property of the name on an object.</p>
253          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
254          * object refers to a string specifying the character encoding of the linked 
255          * resource.</p> 
256          * @since 1.0
257          * @javascript Re-compilers must resolve the member of this instance field to the
258          * identifier of the field name appending to the identifier resolved from its 
259          * qualifying member with a dot in between.
260          */
261         public final Value.String.Member charset = new Value.String.Member(this, Members.charset);
262         /**
263          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
264          * name of this field, qualified by the current member instance of the field, and 
265          * to access the property of the name on an object.</p>
266          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
267          * object refers to a URI string designating an external script.</p> 
268          * @since 1.0
269          * @javascript Re-compilers must resolve the member of this instance field to the
270          * identifier of the field name appending to the identifier resolved from its 
271          * qualifying member with a dot in between.
272          */
273         public final Value.String.Member src     = new Value.String.Member(this, Members.src    );
274         /**
275          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
276          * name of this field, qualified by the current member instance of the field, and 
277          * to access the property of the name on an object.</p>
278          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
279          * object refers to a string specifying the content type of the script language.</p> 
280          * @since 1.0
281          * @javascript Re-compilers must resolve the member of this instance field to the
282          * identifier of the field name appending to the identifier resolved from its 
283          * qualifying member with a dot in between.
284          */
285         public final Value.String.Member type    = new Value.String.Member(this, Members.type   );
286         /**
287          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
288          * name of this field, qualified by the current member instance of the field, and 
289          * to access the property of the name on an object.</p>
290          * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
291          * object refers to a boolean value indicating that the browser can defer processing 
292          * of the script.</p> 
293          * @since 1.0
294          * @javascript Re-compilers must resolve the member of this instance field to the
295          * identifier of the field name appending to the identifier resolved from its 
296          * qualifying member with a dot in between.
297          */
298         public final Value.Boolean.Member defer = new Value.Boolean.Member(this, Members.defer);
299     }
300 
301     /**
302      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
303      * with the wrapping constructor.</p>
304      * @param var The argument of an <b>opaque</b> object.
305      * @since 1.0
306      * @javascript Re-compilers must ignore the construction operation of this constructor,
307      * that is, replacing it with its only argument.
308      */
309     public JsHTMLScriptElement(JsObject var) {
310         super(var);
311     }
312 
313     /**
314      * <p>An <b>opaque</b> static field defining a member that is named by the field name
315      * without a qualifying member and to access the property of the name on an object.</p>
316      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
317      * object refers to a string specifying the script content of the element.</p> 
318      * @since 1.0
319      * @javascript Re-compilers must resolve the member of this static field to the
320      * identifier of the field name.
321      */
322     public static final Value.String.Member text    = new Value.String.Member(Members.text   );
323     /**
324      * <p>An <b>opaque</b> static field defining a member that is named by the field name
325      * without a qualifying member and to access the property of the name on an object.</p>
326      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
327      * object is reserved for future use by DOM2 HTML.</p> 
328      * @since 1.0
329      * @javascript Re-compilers must resolve the member of this static field to the
330      * identifier of the field name.
331      */
332     public static final Value.String.Member htmlFor = new Value.String.Member(Members.htmlFor);
333     /**
334      * <p>An <b>opaque</b> static field defining a member that is named by the field name
335      * without a qualifying member and to access the property of the name on an object.</p>
336      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
337      * object is reserved for future use by DOM2 HTML.</p> 
338      * @since 1.0
339      * @javascript Re-compilers must resolve the member of this static field to the
340      * identifier of the field name.
341      */
342     public static final Value.String.Member event   = new Value.String.Member(Members.event  );
343     /**
344      * <p>An <b>opaque</b> static field defining a member that is named by the field name
345      * without a qualifying member and to access the property of the name on an object.</p>
346      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
347      * object refers to a string specifying the character encoding of the linked 
348      * resource.</p> 
349      * @since 1.0
350      * @javascript Re-compilers must resolve the member of this static field to the
351      * identifier of the field name.
352      */
353     public static final Value.String.Member charset = new Value.String.Member(Members.charset);
354     /**
355      * <p>An <b>opaque</b> static field defining a member that is named by the field name
356      * without a qualifying member and to access the property of the name on an object.</p>
357      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
358      * object refers to a URI string designating an external script.</p> 
359      * @since 1.0
360      * @javascript Re-compilers must resolve the member of this static field to the
361      * identifier of the field name.
362      */
363     public static final Value.String.Member src     = new Value.String.Member(Members.src    );
364     /**
365      * <p>An <b>opaque</b> static field defining a member that is named by the field name
366      * without a qualifying member and to access the property of the name on an object.</p>
367      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
368      * object refers to a string specifying the content type of the script language.</p> 
369      * @since 1.0
370      * @javascript Re-compilers must resolve the member of this static field to the
371      * identifier of the field name.
372      */
373     public static final Value.String.Member type    = new Value.String.Member(Members.type   );
374     /**
375      * <p>An <b>opaque</b> static field defining a member that is named by the field name
376      * without a qualifying member and to access the property of the name on an object.</p>
377      * <p>The property, identified by this member, of a {@link JsHTMLScriptElement} 
378      * object refers to a boolean value indicating that the browser can defer processing 
379      * of the script.</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 Value.Boolean.Member defer = new Value.Boolean.Member(Members.defer);
385 
386     @Override
387     /**
388      * <p>Returns the primitive value associated with the current instance, if there is one.
389      * This invocation simply returns the instance itself for the current instance is an 
390      * object and there is no primitive value for it.</p>
391      * @return The current object itself.
392      * @since 1.0
393      * @javascript Re-compilers must convert the instance invocation of this method directly
394      * into a JavaScript invocation on its current object instance without changing the 
395      * method name, but expanding variable arguments, if any, into comma-separated values. 
396      */
397     public final JsHTMLScriptElement valueOf() {
398         return new JsHTMLScriptElement((JsObject)var().valueOf());
399     }
400 }