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.core;
021 
022 import js.ObjectLike;
023 
024 /**
025  * <p>An <b>opaque</b> class representing JavaScript <tt>URIError</tt>.</p>
026  * <p>An instance of this class is thrown by {@link js.Js#decodeURI(Object)} and 
027  * {@link js.Js#decodeURIComponent(Object)} if the specified string contains illegal 
028  * hexadecimal escapes. It can also be thrown by {@link js.Js#encodeURI(Object)} and 
029  * {@link js.Js#encodeURIComponent(Object)} if the specified string contains illegal 
030  * unicode surrogate pairs.</p>
031  * <p>In JS, to throw a value or object as a <tt>RuntimeException</tt>, see {@link js.Js#err(Object)}.</p>
032  *
033  * @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>
034  * @see js.Js#err(Object)
035  * 
036  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be 
037  * generated into the target codes. Re-compilers must exit with error on the operations of 
038  * accessing that kind of class objects.
039  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored 
040  * and <tt>instanceof</tt> to it always <tt>true</tt>.
041  */
042 public class JsURIError extends JsGlobal.URIError.Prototype
043 {
044     /**
045      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
046      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
047      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
048      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
049      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
050      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
051      * either circumstance, the field names must be exactly same as the member names, as 
052      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
053      * based on the field names.</p>
054      *
055      * @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>
056      * 
057      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created 
058      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
059      * of class objects.
060      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in 
061      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
062      * <pre>q.m</pre>
063      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier 
064      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
065      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
066      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
067      * <pre>m</pre>
068      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report 
069      * error on the access to <b>opaque</b> fields declared by this class under any other 
070      * circumstances.
071      */
072     public static class Member extends JsGlobal.URIError.Prototype.Member
073     {
074         /**
075          * <p>Internally constructs a member based on a qualifying member.</p>
076          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b> 
077          * or <b>internal</b> classes or class members.</p>
078          * <p>Note that, this constructor is <b>internal</b> but its declaring class is 
079          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
080          * declared in the declaring class of this constructor itself or its subclasses. 
081          * Under this circumstance, the field names must be exactly same as the member 
082          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
083          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly 
084          * to their names appending to the name resolved from the specified qualifying 
085          * member with a dot in between.</p>
086          * @param q A qualifying member
087          * @param mid The ID of the member to construct
088          * @since 1.0
089          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor. 
090          */
091         public Member(JsObject.Member q, Mid mid) {
092             super(q, mid);
093         }
094         /**
095          * <p>Internally constructs a member without a qualifying member.</p>
096          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b> 
097          * or <b>internal</b> classes or class members.</p>
098          * <p>Note that, this constructor is <b>internal</b> but its declaring class is 
099          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
100          * declared in <b>opaque</b> types other than the declaring class of this constructor 
101          * itself and its subclasses. Under this circumstance, the field names must be 
102          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b> 
103          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
104          * @param mid The ID of the member to construct
105          * @since 1.0
106          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor. 
107          */
108         public Member(Mid mid) {
109             super(mid);
110         }
111         /**
112          * <p>Evaluates the property, represented by the current member instance, of the 
113          * argument object.</p>
114          * @param o The argument object
115          * @return The value of the current member based on the object argument.
116          * @since 1.0
117          * @javascript Re-compilers must convert the instance invocation of this method into 
118          * the JavaScript expression: 
119          * <pre>o.m</pre>
120          * where <tt>m</tt> is the identifier name resolved from the current member 
121          * instance of the invocation.
122          */
123         @Override
124         public JsURIError with(ObjectLike o) {
125             return new JsURIError(super.with(o));
126         }
127 
128         /**
129          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the 
130          * name of this field, qualified by the current member instance of the field, and 
131          * to access the property of the name on an object.</p>
132          * <p>The <tt>constructor</tt> property of an object is a reference to the function 
133          * that was the constructor for that object.</p>
134          * <p>A common use of the <tt>constructor</tt> property is to determine the type of unknown 
135          * objects. Given an unknown value, you can use the {@link js.Js#typeof(Object)} operation 
136          * to determine whether it is a primitive value or an object. If it is an object, you can 
137          * use the <tt>constructor</tt> property to determine what type of object it is.</p>
138          * <p>Note, however, that while this technique works for the objects built into core 
139          * JavaScript, it is not guaranteed to work with host objects such as the <tt>window</tt> 
140          * object of client-side JavaScript. The default implementation of the <tt>toString()</tt> 
141          * method provides another way to determine the type of an unknown object.</p>
142          * @since 1.0
143          * @javascript Re-compilers must resolve the member of this instance field to the 
144          * identifier of the field name appending to the identifier resolved from its 
145          * qualifying member with a dot in between.
146          */
147         public final JsFunction.Member<JsURIError> constructor = new JsFunction.Member<JsURIError>(this, Members.constructor, Generic.get(JsURIError.class));
148     }
149 
150     /**
151      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it 
152      * with the wrapping constructor.</p>
153      * @param var The argument of an <b>opaque</b> object.
154      * @since 1.0
155      * @javascript Re-compilers must ignore the construction operation of this constructor, 
156      * that is, replacing it with its only argument.
157      */
158     public JsURIError(JsObject var) {
159         super(var);
160     }
161 
162     /**
163      * <p>An <b>opaque</b> static field defining a member that is named by the field name 
164      * without a qualifying member and to access the property of the name on an object.</p>
165      * <p>The <tt>constructor</tt> property of an object is a reference to the function 
166      * that was the constructor for that object.</p>
167      * <p>A common use of the <tt>constructor</tt> property is to determine the type of unknown 
168      * objects. Given an unknown value, you can use the {@link js.Js#typeof(Object)} operation 
169      * to determine whether it is a primitive value or an object. If it is an object, you can 
170      * use the <tt>constructor</tt> property to determine what type of object it is.</p>
171      * <p>Note, however, that while this technique works for the objects built into core 
172      * JavaScript, it is not guaranteed to work with host objects such as the <tt>window</tt> 
173      * object of client-side JavaScript. The default implementation of the <tt>toString()</tt> 
174      * method provides another way to determine the type of an unknown object.</p>
175      * @since 1.0
176      * @javascript Re-compilers must resolve the member of this static field to the 
177      * identifier of the field name.
178      */
179     public static final JsFunction.Member<JsURIError> constructor = new JsFunction.Member<JsURIError>(Members.constructor, Generic.get(JsURIError.class));
180 
181     /**
182      * <p>Returns the primitive value associated with the current instance, if there is one. 
183      * This invocation simply returns the instance itself for the current instance is an 
184      * object and there is no primitive value for it.</p>
185      * @return The current object itself.
186      * @since 1.0
187      * @javascript Re-compilers must convert the instance invocation of this method directly 
188      * into a JavaScript invocation on its current object instance without changing the 
189      * method name, but expanding variable arguments, if any, into comma-separated values. 
190      */
191     @Override
192     public JsURIError valueOf() {
193         return new JsURIError((JsObject)var().valueOf());
194     }
195 }