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#HTMLPreElement} class.</p>
028  * <p>This class represents a preformatted text 
029  * in an HTML page, or a {@link JsHTMLElement} object created with the HTML 
030  * <tt>&lt;pre&gt;</tt> tag which tells browsers that the enclosed text is 
031  * "preformatted".</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  *
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 JsHTMLPreElement extends JsClient.HTMLPreElement.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.HTMLPreElement.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 JsHTMLPreElement#width
060          * @see JsHTMLPreElement.Member#width
061          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
062          */
063         public final static Mid width = id("width");
064     }
065     /**
066      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
067      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
068      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
069      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
070      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
071      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
072      * either circumstance, the field names must be exactly same as the member names, as 
073      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
074      * based on the field names.</p>
075      *
076      * @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>
077      * 
078      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
079      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
080      * of class objects.
081      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
082      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
083      * <pre>q.m</pre>
084      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
085      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
086      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
087      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
088      * <pre>m</pre>
089      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
090      * error on the access to <b>opaque</b> fields declared by this class under any other 
091      * circumstances.
092      */
093     public static class Member extends JsClient.HTMLPreElement.Prototype.Member
094     {
095         /**
096          * <p>Internally constructs a member based on a qualifying member.</p>
097          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
098          * or <b>internal</b> classes or class members.</p>
099          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
100          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
101          * declared in the declaring class of this constructor itself or its subclasses. 
102          * Under this circumstance, the field names must be exactly same as the member 
103          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
104          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
105          * to their names appending to the name resolved from the specified qualifying 
106          * member with a dot in between.</p>
107          * @param q A qualifying member
108          * @param mid The ID of the member to construct
109          * @since 1.0
110          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
111          */
112         public Member(JsObject.Member q, Mid mid) {
113             super(q, mid);
114         }
115         /**
116          * <p>Internally constructs a member without a qualifying member.</p>
117          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
118          * or <b>internal</b> classes or class members.</p>
119          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
120          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
121          * declared in <b>opaque</b> types other than the declaring class of this constructor 
122          * itself and its subclasses. Under this circumstance, the field names must be
123          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
124          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
125          * @param mid The ID of the member to construct
126          * @since 1.0
127          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
128          */
129         public Member(Mid mid) {
130             super(mid);
131         }
132         @Override
133         /**
134          * <p>Evaluates the property, represented by the current member instance, of the
135          * argument object.</p>
136          * @param o The argument object
137          * @return The value of the current member based on the object argument.
138          * @since 1.0
139          * @javascript Re-compilers must convert the instance invocation of this method into
140          * the JavaScript expression: 
141          * <pre>o.m</pre>
142          * where <tt>m</tt> is the identifier name resolved from the current member
143          * instance of the invocation.
144          */
145         public JsHTMLPreElement with(ObjectLike o) {
146             return new JsHTMLPreElement(super.with(o));
147         }
148 
149         /**
150          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
151          * name of this field, qualified by the current member instance of the field, and 
152          * to access the property of the name on an object.</p>
153          * <p>The property, identified by this member, of a {@link JsHTMLPreElement} 
154          * object refers to an integer value that provides a hint to visual browsers 
155          * about the desired width of the formatted block. The browser can use this 
156          * information to select an appropriate font size or to indent the content 
157          * appropriately. The desired width is expressed in number of characters. This 
158          * attribute is not widely supported currently.</p> 
159          * @since 1.0
160          * @javascript Re-compilers must resolve the member of this instance field to the
161          * identifier of the field name appending to the identifier resolved from its 
162          * qualifying member with a dot in between.
163          */
164         public final Value.Number.Member width = new Value.Number.Member(this, Members.width);
165     }
166 
167     /**
168      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
169      * with the wrapping constructor.</p>
170      * @param var The argument of an <b>opaque</b> object.
171      * @since 1.0
172      * @javascript Re-compilers must ignore the construction operation of this constructor,
173      * that is, replacing it with its only argument.
174      */
175     public JsHTMLPreElement(JsObject var) {
176         super(var);
177     }
178 
179     /**
180      * <p>An <b>opaque</b> static field defining a member that is named by the field name
181      * without a qualifying member and to access the property of the name on an object.</p>
182      * <p>The property, identified by this member, of a {@link JsHTMLPreElement} 
183      * object refers to an integer value that provides a hint to visual browsers 
184      * about the desired width of the formatted block. The browser can use this 
185      * information to select an appropriate font size or to indent the content 
186      * appropriately. The desired width is expressed in number of characters. This 
187      * attribute is not widely supported currently.</p> 
188      * @since 1.0
189      * @javascript Re-compilers must resolve the member of this static field to the
190      * identifier of the field name.
191      */
192     public static final Value.Number.Member width = new Value.Number.Member(Members.width);
193 
194     @Override
195     /**
196      * <p>Returns the primitive value associated with the current instance, if there is one.
197      * This invocation simply returns the instance itself for the current instance is an 
198      * object and there is no primitive value for it.</p>
199      * @return The current object itself.
200      * @since 1.0
201      * @javascript Re-compilers must convert the instance invocation of this method directly
202      * into a JavaScript invocation on its current object instance without changing the 
203      * method name, but expanding variable arguments, if any, into comma-separated values. 
204      */
205     public final JsHTMLPreElement valueOf() {
206         return new JsHTMLPreElement((JsObject)var().valueOf());
207     }
208 }