001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package js.user;
021 
022 import js.*;
023 import js.core.*;
024 
025 /**
026  * <p>An <b>opaque</b> class representing JavaScript client-side objects of the global 
027  * {@link JsClient#ProcessingInstruction} class.</p>
028  * <p>This class is infrequently used and represents a processing instruction (or PI) 
029  * in an XML document. Programmers working with HTML documents will never encounter a 
030  * {@link JsProcessingInstruction} node</p>
031  *
032  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
033  * @see JsDocument#createProcessingInstruction(String, String)
034  *
035  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
036  * generated into the target codes. Re-compilers must exit with error on the operations of
037  * accessing that kind of class objects.
038  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
039  * and <tt>instanceof</tt> to it always <tt>true</tt>.
040  */
041 public class JsProcessingInstruction extends JsClient.ProcessingInstruction.Prototype
042 {
043     /**
044      * <p>An <b>internal</b> class containing membership data for its enclosing
045      * opaque class.</p>
046      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
047      * class members.</p>
048      *
049      * @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>
050      * 
051      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
052      */
053     protected static abstract class Members extends JsClient.ProcessingInstruction.Prototype.Members
054     {
055         /**
056          * <p>An <b>internal</b> static field defining a member ID of the field name and
057          * used internally to define a member of the same name.</p>
058          * @since 1.0
059          * @see JsProcessingInstruction#data
060          * @see JsProcessingInstruction.Member#data
061          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
062          */
063         public final static Mid data   = id("data"  );
064         /**
065          * <p>An <b>internal</b> static field defining a member ID of the field name and
066          * used internally to define a member of the same name.</p>
067          * @since 1.0
068          * @see JsProcessingInstruction#target
069          * @see JsProcessingInstruction.Member#target
070          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
071          */
072         public final static Mid target = id("target");
073     }
074     /**
075      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
076      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
077      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
078      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
079      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
080      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
081      * either circumstance, the field names must be exactly same as the member names, as 
082      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
083      * based on the field names.</p>
084      *
085      * @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>
086      * 
087      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
088      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
089      * of class objects.
090      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
091      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
092      * <pre>q.m</pre>
093      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
094      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
095      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
096      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
097      * <pre>m</pre>
098      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
099      * error on the access to <b>opaque</b> fields declared by this class under any other 
100      * circumstances.
101      */
102     public static class Member extends JsClient.ProcessingInstruction.Prototype.Member
103     {
104         /**
105          * <p>Internally constructs a member based on a qualifying member.</p>
106          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
107          * or <b>internal</b> classes or class members.</p>
108          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
109          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
110          * declared in the declaring class of this constructor itself or its subclasses. 
111          * Under this circumstance, the field names must be exactly same as the member 
112          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
113          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
114          * to their names appending to the name resolved from the specified qualifying 
115          * member with a dot in between.</p>
116          * @param q A qualifying member
117          * @param mid The ID of the member to construct
118          * @since 1.0
119          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
120          */
121         public Member(JsObject.Member q, Mid mid) {
122             super(q, mid);
123         }
124         /**
125          * <p>Internally constructs a member without a qualifying member.</p>
126          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
127          * or <b>internal</b> classes or class members.</p>
128          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
129          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
130          * declared in <b>opaque</b> types other than the declaring class of this constructor 
131          * itself and its subclasses. Under this circumstance, the field names must be
132          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
133          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
134          * @param mid The ID of the member to construct
135          * @since 1.0
136          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
137          */
138         public Member(Mid mid) {
139             super(mid);
140         }
141         @Override
142         /**
143          * <p>Evaluates the property, represented by the current member instance, of the
144          * argument object.</p>
145          * @param o The argument object
146          * @return The value of the current member based on the object argument.
147          * @since 1.0
148          * @javascript Re-compilers must convert the instance invocation of this method into
149          * the JavaScript expression: 
150          * <pre>o.m</pre>
151          * where <tt>m</tt> is the identifier name resolved from the current member
152          * instance of the invocation.
153          */
154         public JsProcessingInstruction with(ObjectLike o) {
155             return new JsProcessingInstruction(super.with(o));
156         }
157 
158         /**
159          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
160          * name of this field, qualified by the current member instance of the field, and 
161          * to access the property of the name on an object.</p>
162          * @since 1.0
163          * <p>The property, identified by this member, of a {@link JsProcessingInstruction} object 
164          * refers to the content of the processing instruction , that is, the first non-space 
165          * character after the target up to but not including the closing ?&gt;.</p> 
166          * @javascript Re-compilers must resolve the member of this instance field to the
167          * identifier of the field name appending to the identifier resolved from its 
168          * qualifying member with a dot in between.
169          */
170         public final Value.String.Member data   = new Value.String.Member(this, Members.data  );
171         /**
172          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
173          * name of this field, qualified by the current member instance of the field, and 
174          * to access the property of the name on an object.</p>
175          * <p>The property, identified by this member, of a {@link JsProcessingInstruction} object 
176          * refers to a read-only string that specifies the target of the processing 
177          * instruction. This is the first identifier that follows the opening &lt;? and 
178          * specifies the "processor" for which the processing instruction is intended.</p>
179          * @since 1.0
180          * @javascript Re-compilers must resolve the member of this instance field to the
181          * identifier of the field name appending to the identifier resolved from its 
182          * qualifying member with a dot in between.
183          */
184         public final Value.String.Member target = new Value.String.Member(this, Members.target);
185     }
186 
187     /**
188      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
189      * with the wrapping constructor.</p>
190      * @param var The argument of an <b>opaque</b> object.
191      * @since 1.0
192      * @javascript Re-compilers must ignore the construction operation of this constructor,
193      * that is, replacing it with its only argument.
194      */
195     public JsProcessingInstruction(JsObject var) {
196         super(var);
197     }
198 
199     /**
200      * <p>An <b>opaque</b> static field defining a member that is named by the field name
201      * without a qualifying member and to access the property of the name on an object.</p>
202      * <p>The property, identified by this member, of a {@link JsProcessingInstruction} object 
203      * refers to the content of the processing instruction , that is, the first non-space 
204      * character after the target up to but not including the closing ?&gt;.</p> 
205      * @since 1.0
206      * @javascript Re-compilers must resolve the member of this static field to the
207      * identifier of the field name.
208      */
209     public static final Value.String.Member data   = new Value.String.Member(Members.data  );
210     /**
211      * <p>An <b>opaque</b> static field defining a member that is named by the field name
212      * without a qualifying member and to access the property of the name on an object.</p>
213      * <p>The property, identified by this member, of a {@link JsProcessingInstruction} object 
214      * refers to a read-only string that specifies the target of the processing 
215      * instruction. This is the first identifier that follows the opening &lt;? and 
216      * specifies the "processor" for which the processing instruction is intended.</p>
217      * @since 1.0
218      * @javascript Re-compilers must resolve the member of this static field to the
219      * identifier of the field name.
220      */
221     public static final Value.String.Member target = new Value.String.Member(Members.target);
222 
223     @Override
224     /**
225      * <p>Returns the primitive value associated with the current instance, if there is one.
226      * This invocation simply returns the instance itself for the current instance is an 
227      * object and there is no primitive value for it.</p>
228      * @return The current object itself.
229      * @since 1.0
230      * @javascript Re-compilers must convert the instance invocation of this method directly
231      * into a JavaScript invocation on its current object instance without changing the 
232      * method name, but expanding variable arguments, if any, into comma-separated values. 
233      */
234     public JsProcessingInstruction valueOf() {
235         return new JsProcessingInstruction((JsObject)var().valueOf());
236     }
237 }