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#DocumentType} class.</p>
028  * <p>This infrequently used class represents the DTD of an XML document. Programmers 
029  * working exclusively with HTML documents never need to use this class.</p>
030  * <p>Because a DTD is not part of a document's content, {@link JsDocumentType} nodes 
031  * never appear in the document tree. If an XML document has a DTD, the {@link JsDocumentType} 
032  * node for that DTD is available through the {@link JsDocument#doctype} property of the 
033  * {@link JsDocument} node.</p>
034  * <p>Although the W3C DOM includes an API for accessing the XML entities and notations 
035  * defined in a DTD, typical web browsers do not parse the DTDs for the documents they 
036  * load, and client-side JavaScript, including JS, can not access those entities and 
037  * notations. For client-side JS programming, this <b>opaque</b> class represents only 
038  * the contents of the <tt>&lt;!DOCTYPE&gt;</tt> tag, not the contents of the DTD file 
039  * it references.</p>
040  * <p>Nodes of this class are immutable and may not be modified in any way.</p>
041  *
042  * @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>
043  *
044  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
045  * generated into the target codes. Re-compilers must exit with error on the operations of
046  * accessing that kind of class objects.
047  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
048  * and <tt>instanceof</tt> to it always <tt>true</tt>.
049  */
050 public class JsDocumentType extends JsClient.DocumentType.Prototype
051 {
052     /**
053      * <p>An <b>internal</b> class containing membership data for its enclosing
054      * opaque class.</p>
055      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
056      * class members.</p>
057      *
058      * @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>
059      * 
060      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
061      */
062     protected static abstract class Members extends JsClient.DocumentType.Prototype.Members
063     {
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 JsDocumentType#internalSubset
069          * @see JsDocumentType.Member#internalSubset
070          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
071          */
072         public final static Mid internalSubset = id("internalSubset");
073         /**
074          * <p>An <b>internal</b> static field defining a member ID of the field name and
075          * used internally to define a member of the same name.</p>
076          * @since 1.0
077          * @see JsDocumentType#name
078          * @see JsDocumentType.Member#name
079          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
080          */
081         public final static Mid name           = id("name"          );
082         /**
083          * <p>An <b>internal</b> static field defining a member ID of the field name and
084          * used internally to define a member of the same name.</p>
085          * @since 1.0
086          * @see JsDocumentType#publicId
087          * @see JsDocumentType.Member#publicId
088          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
089          */
090         public final static Mid publicId       = id("publicId"      );
091         /**
092          * <p>An <b>internal</b> static field defining a member ID of the field name and
093          * used internally to define a member of the same name.</p>
094          * @since 1.0
095          * @see JsDocumentType#systemId
096          * @see JsDocumentType.Member#systemId
097          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
098          */
099         public final static Mid systemId       = id("systemId"      );
100     }
101     /**
102      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
103      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
104      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
105      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
106      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
107      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
108      * either circumstance, the field names must be exactly same as the member names, as 
109      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
110      * based on the field names.</p>
111      *
112      * @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>
113      * 
114      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
115      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
116      * of class objects.
117      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
118      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
119      * <pre>q.m</pre>
120      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
121      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
122      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
123      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
124      * <pre>m</pre>
125      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
126      * error on the access to <b>opaque</b> fields declared by this class under any other 
127      * circumstances.
128      */
129     public static class Member extends JsClient.DocumentType.Prototype.Member
130     {
131         /**
132          * <p>Internally constructs a member based on a qualifying member.</p>
133          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
134          * or <b>internal</b> classes or class members.</p>
135          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
136          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
137          * declared in the declaring class of this constructor itself or its subclasses. 
138          * Under this circumstance, the field names must be exactly same as the member 
139          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
140          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
141          * to their names appending to the name resolved from the specified qualifying 
142          * member with a dot in between.</p>
143          * @param q A qualifying member
144          * @param mid The ID of the member to construct
145          * @since 1.0
146          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
147          */
148         public Member(JsObject.Member q, Mid mid) {
149             super(q, mid);
150         }
151         /**
152          * <p>Internally constructs a member without a qualifying member.</p>
153          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
154          * or <b>internal</b> classes or class members.</p>
155          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
156          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
157          * declared in <b>opaque</b> types other than the declaring class of this constructor 
158          * itself and its subclasses. Under this circumstance, the field names must be
159          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
160          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
161          * @param mid The ID of the member to construct
162          * @since 1.0
163          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
164          */
165         public Member(Mid mid) {
166             super(mid);
167         }
168         @Override
169         /**
170          * <p>Evaluates the property, represented by the current member instance, of the
171          * argument object.</p>
172          * @param o The argument object
173          * @return The value of the current member based on the object argument.
174          * @since 1.0
175          * @javascript Re-compilers must convert the instance invocation of this method into
176          * the JavaScript expression: 
177          * <pre>o.m</pre>
178          * where <tt>m</tt> is the identifier name resolved from the current member
179          * instance of the invocation.
180          */
181         public JsDocumentType with(ObjectLike o) {
182             return new JsDocumentType(super.with(o));
183         }
184 
185         /**
186          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
187          * name of this field, qualified by the current member instance of the field, and 
188          * to access the property of the name on an object.</p>
189          * <p>The property, identified by this member, of a {@link JsDocumentType} 
190          * object is a read-only reference to the unparsed text of the internal subset 
191          * of the DTD, that is, the portion of the DTD that appears in the document 
192          * itself rather than in an external file. The delimiting square brackets of the 
193          * internal subset are not part of the returned value. If there is no internal 
194          * subset, the property is <tt>null</tt>.</p>
195          * @since 1.0
196          * @javascript Re-compilers must resolve the member of this instance field to the
197          * identifier of the field name appending to the identifier resolved from its 
198          * qualifying member with a dot in between.
199          */
200         public final Value.String.Member internalSubset = new Value.String.Member(this, Members.internalSubset);
201         /**
202          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
203          * name of this field, qualified by the current member instance of the field, and 
204          * to access the property of the name on an object.</p>
205          * <p>The property, identified by this member, of a {@link JsDocumentType} 
206          * object is a read-only reference to the name of the document type. It is the 
207          * identifier that immediately follows <tt>&lt;!DOCTYPE&gt;</tt> at the start of 
208          * an XML document and is the same as the tag name of the document's root element.</p>
209          * @since 1.0
210          * @javascript Re-compilers must resolve the member of this instance field to the
211          * identifier of the field name appending to the identifier resolved from its 
212          * qualifying member with a dot in between.
213          */
214         public final Value.String.Member name           = new Value.String.Member(this, Members.name          );
215         /**
216          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
217          * name of this field, qualified by the current member instance of the field, and 
218          * to access the property of the name on an object.</p>
219          * <p>The property, identified by this member, of a {@link JsDocumentType} 
220          * object is a read-only reference to the public identifier of the external 
221          * subset of the DTD, or <tt>null</tt> if none is specified.</p>
222          * @since 1.0
223          * @javascript Re-compilers must resolve the member of this instance field to the
224          * identifier of the field name appending to the identifier resolved from its 
225          * qualifying member with a dot in between.
226          */
227         public final Value.String.Member publicId       = new Value.String.Member(this, Members.publicId      );
228         /**
229          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
230          * name of this field, qualified by the current member instance of the field, and 
231          * to access the property of the name on an object.</p>
232          * <p>The property, identified by this member, of a {@link JsDocumentType} 
233          * object is a read-only reference to the system identifier of the external 
234          * subset of the DTD, or <tt>null</tt> if none is specified.</p>
235          * @since 1.0
236          * @javascript Re-compilers must resolve the member of this instance field to the
237          * identifier of the field name appending to the identifier resolved from its 
238          * qualifying member with a dot in between.
239          */
240         public final Value.String.Member systemId       = new Value.String.Member(this, Members.systemId      );
241     }
242 
243     /**
244      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
245      * with the wrapping constructor.</p>
246      * @param var The argument of an <b>opaque</b> object.
247      * @since 1.0
248      * @javascript Re-compilers must ignore the construction operation of this constructor,
249      * that is, replacing it with its only argument.
250      */
251     public JsDocumentType(JsObject var) {
252         super(var);
253     }
254 
255     /**
256      * <p>An <b>opaque</b> static field defining a member that is named by the field name
257      * without a qualifying member and to access the property of the name on an object.</p>
258      * <p>The property, identified by this member, of a {@link JsDocumentType} 
259      * object is a read-only reference to the unparsed text of the internal subset 
260      * of the DTD, that is, the portion of the DTD that appears in the document 
261      * itself rather than in an external file. The delimiting square brackets of the 
262      * internal subset are not part of the returned value. If there is no internal 
263      * subset, the property is <tt>null</tt>.</p>
264      * @since 1.0
265      * @javascript Re-compilers must resolve the member of this static field to the
266      * identifier of the field name.
267      */
268     public static final Value.String.Member internalSubset = new Value.String.Member(Members.internalSubset);
269     /**
270      * <p>An <b>opaque</b> static field defining a member that is named by the field name
271      * without a qualifying member and to access the property of the name on an object.</p>
272      * <p>The property, identified by this member, of a {@link JsDocumentType} 
273      * object is a read-only reference to the name of the document type. It is the 
274      * identifier that immediately follows <tt>&lt;!DOCTYPE&gt;</tt> at the start of 
275      * an XML document and is the same as the tag name of the document's root element.</p>
276      * @since 1.0
277      * @javascript Re-compilers must resolve the member of this static field to the
278      * identifier of the field name.
279      */
280     public static final Value.String.Member name           = new Value.String.Member(Members.name          );
281     /**
282      * <p>An <b>opaque</b> static field defining a member that is named by the field name
283      * without a qualifying member and to access the property of the name on an object.</p>
284      * <p>The property, identified by this member, of a {@link JsDocumentType} 
285      * object is a read-only reference to the public identifier of the external 
286      * subset of the DTD, or <tt>null</tt> if none is specified.</p>
287      * @since 1.0
288      * @javascript Re-compilers must resolve the member of this static field to the
289      * identifier of the field name.
290      */
291     public static final Value.String.Member publicId       = new Value.String.Member(Members.publicId      );
292     /**
293      * <p>An <b>opaque</b> static field defining a member that is named by the field name
294      * without a qualifying member and to access the property of the name on an object.</p>
295      * <p>The property, identified by this member, of a {@link JsDocumentType} 
296      * object is a read-only reference to the system identifier of the external 
297      * subset of the DTD, or <tt>null</tt> if none is specified.</p>
298      * @since 1.0
299      * @javascript Re-compilers must resolve the member of this static field to the
300      * identifier of the field name.
301      */
302     public static final Value.String.Member systemId       = new Value.String.Member(Members.systemId      );
303 
304     @Override
305     /**
306      * <p>Returns the primitive value associated with the current instance, if there is one.
307      * This invocation simply returns the instance itself for the current instance is an 
308      * object and there is no primitive value for it.</p>
309      * @return The current object itself.
310      * @since 1.0
311      * @javascript Re-compilers must convert the instance invocation of this method directly
312      * into a JavaScript invocation on its current object instance without changing the 
313      * method name, but expanding variable arguments, if any, into comma-separated values. 
314      */
315     public JsDocumentType valueOf() {
316         return new JsDocumentType((JsObject)var().valueOf());
317     }
318 }