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#CSSRule} class.</p>
028  * <p>An object of this class represents a rule in a CSS stylesheet. It represents style 
029  * information to be applied to a specific set of document elements.</p>
030  * <p>The DOM Level 2 CSS specification actually defines a complex hierarchy of CSSRule 
031  * interfaces to represent different types of rules that can appear in a CSSStyleSheet. 
032  * Style rules are the most common and most important types of rules in a stylesheet, 
033  * and the property members of this class are the only ones that can be used portably 
034  * across browsers.</p>
035  *
036  * @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>
037  *
038  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
039  * generated into the target codes. Re-compilers must exit with error on the operations of
040  * accessing that kind of class objects.
041  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
042  * and <tt>instanceof</tt> to it always <tt>true</tt>.
043  */
044 public class JsCSSRule extends JsClient.CSSRule.Prototype
045 {
046     /**
047      * <p>An <b>internal</b> class containing membership data for its enclosing
048      * opaque class.</p>
049      * <p>This class is only used inside of <b>opaque</b> or <b>internal</b> classes or
050      * class members.</p>
051      *
052      * @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>
053      * 
054      * @javascript Re-compilers must report error on resolving an <b>internal</b> class.
055      */
056     protected static abstract class Members extends JsClient.CSSRule.Prototype.Members
057     {
058         /**
059          * <p>An <b>internal</b> static field defining a member ID of the field name and
060          * used internally to define a member of the same name.</p>
061          * @since 1.0
062          * @see JsCSSRule#selectorText
063          * @see JsCSSRule.Member#selectorText
064          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
065          */
066         public final static Mid selectorText = id("selectorText");
067         /**
068          * <p>An <b>internal</b> static field defining a member ID of the field name and
069          * used internally to define a member of the same name.</p>
070          * @since 1.0
071          * @see JsCSSRule#style
072          * @see JsCSSRule.Member#style
073          * @javascript Re-compilers must report error on accessing an <b>internal</b> field.
074          */
075         public final static Mid style        = id("style"       );
076     }
077     /**
078      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
079      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
080      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
081      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
082      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
083      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
084      * either circumstance, the field names must be exactly same as the member names, as 
085      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
086      * based on the field names.</p>
087      *
088      * @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>
089      * 
090      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
091      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
092      * of class objects.
093      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
094      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
095      * <pre>q.m</pre>
096      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
097      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
098      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
099      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
100      * <pre>m</pre>
101      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
102      * error on the access to <b>opaque</b> fields declared by this class under any other 
103      * circumstances.
104      */
105     public static class Member extends JsClient.CSSRule.Prototype.Member
106     {
107         /**
108          * <p>Internally constructs a member based on a qualifying member.</p>
109          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
110          * or <b>internal</b> classes or class members.</p>
111          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
112          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
113          * declared in the declaring class of this constructor itself or its subclasses. 
114          * Under this circumstance, the field names must be exactly same as the member 
115          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
116          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
117          * to their names appending to the name resolved from the specified qualifying 
118          * member with a dot in between.</p>
119          * @param q A qualifying member
120          * @param mid The ID of the member to construct
121          * @since 1.0
122          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
123          */
124         public Member(JsObject.Member q, Mid mid) {
125             super(q, mid);
126         }
127         /**
128          * <p>Internally constructs a member without a qualifying member.</p>
129          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
130          * or <b>internal</b> classes or class members.</p>
131          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
132          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
133          * declared in <b>opaque</b> types other than the declaring class of this constructor 
134          * itself and its subclasses. Under this circumstance, the field names must be
135          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
136          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
137          * @param mid The ID of the member to construct
138          * @since 1.0
139          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
140          */
141         public Member(Mid mid) {
142             super(mid);
143         }
144         @Override
145         /**
146          * <p>Evaluates the property, represented by the current member instance, of the
147          * argument object.</p>
148          * @param o The argument object
149          * @return The value of the current member based on the object argument.
150          * @since 1.0
151          * @javascript Re-compilers must convert the instance invocation of this method into
152          * the JavaScript expression: 
153          * <pre>o.m</pre>
154          * where <tt>m</tt> is the identifier name resolved from the current member
155          * instance of the invocation.
156          */
157         public JsCSSRule with(ObjectLike o) {
158             return new JsCSSRule(super.with(o));
159         }
160 
161         /**
162          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
163          * name of this field, qualified by the current member instance of the field, and 
164          * to access the property of the name on an object.</p>
165          * <p>The property, identified by this member, of a {@link JsCSSRule} object 
166          * refers to the selector text that specifies the document elements the style 
167          * rule applies to. Setting the property throws a {@link JsDOMException} with 
168          * its {@link JsDOMException#code} property of the value {@link JsDOMException#NO_MODIFICATION_ALLOWED_ERR} 
169          * if the rule is read-only or the value {@link JsDOMException#SYNTAX_ERR} if 
170          * the new value does not follow CSS syntax rules.</p>
171          * @since 1.0
172          * @javascript Re-compilers must resolve the member of this instance field to the
173          * identifier of the field name appending to the identifier resolved from its 
174          * qualifying member with a dot in between.
175          */
176         public final Value.String.Member selectorText = new Value.String.Member(this, Members.selectorText);
177         /**
178          * <p>An <b>opaque</b> instance field defining a sub-member that is named by the
179          * name of this field, qualified by the current member instance of the field, and 
180          * to access the property of the name on an object.</p>
181          * <p>The property, identified by this member, of a {@link JsCSSRule} object is 
182          * a read-only reference to the style values that should be applied to elements 
183          * specified by {@link #selectorText}.</p>
184          * <p>Note that while the property, identified by this member, is read-only 
185          * itself, the properties of the {@link JsCSS2Properties} object to which it 
186          * refers are read/write.</p>
187          * @since 1.0
188          * @javascript Re-compilers must resolve the member of this instance field to the
189          * identifier of the field name appending to the identifier resolved from its 
190          * qualifying member with a dot in between.
191          */
192         public final JsCSS2Properties.Member style = new JsCSS2Properties.Member(this, Members.style);
193     }
194 
195     /**
196      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
197      * with the wrapping constructor.</p>
198      * @param var The argument of an <b>opaque</b> object.
199      * @since 1.0
200      * @javascript Re-compilers must ignore the construction operation of this constructor,
201      * that is, replacing it with its only argument.
202      */
203     public JsCSSRule(JsObject var) {
204         super(var);
205     }
206 
207     /**
208      * <p>An <b>opaque</b> static field defining a member that is named by the field name
209      * without a qualifying member and to access the property of the name on an object.</p>
210      * <p>The property, identified by this member, of a {@link JsCSSRule} object 
211      * refers to the selector text that specifies the document elements the style 
212      * rule applies to. Setting the property throws a {@link JsDOMException} with 
213      * its {@link JsDOMException#code} property of the value {@link JsDOMException#NO_MODIFICATION_ALLOWED_ERR} 
214      * if the rule is read-only or the value {@link JsDOMException#SYNTAX_ERR} if 
215      * the new value does not follow CSS syntax rules.</p>
216      * @since 1.0
217      * @javascript Re-compilers must resolve the member of this static field to the
218      * identifier of the field name.
219      */
220     public static final Value.String.Member selectorText = new Value.String.Member(Members.selectorText);
221     /**
222      * <p>An <b>opaque</b> static field defining a member that is named by the field name
223      * without a qualifying member and to access the property of the name on an object.</p>
224      * <p>The property, identified by this member, of a {@link JsCSSRule} object is 
225      * a read-only reference to the style values that should be applied to elements 
226      * specified by {@link #selectorText}.</p>
227      * <p>Note that while the property, identified by this member, is read-only 
228      * itself, the properties of the {@link JsCSS2Properties} object to which it 
229      * refers are read/write.</p>
230      * @since 1.0
231      * @javascript Re-compilers must resolve the member of this static field to the
232      * identifier of the field name.
233      */
234     public static final JsCSS2Properties.Member style = new JsCSS2Properties.Member(Members.style);
235 
236     @Override
237     /**
238      * <p>Returns the primitive value associated with the current instance, if there is one.
239      * This invocation simply returns the instance itself for the current instance is an 
240      * object and there is no primitive value for it.</p>
241      * @return The current object itself.
242      * @since 1.0
243      * @javascript Re-compilers must convert the instance invocation of this method directly
244      * into a JavaScript invocation on its current object instance without changing the 
245      * method name, but expanding variable arguments, if any, into comma-separated values. 
246      */
247     public JsCSSRule valueOf() {
248         return new JsCSSRule((JsObject)var().valueOf());
249     }
250 }