0001 
0002 /*
0003  *  JScripter Standard 1.0 - To Script In Java
0004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
0005  *  
0006  *  This program is free software: you can redistribute it and/or modify
0007  *  it under the terms of the GNU Affero General Public License as published by
0008  *  the Free Software Foundation, either version 3 of the License, or
0009  *  (at your option) any later version.
0010  *  
0011  *  This program is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  *  GNU Affero General Public License for more details.
0015  *  
0016  *  You should have received a copy of the GNU Affero General Public License
0017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 package js.user;
0021 
0022 import js.*;
0023 import js.core.*;
0024 import js.dom.*;
0025 
0026 /**
0027  * <p>An <b>opaque</b> class representing JavaScript client-side objects of the global 
0028  * {@link JsClient#Document} class.</p>
0029  *
0030  * @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>
0031  *
0032  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
0033  * generated into the target codes. Re-compilers must exit with error on the operations of
0034  * accessing that kind of class objects.
0035  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
0036  * and <tt>instanceof</tt> to it always <tt>true</tt>.
0037  */
0038 public class JsDocument extends JsClient.Document.Prototype implements EventTarget, DocumentRange
0039 {
0040     /**
0041      * <p>An <b>internal</b> class containing membership data for its enclosing
0042      * opaque class.</p>
0043      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
0044      * class members.</p>
0045      *
0046      * @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>
0047      * 
0048      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
0049      */
0050     protected static abstract class Members extends JsClient.Document.Prototype.Members
0051     {
0052         /**
0053          * <p>An <b>internal</b> static field defining a member ID of the field name and
0054          * used internally to define a member of the same name.</p>
0055          * @since 1.0
0056          * @see JsDocument#defaultView
0057          * @see JsDocument.Member#defaultView
0058          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0059          */
0060         public final static Mid defaultView     = id("defaultView"    );
0061         /**
0062          * <p>An <b>internal</b> static field defining a member ID of the field name and
0063          * used internally to define a member of the same name.</p>
0064          * @since 1.0
0065          * @see JsDocument#doctype
0066          * @see JsDocument.Member#doctype
0067          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0068          */
0069         public final static Mid doctype         = id("doctype"        );
0070         /**
0071          * <p>An <b>internal</b> static field defining a member ID of the field name and
0072          * used internally to define a member of the same name.</p>
0073          * @since 1.0
0074          * @see JsDocument#documentElement
0075          * @see JsDocument.Member#documentElement
0076          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0077          */
0078         public final static Mid documentElement = id("documentElement");
0079         /**
0080          * <p>An <b>internal</b> static field defining a member ID of the field name and
0081          * used internally to define a member of the same name.</p>
0082          * @since 1.0
0083          * @see JsDocument#implementation
0084          * @see JsDocument.Member#implementation
0085          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0086          */
0087         public final static Mid implementation  = id("implementation" );
0088         /**
0089          * <p>An <b>internal</b> static field defining a member ID of the field name and
0090          * used internally to define a member of the same name.</p>
0091          * @since 1.0
0092          * @see JsDocument#styleSheets
0093          * @see JsDocument.Member#styleSheets
0094          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0095          */
0096         public final static Mid styleSheets     = id("styleSheets"    );
0097         /**
0098          * <p>An <b>internal</b> static field defining a member ID of the field name and
0099          * used internally to define a member of the same name.</p>
0100          * @since 1.0
0101          * @see JsDocument#compatMode
0102          * @see JsDocument.Member#compatMode
0103          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
0104          */
0105         public final static Mid compatMode      = id("compatMode"     );
0106     }
0107 
0108     /**
0109      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
0110      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
0111      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
0112      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
0113      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
0114      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
0115      * either circumstance, the field names must be exactly same as the member names, as 
0116      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
0117      * based on the field names.</p>
0118      *
0119      * @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>
0120      * 
0121      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
0122      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
0123      * of class objects.
0124      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
0125      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
0126      * <pre>q.m</pre>
0127      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
0128      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
0129      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
0130      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
0131      * <pre>m</pre>
0132      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
0133      * error on the access to <b>opaque</b> fields declared by this class under any other 
0134      * circumstances.
0135      */
0136     public static class Member extends JsClient.Document.Prototype.Member
0137     {
0138         /**
0139          * <p>Internally constructs a member based on a qualifying member.</p>
0140          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
0141          * or <b>internal</b> classes or class members.</p>
0142          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
0143          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
0144          * declared in the declaring class of this constructor itself or its subclasses. 
0145          * Under this circumstance, the field names must be exactly same as the member 
0146          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
0147          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
0148          * to their names appending to the name resolved from the specified qualifying 
0149          * member with a dot in between.</p>
0150          * @param q A qualifying member
0151          * @param mid The ID of the member to construct
0152          * @since 1.0
0153          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
0154          */
0155         public Member(JsObject.Member q, Mid mid) {
0156             super(q, mid);
0157         }
0158         /**
0159          * <p>Internally constructs a member without a qualifying member.</p>
0160          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
0161          * or <b>internal</b> classes or class members.</p>
0162          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
0163          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
0164          * declared in <b>opaque</b> types other than the declaring class of this constructor 
0165          * itself and its subclasses. Under this circumstance, the field names must be
0166          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
0167          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
0168          * @param mid The ID of the member to construct
0169          * @since 1.0
0170          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
0171          */
0172         public Member(Mid mid) {
0173             super(mid);
0174         }
0175         @Override
0176         /**
0177          * <p>Evaluates the property, represented by the current member instance, of the
0178          * argument object.</p>
0179          * @param o The argument object
0180          * @return The value of the current member based on the object argument.
0181          * @since 1.0
0182          * @javascript Re-compilers must convert the instance invocation of this method into
0183          * the JavaScript expression: 
0184          * <pre>o.m</pre>
0185          * where <tt>m</tt> is the identifier name resolved from the current member
0186          * instance of the invocation.
0187          */
0188         public JsDocument with(ObjectLike o) {
0189             return new JsDocument(super.with(o));
0190         }
0191         /**
0192          * <p>Evaluates a property, represented by the current member instance, of the
0193          * JavaScript global object, that is, evaluates the member to a global identifier.</p>
0194          * @return The value of the current member based on the JavaScript global object.
0195          * @since 1.0
0196          * @javascript Re-compilers must convert the instance invocation of this method into
0197          * the JavaScript expression: 
0198          * <pre>m</pre>
0199          * where <tt>m</tt> is the identifier name resolved from the current member
0200          * instance of the invocation.
0201          */
0202         public JsDocument with() {
0203             return with(Js.win());
0204         }
0205 
0206         /**
0207          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
0208          * name of this field, qualified by the current member instance of the field, and 
0209          * to access the property of the name on an object.</p>
0210          * <p>The property, identified by this member, of a {@link JsDocument} object 
0211          * specifies a {@link JsDocumentType} node that represents the document's DTD 
0212          * for XML documents with a <tt>&lt;!DOCTYPE&gt;</tt> declaration. For HTML 
0213          * documents and for XML documents with no <tt>&lt;!DOCTYPE&gt;</tt> declaration, 
0214          * the property is <tt>null</tt>.</p>
0215          * @since 1.0
0216          * @javascript Re-compilers must resolve the member of this instance field to the
0217          * identifier of the field name appending to the identifier resolved from its 
0218          * qualifying member with a dot in between.
0219          */
0220         public final JsDocumentType.Member doctype = new JsDocumentType.Member(this, Members.doctype);
0221         /**
0222          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
0223          * name of this field, qualified by the current member instance of the field, and 
0224          * to access the property of the name on an object.</p>
0225          * <p>The property, identified by this member, of a {@link JsDocument} object 
0226          * is a reference to the root element of the document. For HTML documents, the 
0227          * property is always the {@link JsElement} object representing the <tt>&lt;html&gt;</tt> tag. 
0228          * This root element is also available through the {@link JsNode#childNodes} 
0229          * array inherited from {@link JsNode}. See also the {@link JsHTMLDocument#body} 
0230          * property.</p> 
0231          * @since 1.0
0232          * @javascript Re-compilers must resolve the member of this instance field to the
0233          * identifier of the field name appending to the identifier resolved from its 
0234          * qualifying member with a dot in between.
0235          */
0236         public final JsElement.Member documentElement = new JsElement.Member(this, Members.documentElement);
0237         /**
0238          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
0239          * name of this field, qualified by the current member instance of the field, and 
0240          * to access the property of the name on an object.</p>
0241          * <p>The property, identified by this member, of a {@link JsDocument} object 
0242          * refers to an object of {@link JsDOMImplementation} that represents the 
0243          * implementation that created the document.</p> 
0244          * @since 1.0
0245          * @javascript Re-compilers must resolve the member of this instance field to the
0246          * identifier of the field name appending to the identifier resolved from its 
0247          * qualifying member with a dot in between.
0248          */
0249         public final JsDOMImplementation.Member implementation = new JsDOMImplementation.Member(this, Members.implementation);
0250         /**
0251          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
0252          * name of this field, qualified by the current member instance of the field, and 
0253          * to access the property of the name on an object.</p>
0254          * <p>The property, identified by this member, of a {@link JsDocument} object 
0255          * refers to a collection of objects representing all style-sheets embedded in or 
0256          * linked into a document. In HTML documents, this includes style-sheets defined 
0257          * with <tt>&lt;link&gt;</tt> and <tt>&lt;style&gt;</tt> tags.</p> 
0258          * @since 1.0
0259          * @javascript Re-compilers must resolve the member of this instance field to the
0260          * identifier of the field name appending to the identifier resolved from its 
0261          * qualifying member with a dot in between.
0262          */
0263         public final JsArray.Member styleSheets = new JsArray.Member(this, Members.styleSheets);
0264         /**
0265          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
0266          * name of this field, qualified by the current member instance of the field, and 
0267          * to access the property of the name on an object.</p>
0268          * @since 1.0
0269          * @javascript Re-compilers must resolve the member of this instance field to the
0270          * identifier of the field name appending to the identifier resolved from its 
0271          * qualifying member with a dot in between.
0272          */
0273         public final Value.String.Member compatMode = new Value.String.Member(this, Members.compatMode);
0274     }
0275 
0276     /**
0277      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
0278      * with the wrapping constructor.</p>
0279      * @param var The argument of an <b>opaque</b> object.
0280      * @since 1.0
0281      * @javascript Re-compilers must ignore the construction operation of this constructor,
0282      * that is, replacing it with its only argument.
0283      */
0284     public JsDocument(JsObject var) {
0285         super(var);
0286     }
0287 
0288     /**
0289      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0290      * without a qualifying member and to access the property of the name on an object.</p>
0291      * <p>The property, identified by this member, of a {@link JsDocument} object
0292      * refers to the web browser's {@link JsWindow} object in which the document is 
0293      * displayed. The "view" is in DOM terminology.</p>
0294      * @since 1.0
0295      * @javascript Re-compilers must resolve the member of this static field to the
0296      * identifier of the field name.
0297      */
0298     public static final JsWindow.Member defaultView = new JsWindow.Member(Members.defaultView);
0299     /**
0300      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0301      * without a qualifying member and to access the property of the name on an object.</p>
0302      * <p>The property, identified by this member, of a {@link JsDocument} object 
0303      * specifies a {@link JsDocumentType} node that represents the document's DTD 
0304      * for XML documents with a <tt>&lt;!DOCTYPE&gt;</tt> declaration. For HTML 
0305      * documents and for XML documents with no <tt>&lt;!DOCTYPE&gt;</tt> declaration, 
0306      * the property is <tt>null</tt>.</p>
0307      * @since 1.0
0308      * @javascript Re-compilers must resolve the member of this static field to the
0309      * identifier of the field name.
0310      */
0311     public static final JsDocumentType.Member doctype = new JsDocumentType.Member(Members.doctype);
0312     /**
0313      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0314      * without a qualifying member and to access the property of the name on an object.</p>
0315      * <p>The property, identified by this member, of a {@link JsDocument} object 
0316      * is a reference to the root element of the document. For HTML documents, the 
0317      * property is always the {@link JsElement} object representing the <tt>&lt;html&gt;</tt><html> tag. 
0318      * This root element is also available through the {@link JsNode#childNodes} 
0319      * array inherited from {@link JsNode}. See also the {@link JsHTMLDocument#body} 
0320      * property.</p> 
0321      * @since 1.0
0322      * @javascript Re-compilers must resolve the member of this static field to the
0323      * identifier of the field name.
0324      */
0325     public static final JsElement.Member documentElement = new JsElement.Member(Members.documentElement);
0326     /**
0327      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0328      * without a qualifying member and to access the property of the name on an object.</p>
0329      * <p>The property, identified by this member, of a {@link JsDocument} object 
0330      * refers to an object of {@link JsDOMImplementation} that represents the 
0331      * implementation that created the document.</p> 
0332      * @since 1.0
0333      * @javascript Re-compilers must resolve the member of this static field to the
0334      * identifier of the field name.
0335      */
0336     public static final JsDOMImplementation.Member implementation = new JsDOMImplementation.Member(Members.implementation);
0337     /**
0338      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0339      * without a qualifying member and to access the property of the name on an object.</p>
0340      * <p>The property, identified by this member, of a {@link JsDocument} object 
0341      * refers to a collection of objects representing all style-sheets embedded in or 
0342      * linked into a document. In HTML documents, this includes style-sheets defined 
0343      * with <tt>&lt;link&gt;</tt> and <tt>&lt;style&gt;</tt> tags.</p> 
0344      * @since 1.0
0345      * @javascript Re-compilers must resolve the member of this static field to the
0346      * identifier of the field name.
0347      */
0348     public static final JsArray.Member styleSheets = new JsArray.Member(Members.styleSheets);
0349     /**
0350      * <p>An <b>opaque</b> static field defining a member that is named by the field name
0351      * without a qualifying member and to access the property of the name on an object.</p>
0352      * @since 1.0
0353      * @javascript Re-compilers must resolve the member of this static field to the
0354      * identifier of the field name.
0355      */
0356     public static final Value.String.Member compatMode = new Value.String.Member(Members.compatMode);
0357 
0358     @Override
0359     /**
0360      * <p>Returns the primitive value associated with the current instance, if there is one.
0361      * This invocation simply returns the instance itself for the current instance is an 
0362      * object and there is no primitive value for it.</p>
0363      * @return The current object itself.
0364      * @since 1.0
0365      * @javascript Re-compilers must convert the instance invocation of this method directly
0366      * into a JavaScript invocation on its current object instance without changing the 
0367      * method name, but expanding variable arguments, if any, into comma-separated values. 
0368      */
0369     public JsDocument valueOf() {
0370         return new JsDocument((JsObject)var().valueOf());
0371     }
0372     public final JsWindow var(JsWindow.Member r) {
0373         return r.with(this);
0374     }
0375     public final JsDocumentType var(JsDocumentType.Member r) {
0376         return r.with(this);
0377     }
0378     public final JsElement var(JsElement.Member r) {
0379         return r.with(this);
0380     }
0381     public final JsDOMImplementation var(JsDOMImplementation.Member r) {
0382         return r.with(this);
0383     }
0384 
0385     /**
0386      * <p>Adds an event handler function to the set of event handlers for this document. 
0387      * This is a DOM-standard method supported by all modern browsers except IE.</p>
0388      * <p>This method adds the specified event <tt>listener</tt> function to the set of 
0389      * listeners registered on this node to handle events of the specified <tt>type</tt>. 
0390      * If <tt>useCapture</tt> is <tt>true</tt>, the <tt>listener</tt> is registered as 
0391      * a capturing event listener. If <tt>useCapture</tt> is <tt>false</tt>, it is 
0392      * registered as a normal event listener.</p>
0393      * <p>This method may be called multiple times to register multiple event handlers 
0394      * for the same type of event on the same node. Note, however, that the DOM 
0395      * Specification makes no guarantees about the order in which multiple event handlers 
0396      * are invoked.</p>
0397      * <p>If the same event listener function is registered twice on the same node with 
0398      * the same <tt>type</tt> and <tt>useCapture</tt> arguments, the second registration 
0399      * is simply ignored. If a new event listener is registered on this node while an 
0400      * event is being handled at this node, the new event listener is not invoked for 
0401      * that event.</p>
0402      * <p>When a node is duplicated with {@link JsNode#cloneNode(Boolean)} or {@link JsDocument#importNode(JsNode, Boolean)}, 
0403      * the event listeners registered for the original node are not copied.</p>
0404      * <p>The same method is also defined by, and works analogously on, the {@link JsElement} 
0405      * and {@link JsWindow} objects</p>
0406      * @param type The type of event for which the event listener is to be invoked.
0407      * @param listener The event listener function that is invoked when an event of the 
0408      * specified type is dispatched to this node. When invoked, the listener function 
0409      * is passed an {@link JsEvent} object and is invoked as a method of the node on 
0410      * which it is registered.
0411      * @param useCapture If <tt>true</tt>, the specified <tt>listener</tt> is to be 
0412      * invoked only during the capturing phase of event propagation. The more common 
0413      * value of <tt>false</tt> means that the <tt>listener</tt> is not invoked during 
0414      * the capturing phase but instead is invoked when this node is the actual event 
0415      * target or when the event bubbles up to this node from its original target.
0416      * @since 1.0
0417      * @see #attachEvent(String, JsFunction)
0418      * @see #removeEventListener(String, JsFunction, Boolean)
0419      * @see JsElement#addEventListener(String, JsFunction, Boolean)
0420      * @see JsWindow#addEventListener(String, JsFunction, Boolean)
0421      * @javascript Re-compilers must convert the instance invocation of this method directly
0422      * into a JavaScript invocation on its current object instance without changing the 
0423      * method name, but expanding variable arguments, if any, into comma-separated values. 
0424      */
0425     public final void addEventListener(String type, JsFunction<?> listener, Boolean useCapture) {
0426         call(addEventListener, new Vars<Object>().add(type).add(listener).add(useCapture));
0427     }
0428     /**
0429      * <p>Removes an event handler function from the set of handlers for this document. 
0430      * This is a standard DOM method implemented by all modern browsers except IE.</p>
0431      * <p>This method removes the specified event <tt>listener</tt> function. The <tt>type</tt> 
0432      * and <tt>useCapture</tt> arguments must be the same as they are in the 
0433      * corresponding call to {@link #addEventListener(String, JsFunction, Boolean)}. If 
0434      * no event listener is found that matches the specified arguments, this method does 
0435      * nothing.</p>
0436      * <p>Once an event <tt>listener</tt> function has been removed by this method, it 
0437      * will no longer be invoked for the specified <tt>type</tt> of event on this node. 
0438      * This is true even if the event <tt>listener</tt> is removed by another event 
0439      * listener registered for the same type of event on the same node.</p>
0440      * <p>The same method is also defined by, and works analogously on, the {@link JsElement} 
0441      * and {@link JsWindow} objects</p>
0442      * @param type The type of event for which the event listener is to be deleted.
0443      * @param listener The event listener function that is to be removed.
0444      * @param useCapture <tt>true</tt> if a capturing event listener is to be removed; 
0445      * <tt>false</tt> if a normal event listener is to be removed.
0446      * @since 1.0
0447      * @see #detachEvent(String, JsFunction)
0448      * @see #addEventListener(String, JsFunction, Boolean)
0449      * @see JsElement#removeEventListener(String, JsFunction, Boolean)
0450      * @see JsWindow#removeEventListener(String, JsFunction, Boolean)
0451      * @javascript Re-compilers must convert the instance invocation of this method directly
0452      * into a JavaScript invocation on its current object instance without changing the 
0453      * method name, but expanding variable arguments, if any, into comma-separated values. 
0454      */
0455     public final void removeEventListener(String type, JsFunction<?> listener, Boolean useCapture) {
0456         call(removeEventListener, new Vars<Object>().add(type).add(listener).add(useCapture));
0457     }
0458     /**
0459      * <p>Adds an event handler function to the set of handlers for this document. 
0460      * This is the IE-specific alternative to {@link #addEventListener(String, JsFunction, Boolean)}.</p>
0461      * <p>This method is an IE-specific event registration method. It serves the same 
0462      * purpose as the standard {@link #addEventListener(String, JsFunction, Boolean)} 
0463      * method, which IE does not support, but is different from that function in several 
0464      * important ways:
0465      * <ul>
0466      * <li>Since the IE event model does not support event capturing, this method and 
0467      * {@link #detachEvent(String, JsFunction)} expect only two arguments: the event 
0468      * type and the handler function.</li>
0469      * <li>The event handler names passed to the IE methods should include the "on" 
0470      * prefix.</li>
0471      * <li>Functions registered with this method are invoked with no {@link JsEvent} 
0472      * {@link JsWindow#event} property of 
0473      * {@link JsWindow#window} object.</li>
0474      * <li>Functions registered with this method are invoked as global functions, rather 
0475      * than as methods of the node on which the event occurred. That is, when an event 
0476      * handler registered with this method executes, the <tt>this</tt> keyword refers to 
0477      * {@link JsWindow#window} object, not to the event's target node.</li>
0478      * <li>This method allows the same event handler function to be registered more than 
0479      * once. When an event of the specified type occurs, the registered function is 
0480      * invoked as many times as it is registered.</li>
0481      * </ul>
0482      * </p>
0483      * <p>The same method is also defined by, and works analogously on, the {@link JsElement} 
0484      * and {@link JsWindow} objects</p>
0485      * @param type The type of event for which the event listener is to be invoked, with 
0486      * a leading "on" prefix.
0487      * @param listener The event listener function that is invoked when an event of the 
0488      * specified type is dispatched to this node. This function is not passed any 
0489      * {@link JsWindow#event} 
0490      * property of the {@link JsWindow} object.
0491      * @since 1.0
0492      * @see #addEventListener(String, JsFunction, Boolean)
0493      * @see #detachEvent(String, JsFunction)
0494      * @see JsElement#attachEvent(String, JsFunction)
0495      * @see JsWindow#attachEvent(String, JsFunction)
0496      * @javascript Re-compilers must convert the instance invocation of this method directly
0497      * into a JavaScript invocation on its current object instance without changing the 
0498      * method name, but expanding variable arguments, if any, into comma-separated values. 
0499      */
0500     public final void attachEvent(String type, JsFunction<?> listener) {
0501         call(attachEvent, new Vars<Object>().add(type).add(listener));
0502     }
0503     /**
0504      * <p>Removes an event handler function from this document. This is the IE-specific 
0505      * alternative to the standard {@link #removeEventListener(String, JsFunction, Boolean)} 
0506      * method.</p>
0507      * <p>This method undoes the event handler function registration performed by the 
0508      * {@link #attachEvent(String, JsFunction)} method. It is the IE-specific analog to 
0509      * the standard {@link #removeEventListener(String, JsFunction, Boolean)}. To remove 
0510      * an event handler function for a node, simply invoke this method with the same 
0511      * arguments you originally passed to {@link #attachEvent(String, JsFunction)}.</p>
0512      * <p>The same method is also defined by, and works analogously on, the {@link JsElement} 
0513      * and {@link JsWindow} objects</p>
0514      * @param type The type of event for which the event listener is to be invoked, with 
0515      * a leading "on" prefix.
0516      * @param listener The event listener function that is to be removed.
0517      * @since 1.0
0518      * @see #removeEventListener(String, JsFunction, Boolean)
0519      * @see #attachEvent(String, JsFunction)
0520      * @see JsElement#detachEvent(String, JsFunction)
0521      * @see JsWindow#detachEvent(String, JsFunction)
0522      * @see jsx.client.Win#detachEvent(String, JsFunction)
0523      * @javascript Re-compilers must convert the instance invocation of this method directly
0524      * into a JavaScript invocation on its current object instance without changing the 
0525      * method name, but expanding variable arguments, if any, into comma-separated values. 
0526      */
0527     public final void detachEvent(String type, JsFunction<?> listener) {
0528         call(detachEvent, new Vars<Object>().add(type).add(listener));
0529     }
0530     /**
0531      * <p>Dispatches a synthetic event to this document.</p>
0532      * <p>This method dispatches a synthetic event created with {@link #createEvent(String)} 
0533      * and initialized with the initialization method defined by the {@link JsEvent} 
0534      * or one of its subclasses. The node on which this method is called becomes the 
0535      * target of the event, but the event first propagates down the document tree 
0536      * during the capturing phase, and then, if the {@link JsEvent#bubbles} property of 
0537      * the event is <tt>true</tt>, it bubbles up the document tree after being handled 
0538      * at the event target itself.</p>
0539      * @param evt The {@link JsEvent} object to be dispatched.
0540      * @return <tt>false</tt> if the {@link JsEvent#preventDefault()} method of <tt>evt</tt> 
0541      * is called at any time during the propagation of the event, or <tt>true</tt> 
0542      * otherwise.
0543      * @throws RuntimeException JavaScript throws a {@link JsError} object if <tt>evt</tt> 
0544      * is not initialized, or if its {@link JsEvent#type} property is <tt>null</tt> or 
0545      * the empty string. See {@link Js#err(Object)} for JS Simulation.
0546      * @since 1.0
0547      * @see #createEvent(String)
0548      * @see JsEvent#initEvent(String, Boolean, Boolean)
0549      * @see JsMouseEvent#initMouseEvent(String, Boolean, Boolean, JsWindow, Number, Number, Number, Number, Number, Boolean, Boolean, Boolean, Boolean, Number, JsElement)
0550      * @see JsElement#dispatchEvent(JsEvent)
0551      * @javascript Re-compilers must convert the instance invocation of this method directly
0552      * into a JavaScript invocation on its current object instance without changing the 
0553      * method name, but expanding variable arguments, if any, into comma-separated values. 
0554      */
0555     public final Boolean dispatchEvent(JsEvent evt) {
0556         return call(dispatchEvent, evt);
0557     }
0558     /**
0559      * <p>Returns a descendant {@link JsElement} element of this document that has the 
0560      * specified value for its <tt>id</tt> attribute, or <tt>null</tt> if no such 
0561      * element exists in the document.</p>
0562      * <p>This method searches the document for an {@link JsElement} node with an <tt>id</tt> 
0563      * attribute whose value is <tt>elementId</tt> and returns that element. If no such 
0564      * element is found, it returns <tt>null</tt>. The value of the <tt>id</tt> attribute 
0565      * is intended to be unique within a document, and if this method finds more than 
0566      * one element with the specified <tt>elementId</tt>, it may return one at random, 
0567      * or it may return <tt>null</tt>.</p>
0568      * <p>This is an important and commonly used method because it provides a simple 
0569      * way to obtain the {@link JsElement} object that represents a specific document 
0570      * element.</p>
0571      * <p>For HTML documents, this method searches for an element based on the value of 
0572      * its <tt>id</tt> attribute. Use {@link JsHTMLDocument#getElementsByName(String)} 
0573      * to search for HTML elements based on the value of their <tt>name</tt> attributes.</p>
0574      * <p>For XML documents, this method performs its search using any attribute whose 
0575      * type is <tt>id</tt>, regardless of what the name of that attribute is. If, for example, 
0576      * because the XML parser ignored or could not locate the document's DTD, XML attribute 
0577      * types are not known, this method always returns <tt>null</tt>. In JavaScript, 
0578      * this method is not usually useful with XML documents. In fact, it was originally 
0579      * defined as a member of the <tt>HTMLDocument</tt> interface but was then moved to 
0580      * the <tt>Document</tt> interface in DOM Level 2.</p>
0581      * @param elementId The value of the <tt>id</tt> attribute of the desired element.
0582      * @return The {@link JsElement} node that represents the document element with the 
0583      * specified <tt>id</tt> attribute or <tt>null</tt> if no such element is found.
0584      * @since 1.0
0585      * @see #getElementsByTagName(String)
0586      * @see #getElementById(StringLike)
0587      * @see JsHTMLDocument#getElementsByName(String)
0588      * @javascript Re-compilers must convert the instance invocation of this method directly
0589      * into a JavaScript invocation on its current object instance without changing the 
0590      * method name, but expanding variable arguments, if any, into comma-separated values. 
0591      */
0592     public final JsElement getElementById(String elementId) {
0593         return new JsElement(call(getElementById, elementId));
0594     }
0595     /**
0596      * <p>Returns a descendant {@link JsElement} element of this document that has the 
0597      * specified value for its <tt>id</tt> attribute, or <tt>null</tt> if no such 
0598      * element exists in the document.</p>
0599      * <p>This method searches the document for an {@link JsElement} node with an <tt>id</tt> 
0600      * attribute whose value is <tt>elementId</tt> and returns that element. If no such 
0601      * element is found, it returns <tt>null</tt>. The value of the <tt>id</tt> attribute 
0602      * is intended to be unique within a document, and if this method finds more than 
0603      * one element with the specified <tt>elementId</tt>, it may return one at random, 
0604      * or it may return <tt>null</tt>.</p>
0605      * <p>This is an important and commonly used method because it provides a simple 
0606      * way to obtain the {@link JsElement} object that represents a specific document 
0607      * element.</p>
0608      * <p>For HTML documents, this method searches for an element based on the value of 
0609      * its <tt>id</tt> attribute. Use {@link JsHTMLDocument#getElementsByName(String)} 
0610      * to search for HTML elements based on the value of their <tt>name</tt> attributes.</p>
0611      * <p>For XML documents, this method performs its search using any attribute whose 
0612      * type is <tt>id</tt>, regardless of what the name of that attribute is. If, for example, 
0613      * because the XML parser ignored or could not locate the document's DTD, XML attribute 
0614      * types are not known, this method always returns <tt>null</tt>. In JavaScript, 
0615      * this method is not usually useful with XML documents. In fact, it was originally 
0616      * defined as a member of the <tt>HTMLDocument</tt> interface but was then moved to 
0617      * the <tt>Document</tt> interface in DOM Level 2.</p>
0618      * @param elementId The value of the <tt>id</tt> attribute of the desired element.
0619      * @return The {@link JsElement} node that represents the document element with the 
0620      * specified <tt>id</tt> attribute or <tt>null</tt> if no such element is found.
0621      * @since 1.0
0622      * @see #getElementsByTagName(StringLike)
0623      * @see #getElementById(String)
0624      * @see JsHTMLDocument#getElementsByName(String)
0625      * @javascript Re-compilers must convert the instance invocation of this method directly
0626      * into a JavaScript invocation on its current object instance without changing the 
0627      * method name, but expanding variable arguments, if any, into comma-separated values. 
0628      */
0629     public final JsElement getElementById(StringLike elementId) {
0630         return getElementById(Js.valueOf(elementId));
0631     }
0632     /**
0633      * <p>Returns an array, technically a {@link JsNodeList} object, of all {@link JsElement} 
0634      * nodes in this document that have the specified tag name by traversing the entire 
0635      * document. The {@link JsElement} nodes appear in the returned array in the same 
0636      * order in which they appear in the document source.</p>
0637      * <p>Note that the {@link JsElement#getElementsByTagName(String)} method works 
0638      * just like this one but that traverses just the descendants of a single element, 
0639      * rather than the entire document. Do not confuse this method with {@link JsHTMLDocument#getElementsByName(String)}, 
0640      * which searches for elements based on the value of their <tt>name</tt> attributes 
0641      * rather than by their tag names.</p>
0642      * @param name The tag name of the desired elements, or the value "*" to specify 
0643      * that all descendant elements should be returned, regardless of their tag names.
0644      * @return An read-only array, technically a {@link JsNodeList} object, of all 
0645      * {@link JsElement} nodes in this document that have the specified tag name.
0646      * @since 1.0
0647      * @see #getElementsByTagName(StringLike)
0648      * @see #getElementById(String)
0649      * @see JsElement#getElementsByTagName(String)
0650      * @see JsHTMLDocument#getElementsByName(String)
0651      * @javascript Re-compilers must convert the instance invocation of this method directly
0652      * into a JavaScript invocation on its current object instance without changing the 
0653      * method name, but expanding variable arguments, if any, into comma-separated values. 
0654      */
0655     public final JsNodeList<? extends JsElement> getElementsByTagName(String name) {
0656         return new JsNodeList<JsElement>(call(getElementsByTagName, name));
0657     }
0658     /**
0659      * <p>Returns an array, technically a {@link JsNodeList} object, of all {@link JsElement} 
0660      * nodes in this document that have the specified tag name by traversing the entire 
0661      * document. The {@link JsElement} nodes appear in the returned array in the same 
0662      * order in which they appear in the document source.</p>
0663      * <p>Note that the {@link JsElement#getElementsByTagName(StringLike)} method works 
0664      * just like this one but that traverses just the descendants of a single element, 
0665      * rather than the entire document. Do not confuse this method with {@link JsHTMLDocument#getElementsByName(StringLike)}, 
0666      * which searches for elements based on the value of their <tt>name</tt> attributes 
0667      * rather than by their tag names.</p>
0668      * @param name The tag name of the desired elements, or the value "*" to specify 
0669      * that all descendant elements should be returned, regardless of their tag names.
0670      * @return A read-only array, technically a {@link JsNodeList} object, of all 
0671      * {@link JsElement} nodes in this document that have the specified tag name.
0672      * @since 1.0
0673      * @see #getElementsByTagName(String)
0674      * @see #getElementById(StringLike)
0675      * @see JsElement#getElementsByTagName(StringLike)
0676      * @see JsHTMLDocument#getElementsByName(StringLike)
0677      * @javascript Re-compilers must convert the instance invocation of this method directly
0678      * into a JavaScript invocation on its current object instance without changing the 
0679      * method name, but expanding variable arguments, if any, into comma-separated values. 
0680      */
0681     public final JsNodeList<? extends JsElement> getElementsByTagName(StringLike name) {
0682         return getElementsByTagName(Js.valueOf(name));
0683     }
0684     /**
0685      * <p>Returns an array of all {@link JsElement} nodes that have the specified tag 
0686      * name and name-space.</p>
0687      * <p>This method works like {@link #getElementsByTagName(String)}, except that the 
0688      * tag name of the desired elements is specified as a combination of a name space 
0689      * URI and a local name defined within that name space. This method is useful only 
0690      * with XML documents that use name spaces.</p>
0691      * @param namespaceURI The URI that uniquely identifies the name space of the 
0692      * desired elements.
0693      * @param localName The identifier that specifies the name of the desired elements 
0694      * within its name space.
0695      * @return A read-only array, technically a {@link JsNodeList} object, of all {@link JsElement} 
0696      * nodes in this document that have the specified name and namespace.
0697      * @since 1.0
0698      * @see JsElement#getElementsByTagNameNS(String, String)
0699      * @javascript Re-compilers must convert the instance invocation of this method directly
0700      * into a JavaScript invocation on its current object instance without changing the 
0701      * method name, but expanding variable arguments, if any, into comma-separated values. 
0702      */
0703     public final JsNodeList<? extends JsElement> getElementsByTagNameNS(String namespaceURI, String localName) {
0704         return new JsNodeList<JsElement>(call(getElementsByTagNameNS, new Vars<Object>().add(namespaceURI).add(localName)));
0705     }
0706     /**
0707      * <p>Creates a new {@link JsAttr} node with the specified name.</p>
0708      * @param name The name for the attribute to be created. 
0709      * @return A newly created {@link JsAttr} node with its {@link JsNode#nodeName} 
0710      * property set to <tt>name</tt>. 
0711      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0712      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0713      * if <tt>name</tt> contains an illegal character. See {@link Js#err(Object)} for 
0714      * JS Simulation.
0715      * @since 1.0
0716      * @see #createAttribute(StringLike)
0717      * @javascript Re-compilers must convert the instance invocation of this method directly
0718      * into a JavaScript invocation on its current object instance without changing the 
0719      * method name, but expanding variable arguments, if any, into comma-separated values. 
0720      */
0721     public final JsAttr createAttribute(String name) {
0722         return new JsAttr(call(createAttribute, name));
0723     }
0724     /**
0725      * <p>Creates a new {@link JsAttr} node with the specified name.</p>
0726      * @param name The name for the attribute to be created. 
0727      * @return A newly created {@link JsAttr} node with its {@link JsNode#nodeName} 
0728      * property set to <tt>name</tt>. 
0729      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0730      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0731      * if <tt>name</tt> contains an illegal character. See {@link Js#err(Object)} for 
0732      * JS Simulation.
0733      * @since 1.0
0734      * @see #createAttribute(String)
0735      * @javascript Re-compilers must convert the instance invocation of this method directly
0736      * into a JavaScript invocation on its current object instance without changing the 
0737      * method name, but expanding variable arguments, if any, into comma-separated values. 
0738      */
0739     public final JsAttr createAttribute(StringLike name) {
0740         return createAttribute(Js.valueOf(name));
0741     }
0742     /**
0743      * <p>Creates a new {@link JsAttr} node with the specified name and name space.</p>
0744      * <p>This method is just like {@link #createAttribute(String)}, except that the 
0745      * created {@link JsAttr} node has a name and name space instead of just a name. 
0746      * This method is useful only with XML documents that use name spaces.</p>
0747      * @param namespaceURI The unique identifier of the name space for the {@link JsAttr} 
0748      * node being created or null for no name space. 
0749      * @param qualifiedName The qualified name of the attribute, which should include 
0750      * a name space prefix, a colon, and a local name. 
0751      * @return A newly created {@link JsAttr} node with the specified name and name 
0752      * space. 
0753      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0754      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0755      * if <tt>qualifiedName</tt> contains an illegal character, the value {@link JsDOMException#NAMESPACE_ERR} 
0756      * if <tt>qualifiedName</tt> is malformed or there is a mismatch between <tt>qualifiedName</tt> 
0757      * and <tt>namespaceURI</tt>, or the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0758      * if the implementation does not support XML documents and therefore does not implement 
0759      * this method. See {@link Js#err(Object)} for JS Simulation.
0760      * @since 1.0
0761      * @see #createAttribute(String)
0762      * @javascript Re-compilers must convert the instance invocation of this method directly
0763      * into a JavaScript invocation on its current object instance without changing the 
0764      * method name, but expanding variable arguments, if any, into comma-separated values. 
0765      */
0766     public final JsAttr createAttributeNS(String namespaceURI, String qualifiedName) {
0767         return new JsAttr(call(createAttributeNS, new Vars<Object>().add(namespaceURI).add(qualifiedName)));
0768     }
0769     /**
0770      * <p>Creates a new {@link JsCDATASection} node containing the specified text.</p>
0771      * @param data The text of the {@link JsCDATASection} node being created. 
0772      * @return A newly created {@link JsCDATASection} node with the specified <tt>data</tt> 
0773      * as its contents. 
0774      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0775      * the {@link JsDOMException#code} property of the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0776      * if HTML documents do not allow <tt>CDATASection</tt> nodes. See {@link Js#err(Object)} 
0777      * for JS Simulation.
0778      * @since 1.0
0779      * @see #createCDATASection(StringLike)
0780      * @javascript Re-compilers must convert the instance invocation of this method directly
0781      * into a JavaScript invocation on its current object instance without changing the 
0782      * method name, but expanding variable arguments, if any, into comma-separated values. 
0783      */
0784     public final JsCDATASection createCDATASection(String data) {
0785         return new JsCDATASection(call(createCDATASection, data));
0786     }
0787     /**
0788      * <p>Creates a new {@link JsCDATASection} node containing the specified text.</p>
0789      * @param data The text of the {@link JsCDATASection} node being created. 
0790      * @return A newly created {@link JsCDATASection} node with the specified <tt>data</tt> 
0791      * as its contents. 
0792      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0793      * the {@link JsDOMException#code} property of the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0794      * if HTML documents do not allow <tt>CDATASection</tt> nodes. See {@link Js#err(Object)} 
0795      * for JS Simulation.
0796      * @since 1.0
0797      * @see #createCDATASection(String)
0798      * @javascript Re-compilers must convert the instance invocation of this method directly
0799      * into a JavaScript invocation on its current object instance without changing the 
0800      * method name, but expanding variable arguments, if any, into comma-separated values. 
0801      */
0802     public final JsCDATASection createCDATASection(StringLike data) {
0803         return createCDATASection(Js.valueOf(data));
0804     }
0805     /**
0806      * <p>Creates a new {@link JsComment} node containing the specified string.</p>
0807      * @param data The text of the {@link JsComment} node being created. 
0808      * @return A newly created {@link JsComment} node with the specified <tt>data</tt> 
0809      * as its text. 
0810      * @since 1.0
0811      * @see #createComment(StringLike)
0812      * @javascript Re-compilers must convert the instance invocation of this method directly
0813      * into a JavaScript invocation on its current object instance without changing the 
0814      * method name, but expanding variable arguments, if any, into comma-separated values. 
0815      */
0816     public final JsComment createComment(String data) {
0817         return new JsComment(call(createComment, data));
0818     }
0819     /**
0820      * <p>Creates a new {@link JsComment} node containing the specified string.</p>
0821      * @param data The text of the {@link JsComment} node being created. 
0822      * @return A newly created {@link JsComment} node with the specified <tt>data</tt> 
0823      * as its text. 
0824      * @since 1.0
0825      * @see #createComment(String)
0826      * @javascript Re-compilers must convert the instance invocation of this method directly
0827      * into a JavaScript invocation on its current object instance without changing the 
0828      * method name, but expanding variable arguments, if any, into comma-separated values. 
0829      */
0830     public final JsComment createComment(StringLike data) {
0831         return createComment(Js.valueOf(data));
0832     }
0833     /**
0834      * <p>Creates a new, empty {@link JsDocumentFragment} node.</p>
0835      * @return A newly created {@link JsDocumentFragment} node with no children. 
0836      * @since 1.0
0837      * @javascript Re-compilers must convert the instance invocation of this method directly
0838      * into a JavaScript invocation on its current object instance without changing the 
0839      * method name, but expanding variable arguments, if any, into comma-separated values. 
0840      */
0841     public final JsDocumentFragment createDocumentFragment() {
0842         return new JsDocumentFragment(call(createDocumentFragment));
0843     }
0844     /**
0845      * <p>Creates a new {@link JsElement} node with the specified tag name.</p>
0846      * @param tagName The tag name of the {@link JsElement} node being created. Since 
0847      * HTML tags are case-insensitive, you may use any capitalization for HTML tag names. 
0848      * XML tag names are case-sensitive. 
0849      * @return A newly created {@link JsElement} node with the specified tag name. 
0850      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0851      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0852      * if <tt>tagName</tt> contains an illegal character. See {@link Js#err(Object)} 
0853      * for JS Simulation.
0854      * @since 1.0
0855      * @see #createElement(StringLike)
0856      * @javascript Re-compilers must convert the instance invocation of this method directly
0857      * into a JavaScript invocation on its current object instance without changing the 
0858      * method name, but expanding variable arguments, if any, into comma-separated values. 
0859      */
0860     public JsElement createElement(String tagName) {
0861         return new JsElement(call(createElement, tagName));
0862     }
0863     /**
0864      * <p>Creates a new {@link JsElement} node with the specified tag name.</p>
0865      * @param tagName The tag name of the {@link JsElement} node being created. Since 
0866      * HTML tags are case-insensitive, you may use any capitalization for HTML tag names. 
0867      * XML tag names are case-sensitive. 
0868      * @return A newly created {@link JsElement} node with the specified tag name. 
0869      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0870      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0871      * if <tt>tagName</tt> contains an illegal character. See {@link Js#err(Object)} 
0872      * for JS Simulation.
0873      * @since 1.0
0874      * @see #createElement(String)
0875      * @javascript Re-compilers must convert the instance invocation of this method directly
0876      * into a JavaScript invocation on its current object instance without changing the 
0877      * method name, but expanding variable arguments, if any, into comma-separated values. 
0878      */
0879     public JsElement createElement(StringLike tagName) {
0880         return createElement(Js.valueOf(tagName));
0881     }
0882     /**
0883      * <p>Creates a new {@link JsElement} node with the specified tag name and name-space.</p>
0884      * <p>This method is just like {@link #createElement(String)}, except that the 
0885      * created {@link JsElement} node has a name and name space instead of just a name. 
0886      * This method is useful only with XML documents that use name spaces.</p>
0887      * @param namespaceURI The unique identifier for the name space of the new {@link JsElement} 
0888      * node or <tt>null</tt> for no name space. 
0889      * @param qualifiedName The qualified name of the new {@link JsElement} node. This 
0890      * should include a name space prefix, a colon, and a local name. 
0891      * @return A newly created {@link JsElement} node with the specified tag name and 
0892      * name space. 
0893      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0894      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0895      * if <tt>qualifiedName</tt> contains an illegal character, the value {@link JsDOMException#NAMESPACE_ERR} 
0896      * if <tt>qualifiedName</tt> is malformed or there is a mismatch between <tt>qualifiedName</tt> 
0897      * and <tt>namespaceURI</tt>, or the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0898      * if the implementation does not support XML documents and therefore does not implement 
0899      * this method. See {@link Js#err(Object)} for JS Simulation.
0900      * @since 1.0
0901      * @see #createElement(String)
0902      * @javascript Re-compilers must convert the instance invocation of this method directly
0903      * into a JavaScript invocation on its current object instance without changing the 
0904      * method name, but expanding variable arguments, if any, into comma-separated values. 
0905      */
0906     public final JsElement createElementNS(String namespaceURI, String qualifiedName) {
0907         return new JsElement(call(createElementNS, new Vars<Object>().add(namespaceURI).add(qualifiedName)));
0908     }
0909     /**
0910      * <p>Creates a {@link JsEntityReference} object.</p>
0911      * <p>If the referenced entity is known, the child list of the {@link JsEntityReference} 
0912      * node is made the same as that of the corresponding {@link JsEntity} node.</p>
0913      * <p>Note that this method is not supported by main-stream web browsers.</p>
0914      * @param name The name of the entity to reference. 
0915      * @return A newly created {@link JsEntityReference} object. 
0916      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0917      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
0918      * if the specified <tt>name</tt> contains an illegal character or the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0919      * if this document is an HTML document. See {@link Js#err(Object)} for JS Simulation.
0920      * @since 1.0
0921      * @javascript Re-compilers must convert the instance invocation of this method directly
0922      * into a JavaScript invocation on its current object instance without changing the 
0923      * method name, but expanding variable arguments, if any, into comma-separated values. 
0924      */
0925     public final JsEntityReference createEntityReference(String name) {
0926         throw new UnsupportedOperationException();
0927     }
0928     /**
0929      * <p>Creates a new synthetic {@link JsEvent} object of the named type.</p>
0930      * <p>In DOM Specification, this method is actually defined not by the DOM <tt>Document</tt> 
0931      * interface but by the <tt>DocumentEvent</tt> interface. If an implementation 
0932      * supports the Events module, the <tt>Document</tt> object always implements the 
0933      * <tt>DocumentEvent</tt> interface and supports this method. Note that Internet 
0934      * Explorer does not support the DOM Events module.</p>
0935      * @param eventType The name of the event module for which an {@link JsEvent} object 
0936      * is desired. Note that the value of this argument should not be the (singular) name 
0937      * of the DOM event interface to be created but instead should be the (plural) name of 
0938      * the DOM module that defines that interface. Valid event types are listed as follows:
0939      * <ul>
0940      * <li>HTMLEvents: creating a {@link JsEvent} object that must be initialized with 
0941      * the initialization method {@link JsEvent#initEvent(String, Boolean, Boolean)}.</li>
0942      * <li>MouseEvents: creating a {@link JsMouseEvent} object that must be initialized with 
0943      * the initialization method {@link JsMouseEvent#initMouseEvent(String, Boolean, Boolean, JsWindow, Number, Number, Number, Number, Number, Boolean, Boolean, Boolean, Boolean, Number, JsElement)}.</li>
0944      * <li>UIEvents: creating a {@link JsUIEvent} object that must be initialized with 
0945      * the initialization method {@link JsUIEvent#initUIEvent(String, Boolean, Boolean, JsWindow, Long)}.</li>
0946      * </ul> 
0947      * @return A newly created {@link JsEvent} object of the specified type. 
0948      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0949      * the {@link JsDOMException#code} property of the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0950      * if the implementation does not support events of the requested type. See {@link Js#err(Object)} 
0951      * for JS Simulation.
0952      * @since 1.0
0953      * @see #createEvent(StringLike)
0954      * @javascript Re-compilers must convert the instance invocation of this method directly
0955      * into a JavaScript invocation on its current object instance without changing the 
0956      * method name, but expanding variable arguments, if any, into comma-separated values. 
0957      */
0958     public final JsEvent createEvent(String eventType) {
0959         return new JsEvent(call(createEvent, eventType));
0960     }
0961     /**
0962      * <p>Creates a new synthetic {@link JsEvent} object of the named type.</p>
0963      * <p>In DOM Specification, this method is actually defined not by the DOM <tt>Document</tt> 
0964      * interface but by the <tt>DocumentEvent</tt> interface. If an implementation 
0965      * supports the Events module, the <tt>Document</tt> object always implements the 
0966      * <tt>DocumentEvent</tt> interface and supports this method. Note that Internet 
0967      * Explorer does not support the DOM Events module.</p>
0968      * @param eventType The name of the event module for which an {@link JsEvent} object 
0969      * is desired. Note that the value of this argument should not be the (singular) name 
0970      * of the DOM event interface to be created but instead should be the (plural) name of 
0971      * the DOM module that defines that interface. Valid event types are listed as follows:
0972      * <ul>
0973      * <li>HTMLEvents: creating a {@link JsEvent} object that must be initialized with 
0974      * the initialization method {@link JsEvent#initEvent(String, Boolean, Boolean)}.</li>
0975      * <li>MouseEvents: creating a {@link JsMouseEvent} object that must be initialized with 
0976      * the initialization method {@link JsMouseEvent#initMouseEvent(String, Boolean, Boolean, JsWindow, Number, Number, Number, Number, Number, Boolean, Boolean, Boolean, Boolean, Number, JsElement)}.</li>
0977      * <li>UIEvents: creating a {@link JsUIEvent} object that must be initialized with 
0978      * the initialization method {@link JsUIEvent#initUIEvent(String, Boolean, Boolean, JsWindow, Long)}.</li>
0979      * </ul> 
0980      * @return A newly created {@link JsEvent} object of the specified type. 
0981      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
0982      * the {@link JsDOMException#code} property of the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
0983      * if the implementation does not support events of the requested type. See {@link Js#err(Object)} 
0984      * for JS Simulation.
0985      * @since 1.0
0986      * @see #createEvent(String)
0987      * @javascript Re-compilers must convert the instance invocation of this method directly
0988      * into a JavaScript invocation on its current object instance without changing the 
0989      * method name, but expanding variable arguments, if any, into comma-separated values. 
0990      */
0991     public final JsEvent createEvent(StringLike eventType) {
0992         return createEvent(Js.valueOf(eventType));
0993     }
0994     /**
0995      * <p>Creates a new {@link JsXPathExpression} object that represents a compiled 
0996      * <tt>XPath</tt> query.</p>
0997      * <p>Note that Internet Explorer does not support this method. See {@link JsNode#selectNodes(String)} 
0998      * for an IE-specific alternative.</p>
0999      * @param xpathText The string representing the XPath expression to compile.
1000      * @param namespaceURLMapper A function that will map from a name space prefix to a 
1001      * full name space URL, or <tt>null</tt> if no such mapping is required.
1002      * @return A newly created {@link JsXPathExpression} object. 
1003      * @throws RuntimeException JavaScript throws a {@link JsError} object if the <tt>xpathText</tt> 
1004      * contains a syntax error or if it uses a name space prefix that cannot be resolved 
1005      * by <tt>namespaceURLMapper</tt>. See {@link Js#err(Object)} for JS Simulation.
1006      * @since 1.0
1007      * @see JsNode#selectNodes(String)
1008      * @javascript Re-compilers must convert the instance invocation of this method directly
1009      * into a JavaScript invocation on its current object instance without changing the 
1010      * method name, but expanding variable arguments, if any, into comma-separated values. 
1011      */
1012     public final JsXPathExpression createExpression(String xpathText, JsFunction<? extends String> namespaceURLMapper) {
1013         return new JsXPathExpression(call(createExpression, new Vars<Object>().add(xpathText).add(namespaceURLMapper)));
1014     }
1015     /**
1016      * <p>Creates a new {@link JsXPathExpression} object that represents a compiled 
1017      * <tt>XPath</tt> query.</p>
1018      * <p>Note that Internet Explorer does not support this method. See {@link JsNode#selectNodes(String)} 
1019      * for an IE-specific alternative.</p>
1020      * @param xpathText The string representing the XPath expression to compile.
1021      * @return A newly created {@link JsXPathExpression} object. 
1022      * @throws RuntimeException JavaScript throws a {@link JsError} object if the <tt>xpathText</tt> 
1023      * contains a syntax error. See {@link Js#err(Object)} for JS Simulation.
1024      * @since 1.0
1025      * @see #evaluate(String, JsNode, JsFunction, Number, JsXPathResult)
1026      * @see JsNode#selectNodes(String)
1027      * @javascript Re-compilers must convert the instance invocation of this method directly
1028      * into a JavaScript invocation on its current object instance without changing the 
1029      * method name, but expanding variable arguments, if any, into comma-separated values. 
1030      */
1031     public final JsXPathExpression createExpression(String xpathText) {
1032         return new JsXPathExpression(call(createExpression, new Vars<Object>().add(xpathText).add(null)));
1033     }
1034     /**
1035      * <p>Creates a new {@link JsProcessingInstruction} node with the specified target 
1036      * and data string.</p>
1037      * @param target The target of the processing instruction.
1038      * @param data The content text of the processing instruction.
1039      * @return A newly created {@link JsProcessingInstruction} node. 
1040      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
1041      * the {@link JsDOMException#code} property of the value {@link JsDOMException#INVALID_CHARACTER_ERR} 
1042      * if <tt>target</tt> contains an illegal character, the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
1043      * if this is an HTML document and does not support processing instructions. See 
1044      * {@link Js#err(Object)} for JS Simulation.
1045      * @since 1.0
1046      * @javascript Re-compilers must convert the instance invocation of this method directly
1047      * into a JavaScript invocation on its current object instance without changing the 
1048      * method name, but expanding variable arguments, if any, into comma-separated values. 
1049      */
1050     public final JsProcessingInstruction createProcessingInstruction(String target, String data) {
1051         return new JsProcessingInstruction(call(createProcessingInstruction, new Vars<Object>().add(target).add(data)));
1052     }
1053     /**
1054      * <p>Creates a new {@link JsRange} object.</p>
1055      * <p>This method creates a {@link JsRange} object that can be used to represent a 
1056      * region of this document or of a {@link JsDocumentFragment} associated with this 
1057      * document.</p>
1058      * <p>This method is technically part of the <tt>DocumentRange</tt> interface in DOM2 
1059      * specification. It is implemented by the {@link JsDocument} object only in 
1060      * implementations that support the {@link JsRange} module. That is in the DOM Specification 
1061      * this method is actually defined not by the DOM <tt>Document</tt> interface but by 
1062      * the <tt>DocumentRange</tt> interface. If an implementation supports the <tt>Range</tt> 
1063      * module, the {@link JsDocument} object always implements <tt>DocumentRange</tt> and 
1064      * defines this method. Internet Explorer does not support this module.</p>
1065      * @return A newly created {@link JsRange} object with both boundary points set to the 
1066      * beginning of the document. 
1067      * @since 1.0
1068      * @javascript Re-compilers must convert the instance invocation of this method directly
1069      * into a JavaScript invocation on its current object instance without changing the 
1070      * method name, but expanding variable arguments, if any, into comma-separated values. 
1071      */
1072     public final JsRange createRange() {
1073         return new JsRange(call(createRange));
1074     }
1075     /**
1076      * <p>Creates a style sheet for the document.</p>
1077      * <p>This method is IE specific.</p>
1078      * @param url Specifies how to add the style sheet to the document. If a file name is 
1079      * specified for the argument, the style information will be added as a {@link JsHTMLLinkElement} 
1080      * object. If the argument contains style information, this information will be added 
1081      * to the style object.
1082      * @param index Specifies the index that indicates where the new style sheet is inserted 
1083      * in the {@link #styleSheets} collection. The default is to insert the new style sheet 
1084      * at the end of the collection.
1085      * @return A newly created {@link JsCSSStyleSheet} object. 
1086      * @since 1.0
1087      * @see #createStyleSheet(String)
1088      * @javascript Re-compilers must convert the instance invocation of this method directly
1089      * into a JavaScript invocation on its current object instance without changing the 
1090      * method name, but expanding variable arguments, if any, into comma-separated values. 
1091      */
1092     public final JsCSSStyleSheet createStyleSheet(String url, int index) {
1093         return new JsCSSStyleSheet(call(createStyleSheet, new Vars<Object>().add(url).add(index)));
1094     }
1095     /**
1096      * <p>Creates a style sheet for the document.</p>
1097      * <p>This method is IE specific.</p>
1098      * @param url Specifies how to add the style sheet to the document. If a file name is 
1099      * specified for the argument, the style information will be added as a {@link JsHTMLLinkElement} 
1100      * object. If the argument contains style information, this information will be added 
1101      * to the style object.
1102      * @return A newly created {@link JsCSSStyleSheet} object. 
1103      * @since 1.0
1104      * @see #createStyleSheet(String, int)
1105      * @javascript Re-compilers must convert the instance invocation of this method directly
1106      * into a JavaScript invocation on its current object instance without changing the 
1107      * method name, but expanding variable arguments, if any, into comma-separated values. 
1108      */
1109     public final JsCSSStyleSheet createStyleSheet(String url) {
1110         return new JsCSSStyleSheet(call(createStyleSheet, url));
1111     }
1112     /**
1113      * <p>Creates a new {@link JsText} node to represent the specified text.</p>
1114      * @param data The content of the {@link JsText} node to create.
1115      * @return A newly created {@link JsText} node that represents the specified <tt>data</tt> 
1116      * string. 
1117      * @since 1.0
1118      * @see #createTextNode(StringLike)
1119      * @javascript Re-compilers must convert the instance invocation of this method directly
1120      * into a JavaScript invocation on its current object instance without changing the 
1121      * method name, but expanding variable arguments, if any, into comma-separated values. 
1122      */
1123     public final JsText createTextNode(String data) {
1124         return new JsText(call(createTextNode, data));
1125     }
1126     /**
1127      * <p>Creates a new {@link JsText} node to represent the specified text.</p>
1128      * @param data The content of the {@link JsText} node to create.
1129      * @return A newly created {@link JsText} node that represents the specified <tt>data</tt> 
1130      * string. 
1131      * @since 1.0
1132      * @see #createTextNode(String)
1133      * @javascript Re-compilers must convert the instance invocation of this method directly
1134      * into a JavaScript invocation on its current object instance without changing the 
1135      * method name, but expanding variable arguments, if any, into comma-separated values. 
1136      */
1137     public final JsText createTextNode(StringLike data) {
1138         return createTextNode(Js.valueOf(data));
1139     }
1140     /**
1141      * <p>Evaluates an XPath query against this document.</p>
1142      * <p>This method evaluates the specified XPath expression against the given context 
1143      * node and returns an {@link JsXPathResult} object, using <tt>resultType</tt> to 
1144      * determine what the result type should be. If you want to evaluate an expression 
1145      * more than once, use {@link #createExpression(String)} to compile the expression 
1146      * to a {@link JsXPathExpression} object and then use the {@link JsXPathExpression#evaluate(JsNode, Number, JsXPathResult)} 
1147      * method of that object.</p>
1148      * <p>See {@link JsNode#selectNodes(String)} and {@link JsNode#selectSingleNode(String)} 
1149      * for an IE-specific alternative.</p>
1150      * @param xpathText The string representing the XPath expression to evaluate.
1151      * @param contextNode The node in this document against which the expression is to 
1152      * be evaluated.
1153      * @param namespaceURLMapper A function that will map from a name space prefix to a 
1154      * full name space URL or <tt>null</tt> if no such mapping is required.
1155      * @param resultType The type of object expected as a result, using XPath conversions 
1156      * to coerce the result. Possible values for the type are the constants defined by 
1157      * {@link JsClient#XPathResult} object.
1158      * @param result A {@link JsXPathResult} object to be reused or <tt>null</tt> if you 
1159      * want a new {@link JsXPathResult} object to be created.
1160      * @return A {@link JsXPathResult} object representing the evaluation of the expression 
1161      * against the given context node. 
1162      * @throws RuntimeException JavaScript throws a {@link JsError} object if the <tt>xpathText</tt> 
1163      * contains a syntax error, if the result of the expression cannot be converted to 
1164      * the desired <tt>resultType</tt>, if the expression contains a name space prefix 
1165      * that cannot be resolved by <tt>namespaceURLMapper</tt>, or if <tt>contextNode</tt> is of 
1166      * the wrong type or is not associated with this document. See {@link Js#err(Object)} for 
1167      * JS Simulation.
1168      * @since 1.0
1169      * @see #createExpression(String, JsFunction)
1170      * @see JsNode#selectNodes(String)
1171      * @see JsNode#selectSingleNode(String)
1172      * @javascript Re-compilers must convert the instance invocation of this method directly
1173      * into a JavaScript invocation on its current object instance without changing the 
1174      * method name, but expanding variable arguments, if any, into comma-separated values. 
1175      */
1176     public final JsXPathResult evaluate(String xpathText, JsNode contextNode, JsFunction<? extends String> namespaceURLMapper, Number resultType, JsXPathResult result) {
1177         return new JsXPathResult(call(evaluate, new Vars<Object>().add(xpathText).add(contextNode).add(namespaceURLMapper).add(resultType).add(result)));
1178     }
1179     /**
1180      * <p>Makes a copy of a node from some other document that is suitable for 
1181      * insertion into this document.</p>
1182      * <p>This method is passed a node defined in another document and returns a copy of 
1183      * the node that is suitable for insertion into this document. If <tt>deep</tt> is 
1184      * <tt>true</tt>, all descendants of the node are also copied. The original node and 
1185      * its descendants are not modified in any way. The returned copy has its {@link JsNode#ownerDocument} 
1186      * property set to this document but has a {@link JsNode#parentNode} of <tt>null</tt> 
1187      * because it has not yet been inserted into the document. Event listener functions 
1188      * registered on the original node or tree are not copied.</p>
1189      * <p>When an {@link JsElement} node is imported, only the attributes that are 
1190      * explicitly specified in the source document are imported with it. When an {@link JsAttr} 
1191      * node is imported, its {@link JsAttr#specified} property is automatically set to 
1192      * <tt>true</tt>.</p>
1193      * @param importedNode The node to be imported.
1194      * @param deep If <tt>true</tt>, recursively copy all descendants of <tt>importedNode</tt> 
1195      * as well.
1196      * @return A copy of <tt>importedNode</tt>, and possibly all of its descendants if 
1197      * <tt>deep</tt> is <tt>true</tt>, with its {@link JsNode#ownerDocument} set to this 
1198      * document. 
1199      * @throws RuntimeException JavaScript throws a {@link JsDOMException} object with 
1200      * the {@link JsDOMException#code} property of the value {@link JsDOMException#NOT_SUPPORTED_ERR} 
1201      * if <tt>importedNode</tt> is a {@link JsDocument} or {@link JsDocumentType} node, 
1202      * because those types of nodes cannot be imported. See {@link Js#err(Object)} for 
1203      * JS Simulation.
1204      * @since 1.0
1205      * @see JsNode#cloneNode(Boolean)
1206      * @javascript Re-compilers must convert the instance invocation of this method directly
1207      * into a JavaScript invocation on its current object instance without changing the 
1208      * method name, but expanding variable arguments, if any, into comma-separated values. 
1209      */
1210     public final JsNode importNode(JsNode importedNode, Boolean deep) {
1211         return new JsNode(call(importNode, new Vars<Object>().add(importedNode).add(deep)));
1212     }
1213     /**
1214      * <p>Parses a string of XML mark-up and stores the result in this document object.</p>
1215      * <p>This IE-specific method parses the specified string of XML text and builds a 
1216      * tree of DOM nodes in the current {@link JsDocument} object, discarding any nodes 
1217      * that previously existed in the {@link JsDocument} object.</p>
1218      * <p>This method does not exist on {@link JsDocument} objects that represent HTML 
1219      * documents. Before calling the method, you typically create a new, empty {@link JsDocument} 
1220      * object to hold the parsed content:
1221      * <pre> JsDocument doc = new JsDocument(Js.activeX("MSXML2.DOMDocument"));
1222      * doc.loadXML(markup);</pre>
1223      * </p>
1224      * <p>See {@link JsDOMParser#parseFromString(String, String)} for a non-IE 
1225      * alternative.</p>
1226      * @param text The XML mark-up to parse.
1227      * @since 1.0
1228      * @see #loadXML(StringLike)
1229      * @see JsDOMParser#parseFromString(String, String)
1230      * @javascript Re-compilers must convert the instance invocation of this method directly
1231      * into a JavaScript invocation on its current object instance without changing the 
1232      * method name, but expanding variable arguments, if any, into comma-separated values. 
1233      */
1234     public final void loadXML(String text) {
1235         call(loadXML, text);
1236     }
1237     /**
1238      * <p>Parses a string of XML mark-up and stores the result in this document object.</p>
1239      * <p>This IE-specific method parses the specified string of XML text and builds a 
1240      * tree of DOM nodes in the current {@link JsDocument} object, discarding any nodes 
1241      * that previously existed in the {@link JsDocument} object.</p>
1242      * <p>This method does not exist on {@link JsDocument} objects that represent HTML 
1243      * documents. Before calling the method, you typically create a new, empty {@link JsDocument} 
1244      * object to hold the parsed content:
1245      * <pre> JsDocument doc = new JsDocument(Js.activeX("MSXML2.DOMDocument"));
1246      * doc.loadXML(markup);</pre>
1247      * </p>
1248      * <p>See {@link JsDOMParser#parseFromString(String, String)} for a non-IE 
1249      * alternative.</p>
1250      * @param text The XML mark-up to parse.
1251      * @since 1.0
1252      * @see #loadXML(String)
1253      * @see JsDOMParser#parseFromString(String, String)
1254      * @javascript Re-compilers must convert the instance invocation of this method directly
1255      * into a JavaScript invocation on its current object instance without changing the 
1256      * method name, but expanding variable arguments, if any, into comma-separated values. 
1257      */
1258     public final void loadXML(StringLike text) {
1259         loadXML(Js.valueOf(text));
1260     }
1261     /**
1262      * <p>Executes a command on the current document, current selection, or the given range.</p>
1263      * <p>This method is IE specific. Do not invoke the method until after the page loads.</p>
1264      * @param sCommand A required string that specifies the command to execute. 
1265      * This command can be any of the command identifiers that can be executed in script.
1266      * @param bUserInterface Optional. <tt>false</tt> or undefined for not displaying a 
1267      * user interface; <tt>true</tt> to display a user interface, if the command 
1268      * supports one.
1269      * @param vValue Optional. Possible values depend on <tt>sCommand</tt>.
1270      * @return <tt>True</tt> if the command is successful.
1271      * @since 1.0
1272      * @javascript Re-compilers must convert the instance invocation of this method directly
1273      * into a JavaScript invocation on its current object instance without changing the 
1274      * method name, but expanding variable arguments, if any, into comma-separated values. 
1275      */
1276     public final boolean execCommand(String sCommand, Boolean bUserInterface, Object vValue) {
1277         return call(execCommand, new Vars<Object>().add(sCommand ).add(bUserInterface).add(vValue));
1278     }
1279 }