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 jsx.client;
021 
022 import js.Field;
023 import js.Disposable;
024 import js.Function;
025 import js.Js;
026 import js.Static;
027 import js.Var;
028 import js.core.JsFunction;
029 import js.core.JsGlobal;
030 import js.core.JsObject;
031 
032 /**
033  * <p>A utility class accessing the objects and simulating the functions of JavaScript 
034  * in global scope without full client-side support.</p>
035  * <p>Users are encouraged to use the utilities and static fields provided in this class 
036  * instead of the <b>opaque</b> methods and the members of the {@link js.Js} class or the 
037  * {@link js.core.JsGlobal} class in consideration of the reuse benefit for re-compilation 
038  * results.</p
039  * 
040  * @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>
041  */
042 public abstract class Global extends Disposable
043 {
044     Global() {}
045 
046     public static Object nullObject() {
047         return Browser.isIE ? null : 0;
048     }
049 
050     /**
051      * <p>Displays a simple message in a dialog box, 
052      * simulating the JavaScript global function of the same name.</p>
053      * <p>In JavaScript, this method displays the specified <tt>message</tt> to the 
054      * user in a dialog box. The dialog box contains an OK button the user can click to 
055      * dismiss it. The dialog box is typically modal, and the call to this function 
056      * typically blocks until the dialog is dismissed.</p>
057      * <p>Perhaps the most common use of this method is to display error messages when the 
058      * user's input to some form element is invalid in some way. The alert dialog box can 
059      * inform the user of the problem and explain what needs to be corrected to avoid the 
060      * problem in the future</p>
061      * <p>The appearance of the dialog box is platform-dependent, but it generally contains 
062      * graphics that indicate an error, warning, or alert message of some kind. While it can 
063      * display any desired message, the alert graphics of the dialog box mean that this 
064      * method is not appropriate for simple informational messages like "Welcome to my blog"</p>
065      * <p>Note that the <tt>message</tt> displayed in the dialog box is a string of 
066      * plain text, not formatted HTML. You can use the newline character "\n" in your strings 
067      * to break your message across multiple lines. You can also do some rudimentary 
068      * formatting using spaces and can approximate horizontal rules with underscore characters, 
069      * but the results depend greatly on the font used in the dialog box and thus are 
070      * system-dependent.</p>
071      * @param message The plain-text (not HTML) string to display in a dialog box popped up 
072      * over the current window.
073      * @see js.Js#alert(Object)
074      * @see Client#alert(Object)
075      * @since 1.0
076      */
077     public static void alert(Object message) {
078         Js.alert(message);
079     }
080     /**
081      * <p>Asks a yes-or-no question with a dialog box, 
082      * simulating the JavaScript global function of the same name.</p>
083      * <p>In JavaScript, this method displays the specified question in a dialog box. The 
084      * dialog box contains OK and Cancel buttons that the user can use to answer the 
085      * question. If the user clicks the OK button, it returns <tt>true</tt>. If the 
086      * user clicks Cancel, it returns <tt>false</tt>.</p>
087      * <p>The dialog box that is displayed by the this method is modal. That is, it blocks 
088      * all user input to the main browser window until the user dismisses the dialog box 
089      * by clicking on the OK or Cancel buttons. Since this method returns a value depending 
090      * on the user's response to the dialog box, JavaScript execution pauses in the call to 
091      * this method, and subsequent statements are not executed until the user responds to 
092      * the dialog box.</p>
093      * <p>There is no way to change the labels that appear in the buttons of the dialog box 
094      * (to make them read Yes and No, for example). Therefore, you should take care to 
095      * phrase your question or message so that OK and Cancel are suitable responses.</p>
096      * @param question The plain-text (not HTML) string to be displayed in the dialog box. 
097      * It should generally express a question you want the user to answer.
098      * @return <tt>true</tt> if the user clicks the OK button; <tt>false</tt> if 
099      * the user clicks the Cancel button.
100      * @see js.Js#confirm(Object)
101      * @see Win#confirm(Object)
102      * @since 1.0
103      */
104     public static boolean confirm(Object question) {
105         return Js.confirm(question);
106     }
107     /**
108      * <p>Asks for simple string input with a dialog box, 
109      * simulating the JavaScript global function of the same name.</p>
110      * <p>This method displays text input field and OK and Cancel buttons in a dialog box. 
111      * Platform-dependent graphics in the dialog box help indicate to the user that an 
112      * input is desired.</p>
113      * <p>If the user clicks the Cancel button, the method returns <tt>null</tt>. If 
114      * the user clicks the OK button, it returns the text currently displayed in the 
115      * input field.</p>
116      * <p>The dialog box that is displayed by this method is modal. That is, it blocks all 
117      * user input to the main browser window until the user dismisses the dialog box by 
118      * clicking on the OK or Cancel buttons. Since this method returns a value depending 
119      * on the user's response to the dialog box, JavaScript execution pauses in the call 
120      * to this method, and subsequent statements are not executed until the user responds 
121      * to the dialog box.</p>
122      * @param message The plain-text (not HTML) string to be displayed in the dialog box. 
123      * It should ask the user to enter the information you want.
124      * @return The string entered by the user, the empty string if the user did not enter 
125      * a string, or <tt>null</tt> if the user clicked Cancel.
126      * @see #prompt(Object, Object)
127      * @see js.Js#prompt(Object)
128      * @see Win#prompt(Object)
129      * @since 1.0
130      */
131     public static String prompt(Object message) {
132         return Js.prompt(message);
133     }
134     /**
135      * <p>Asks for simple string input with a dialog box, 
136      * simulating the JavaScript global function of the same name.</p>
137      * <p>This method displays the specified message in a dialog box that also contains a 
138      * text input field and OK and Cancel buttons. Platform-dependent graphics in the 
139      * dialog box help indicate to the user that an input is desired.</p>
140      * <p>If the user clicks the Cancel button, the method returns <tt>null</tt>. If 
141      * the user clicks the OK button, it returns the text currently displayed in the 
142      * input field.</p>
143      * <p>The dialog box that is displayed by this method is modal. That is, it blocks all 
144      * user input to the main browser window until the user dismisses the dialog box by 
145      * clicking on the OK or Cancel buttons. Since this method returns a value depending 
146      * on the user's response to the dialog box, JavaScript execution pauses in the call 
147      * to this method, and subsequent statements are not executed until the user responds 
148      * to the dialog box.</p>
149      * @param message The plain-text (not HTML) string to be displayed in the dialog box. 
150      * It should ask the user to enter the information you want.
151      * @param defaultInput A string that is displayed as the default input in the dialog 
152      * box. Pass the empty string ("") to make the method display an empty input box.
153      * @return The string entered by the user, the empty string if the user did not enter 
154      * a string, or <tt>null</tt> if the user clicked Cancel.
155      * @see #prompt(Object)
156      * @see js.Js#prompt(Object, Object)
157      * @see Win#prompt(Object, Object)
158      * @since 1.0
159      */
160     public static String prompt(Object message, Object defaultInput) {
161         return Js.prompt(message, defaultInput);
162     }
163     /**
164      * <p>Cancels periodic execution of code, 
165      * simulating the JavaScript global function of the same name.</p>
166      * <p>This method stops the repeated execution of code that was started by a call to 
167      * {@link #setInterval(JsFunction, Number)}. <tt>intervalId</tt> must be the value 
168      * that was returned by a call to {@link #setInterval(JsFunction, Number)}.</p>
169      * @param intervalId The value returned by the corresponding call to {@link #setInterval(JsFunction, Number)}.
170      * @see #setInterval(JsFunction, Number)
171      * @see js.Js#clearInterval(Object)
172      * @see Win#clearInterval(Object)
173      * @see jsx.Interval
174      * @since 1.0
175      */
176     public static void clearInterval(Object intervalId) {
177         Js.clearInterval(intervalId);
178     }
179     /**
180      * <p>Cancels a pending timeout operation, 
181      * simulating the JavaScript global function of the same name.</p>
182      * <p>This method cancels the execution of code that has been deferred with the 
183      * {@link #setTimeout(JsFunction, Number)} method. The <tt>timeoutId</tt> argument 
184      * is a value returned by the call to {@link #setTimeout(JsFunction, Number)} and 
185      * identifies which deferred code to cancel.</p>
186      * @param timeoutId A value returned by {@link #setTimeout(JsFunction, Number)} that 
187      * identifies the timeout to be canceled.
188      * @see #clearTimeout(Object)
189      * @see js.Js#clearTimeout(Object)
190      * @see Win#clearTimeout(Object)
191      * @see jsx.Timeout
192      * @since 1.0
193      */
194     public static void clearTimeout(Object timeoutId ) {
195         Js.clearTimeout(timeoutId);
196     }
197     /**
198      * <p>Executes code at periodic intervals, 
199      * simulating the JavaScript global function of the same name.</p>
200      * <p>Note that the specified function is executed in the context of the Window object, 
201      * that is, the Window object is the value of the <tt>this</tt> keyword of the 
202      * executing context of the function. This is <tt>true</tt> even if the call to 
203      * {@link #setTimeout(JsFunction, Number)} occurred within a function with a longer 
204      * scope chain.</p>
205      * @param f A function to be periodically invoked.
206      * @param interval The interval, in milliseconds, between invocations of the function.
207      * @return A value that can be passed to {@link #clearInterval(Object)} method to 
208      * cancel the periodic execution of the function.
209      * @see #setInterval(JsFunction)
210      * @see #clearInterval(Object)
211      * @see js.Js#setInterval(JsFunction)
212      * @see js.Js#setInterval(JsFunction, Number)
213      * @see Win#setInterval(JsFunction)
214      * @see Win#setInterval(JsFunction, Number)
215      * @see jsx.Interval
216      * @since 1.0
217      */
218     public static Object setInterval(JsFunction<?> f, Number interval) {
219         return Js.setInterval(f, interval);
220     }
221     /**
222      * <p>Executes code at periodic intervals, 
223      * simulating the JavaScript global function of the same name.</p>
224      * <p>Note that the specified function is executed in the context of the Window object, 
225      * that is, the Window object is the value of the <tt>this</tt> keyword of the 
226      * executing context of the function. This is <tt>true</tt> even if the call to 
227      * {@link #setTimeout(JsFunction, Number)} occurred within a function with a longer 
228      * scope chain.</p>
229      * @param f A function to be periodically invoked.
230      * @return A value that can be passed to {@link #clearInterval(Object)} method to 
231      * cancel the periodic execution of the function.
232      * @see #setInterval(JsFunction, Number)
233      * @see #clearInterval(Object)
234      * @see js.Js#setInterval(JsFunction)
235      * @see js.Js#setInterval(JsFunction, Number)
236      * @see Win#setInterval(JsFunction)
237      * @see Win#setInterval(JsFunction, Number)
238      * @see jsx.Interval
239      * @since 1.0
240      */
241     public static Object setInterval(JsFunction<?> f) {
242         return Js.setInterval(f);
243     }
244     /**
245      * <p>Executes code after a specified amount of time elapses, 
246      * simulating the JavaScript global function of the same name.</p>
247      * <p>Note that this method executes the specified function only once. The function is 
248      * executed in the context of the Window object, that is, the Window object is the 
249      * value of the <tt>this</tt> keyword of the executing context of the function. 
250      * This is <tt>true</tt> even if the call to {@link #setTimeout(JsFunction, Number)} 
251      * occurred within a function with a longer scope chain.</p>
252      * @param f A function to be invoked after the <tt>delay</tt> has elapsed.
253      * @param delay The amount of time, in milliseconds, before the function should be executed.
254      * @return A value that can be passed to the {@link #clearTimeout(Object)} method to 
255      * cancel the execution of the function.
256      * @see #setTimeout(JsFunction)
257      * @see #clearTimeout(Object)
258      * @see js.Js#setTimeout(JsFunction)
259      * @see js.Js#setTimeout(JsFunction, Number)
260      * @see Win#setTimeout(JsFunction)
261      * @see Win#setTimeout(JsFunction, Number)
262      * @see jsx.Timeout
263      * @since 1.0
264      */
265     public static Object setTimeout(JsFunction<?> f, Number delay) {
266         return Js.setTimeout(f, delay);
267     }
268     /**
269      * <p>Executes code after an amount of time elapses, 
270      * simulating the JavaScript global function of the same name.</p>
271      * <p>Note that this method executes the specified function only once. The function is 
272      * executed in the context of the Window object, that is, the Window object is the 
273      * value of the <tt>this</tt> keyword of the executing context of the function. 
274      * This is <tt>true</tt> even if the call to {@link #setTimeout(JsFunction, Number)} 
275      * occurred within a function with a longer scope chain.</p>
276      * @param f A function to be invoked after the <tt>delay</tt> has elapsed.
277      * @return A value that can be passed to the {@link #clearTimeout(Object)} method to 
278      * cancel the execution of the function.
279      * @see #setTimeout(JsFunction, Number)
280      * @see #clearTimeout(Object)
281      * @see js.Js#setTimeout(JsFunction)
282      * @see js.Js#setTimeout(JsFunction, Number)
283      * @see Win#setTimeout(JsFunction)
284      * @see Win#setTimeout(JsFunction, Number)
285      * @see jsx.Timeout
286      * @since 1.0
287      */
288     public static Object setTimeout(JsFunction<?> f) {
289         return Js.setTimeout(f);
290     }
291     /**
292      * <p>Decodes a string escaped with {@link #encodeURI(Object)}, 
293      * simulating the JavaScript global function of the same name.</p>
294      * @param s A string that contains an encoded URI or other text to be decoded.
295      * @return A copy of <tt>s</tt>, with any hexadecimal escape sequences replaced with 
296      * the characters they represent.
297      * @throws RuntimeException JavaScript throws a <tt>URIError</tt> if one or more of the 
298      * escape sequences in <tt>s</tt> is malformed and cannot be correctly decoded. See 
299      * {@link Js#err(Object)} and {@link js.core.JsURIError} for JS Simulation.
300      * @see #encodeURI(Object)
301      * @see js.Js#decodeURI(Object)
302      * @see Win#decodeURI(Object)
303      * @since 1.0
304      */
305     public static String decodeURI(Object s) {
306         return Js.decodeURI(s);
307     }
308     /**
309      * <p>Decodes a string escaped with {@link #encodeURIComponent(Object)}, 
310      * simulating the JavaScript global function of the same name.</p>
311      * @param s A string that contains an encoded URI component or other text to be decoded.
312      * @return A copy of <tt>s</tt>, with any hexadecimal escape sequences replaced 
313      * with the characters they represent.
314      * @throws RuntimeException JavaScript throws a <tt>URIError</tt> if one or more of the 
315      * escape sequences in <tt>s</tt> is malformed and cannot be correctly decoded. See 
316      * {@link Js#err(Object)} and {@link js.core.JsURIError} for JS Simulation.
317      * @see #encodeURIComponent(Object)
318      * @see js.Js#decodeURIComponent(Object)
319      * @see Win#decodeURIComponent(Object)
320      * @since 1.0
321      */
322     public static String decodeURIComponent(Object s) {
323         return Js.decodeURIComponent(s);
324     }
325     /**
326      * <p>Encodes a URI by escaping certain characters, 
327      * simulating the JavaScript global function of the same name.</p>
328      * @param uri A string that contains the URI or other text to be encoded.
329      * @return A copy of <tt>uri</tt>, with any hexadecimal escape sequences replaced 
330      * with the characters they represent..
331      * @throws RuntimeException JavaScript throws a <tt>URIError</tt> if <tt>s</tt> 
332      * contains malformed unicode surrogate pairs and cannot be encoded. See 
333      * {@link Js#err(Object)} and {@link js.core.JsURIError} for JS Simulation.
334      * @see #decodeURI(Object)
335      * @see js.Js#encodeURI(Object)
336      * @see Win#encodeURI(Object)
337      * @since 1.0
338      */
339     public static String encodeURI(Object uri) {
340         return Js.encodeURI(uri);
341     }
342     /**
343      * <p>Encodes a URI component by escaping certain characters, 
344      * simulating the JavaScript global function of the same name.</p>
345      * @param uri A string that contains a portion of a URI or other text to be encoded.
346      * @return A copy of <tt>uri</tt>, with certain characters replaced by hexadecimal escape sequences.
347      * @throws RuntimeException JavaScript throws a <tt>URIError</tt> if <tt>s</tt> 
348      * contains malformed unicode surrogate pairs and cannot be encoded. See 
349      * {@link Js#err(Object)} and {@link js.core.JsURIError} for JS Simulation.
350      * @see #decodeURIComponent(Object)
351      * @see js.Js#encodeURIComponent(Object)
352      * @see Win#encodeURIComponent(Object)
353      * @since 1.0
354      */
355     public static String encodeURIComponent(Object uri) {
356         return Js.encodeURIComponent(uri);
357     }
358     /**
359      * <p>Encodes a string by replacing certain characters with escape sequences, 
360      * simulating the JavaScript global function of the same name.</p>
361      * @param s The string that is to be "escaped" or encoded.
362      * @return An encoded copy of <tt>s</tt> in which certain characters have been 
363      * replaced by hexadecimal escape sequences.
364      * @see #unescape(Object)
365      * @see js.Js#escape(Object)
366      * @see Win#escape(Object)
367      * @since 1.0
368      */
369     public static String escape(Object s) {
370         return Js.escape(s);
371     }
372     /**
373      * <p>Decodes a string encoded with {@link #escape(Object)}, 
374      * simulating the JavaScript global function of the same name.</p>
375      * @param s The string that is to be decoded or "unescaped".
376      * @return A decoded copy of <tt>s</tt>.
377      * @see #escape(Object)
378      * @see js.Js#unescape(Object)
379      * @see Win#unescape(Object)
380      * @since 1.0
381      */
382     public static String unescape(Object s) {
383         return Js.unescape(s);
384     }
385     /**
386      * <p>Evaluates the argument string as JavaScript code and returns the result, 
387      * simulating the JavaScript global function of the same name.</p>
388      * <p>In JavaScript, <tt>eval()</tt> is a global method that evaluates a string of 
389      * JavaScript code in the current lexical scope. If the code contains an expression, 
390      * eval evaluates the expression and returns its value. If the code contains a 
391      * JavaScript statement or statements, it executes those statements and returns the 
392      * value, if any, returned by the last statement. If the code does not return any 
393      * value, <tt>eval()</tt> returns undefined. Finally, if code throws an exception, 
394      * <tt>eval()</tt> passes that exception on to the caller.</p>
395      * <p>The global function <tt>eval()</tt> provides a very powerful capability to 
396      * the JavaScript language, but its use is infrequent in real-world programs. 
397      * Obvious uses are to write programs that act as recursive JavaScript interpreters 
398      * and to write programs that dynamically generate and evaluate JavaScript code.</p>
399      * <p>Most JavaScript functions and methods that expect string arguments accept 
400      * arguments of other types as well and simply convert those argument values to 
401      * strings before proceeding. <tt>eval()</tt> does not behave like this. If the 
402      * code argument is not a primitive string, it is simply returned unchanged. Be 
403      * careful, therefore, that you do not inadvertently pass a String object to 
404      * <tt>eval()</tt> when you intended to pass a primitive string value.</p>
405      * <p>For purposes of implementation efficiency, the ECMAScript v3 standard places 
406      * an unusual restriction on the use of <tt>eval()</tt>. An ECMAScript implementation 
407      * is allowed to throw an <tt>EvalError</tt> exception if you attempt to overwrite 
408      * the <tt>eval</tt> property or if you assign the <tt>eval()</tt> method to another 
409      * property and attempt to invoke it through that property.</p>
410      * @param s A string of JavaScript code.
411      * @return The return value of the evaluated code, if any.
412      * @throws RuntimeException JavaScript throws a <tt>SyntaxError</tt> if the argument string 
413      * does not contain legal JavaScript, a <tt>EvalError</tt> if the <tt>eval</tt> function 
414      * was called illegally, through an identifier other than "eval", or other JavaScript error 
415      * generated by the code passed. See {@link Js#err(Object)}, {@link js.core.JsSyntaxError}, 
416      * {@link js.core.JsEvalError}, and {@link js.core.JsError} for JS Simulation.
417      * @since 1.0
418      */
419     public static Object eval(Object s) {
420         return Js.eval(s);
421     }
422     /**
423      * <p>Tests whether a value is a finite number, 
424      * simulating the JavaScript global function of the same name.</p>
425      * @param v The number to be tested.
426      * @return <tt>true</tt> if <tt>v</tt> is (or can be converted to) a finite 
427      * number, or <tt>false</tt> if <tt>v</tt> is <tt>NaN</tt> (not a number) 
428      * or positive or negative infinity.
429      * @see js.Js#isFinite(Object)
430      * @see Win#isFinite(Object)
431      * @since 1.0
432      */
433     public static boolean isFinite(Object v) {
434         return Js.isFinite(v);
435     }
436     /**
437      * <p>Tests whether a value is the not-a-number value, 
438      * simulating the JavaScript global function of the same name.</p>
439      * <p>In JavaScript, This function tests its argument to determine whether it is the 
440      * value <tt>NaN</tt>, which represents an illegal number (such as the result of 
441      * division by zero). This function is required because comparing a <tt>NaN</tt> 
442      * with any value, including itself, always returns <tt>false</tt>, so it is not 
443      * possible to test for <tt>NaN</tt> with the == or === operators.</p>
444      * <p>A common use in JavaScript of this function is to test the results of {@link #parseFloat(Object)} 
445      * and {@link #parseInt(Object)} to determine if they represent legal numbers. You can 
446      * also use {@link #isNaN(Object)} to check for arithmetic errors, such as division by 
447      * zero</p>
448      * @param v The value to be tested.
449      * @return <tt>true</tt> if <tt>v</tt> is (or can be converted to) the special 
450      * not-a-number value; <tt>false</tt> if <tt>v</tt> is any other value.
451      * @see js.Js#isNaN(Object)
452      * @see Win#isNaN(Object)
453      * @since 1.0
454      */
455     public static boolean isNaN(Object v) {
456         return Js.isNaN(v);
457     }
458     /**
459      * <p>Parses an integer from a string, 
460      * simulating the JavaScript global function of the same name.</p>
461      * <p>In JavaScript, this function parses and returns the first number (with an 
462      * optional leading minus sign) that occurs in <tt>value</tt>. Parsing stops, and 
463      * the value is returned, when it encounters a character in <tt>value</tt> that is 
464      * not a valid digit for the specified radix. If <tt>value</tt> does not begin with 
465      * a number that it can parse, the function returns the not-a-number value <tt>NaN</tt>. 
466      * Use the {@link #isNaN(Object)} function to test for this return value.</p>
467      * @param value The string to be parsed.
468      * @return The parsed number, or <tt>NaN</tt> if <tt>value</tt> does not begin with 
469      * a valid integer. In JavaScript 1.0, this function returns 0 instead of <tt>NaN</tt> 
470      * when it cannot parse <tt>value</tt>.
471      * @see #parseFloat(Object)
472      * @see #parseInt(Object, int)
473      * @see js.Js#parseInt(Object)
474      * @see Win#parseInt(Object)
475      * @since 1.0
476      */
477     public static Integer parseInt(Object value) {
478         return Js.parseInt(value);
479     }
480     /**
481      * <p>Parses an integer from a string in a base specified, 
482      * simulating the JavaScript global function of the same name.</p>
483      * <p>In JavaScript, this function parses and returns the first number (with an 
484      * optional leading minus sign) that occurs in <tt>value</tt>. Parsing stops, and 
485      * the value is returned, when it encounters a character in <tt>value</tt> that is 
486      * not a valid digit for the specified radix. If <tt>value</tt> does not begin with 
487      * a number that it can parse, the function returns the not-a-number value <tt>NaN</tt>. 
488      * Use the {@link #isNaN(Object)} function to test for this return value.</p>
489      * <p>The <tt>radix</tt> argument specifies the base of the number to be parsed. 
490      * Specifying 10 makes this function parse a decimal number. The value 8 specifies that 
491      * an octal number (using digits 0 through 7) is to be parsed. The value 16 specifies 
492      * a hexadecimal value, using digits 0 through 9 and letters A through F. <tt>radix</tt> 
493      * can be any value between 2 and 36.</p>
494      * <p>If <tt>radix</tt> is 0 or is undefined, this function tries to determine the 
495      * radix of the number from <tt>value</tt>. If <tt>value</tt> begins (after an 
496      * optional minus sign) with 0x, it parses the remainder of <tt>value</tt> as a 
497      * hexadecimal number. If <tt>value</tt> begins with a 0, the ECMAScript v3 standard 
498      * allows an implementation of this function to interpret the following characters as 
499      * an octal number or as a decimal number. Otherwise, if <tt>value</tt> begins with 
500      * a digit from 1 through 9, it parses it as a decimal number</p>
501      * @param value The string to be parsed.
502      * @param radix An optional integer argument that represents the radix (or base) of the 
503      * number to be parsed. If this argument is undefined or is 0, the number is parsed in 
504      * base 10 or in base 16 if it begins with 0x or 0X. If this argument is less than 2 or 
505      * greater than 36, <tt>NaN</tt> is returned.
506      * @return The parsed number, or <tt>NaN</tt> if <tt>value</tt> does not begin with 
507      * a valid integer. In JavaScript 1.0, this function returns 0 instead of <tt>NaN</tt> 
508      * when it cannot parse <tt>value</tt>.
509      * @see #parseInt(Object)
510      * @see js.Js#parseInt(Object, int)
511      * @see Win#parseInt(Object, int)
512      * @since 1.0
513      */
514     public static Integer parseInt(Object value, int radix) {
515         return Js.parseInt(value, radix);
516     }
517     /**
518      * <p>Parses a number from a string, 
519      * simulating the JavaScript global function of the same name.</p>
520      * <p>In JavaScript, this function parses and returns the first number that occurs in 
521      * <tt>value</tt>. Parsing stops, and the value is returned, when it encounters a 
522      * character in <tt>value</tt> that is not a valid part of the number. If <tt>value</tt> 
523      * does not begin with a number that it can parse, the function returns the not-a-number 
524      * value <tt>NaN</tt>. Test for this return value with the {@link #isNaN(Object)} 
525      * function. If you want to parse only the integer portion of a number, use {@link #parseInt(Object)} 
526      * or {@link #parseInt(Object, int)} instead of this one.</p>
527      * @param value The string to be parsed and converted to a number.
528      * @return The parsed number, or <tt>NaN</tt> if <tt>value</tt> does not begin 
529      * with a valid number. In JavaScript 1.0, this function returns 0 instead of <tt>NaN</tt> 
530      * when <tt>value</tt> cannot be parsed as a number.
531      * @see #parseInt(Object)
532      * @see js.Js#parseFloat(Object)
533      * @see Win#parseFloat(Object)
534      * @since 1.0
535      */
536     public static Double parseFloat(Object value) {
537         return Js.parseFloat(value);
538     }
539 
540     public static JsFunction<Void> function() {
541         return new Function<Void>() {
542             @Override
543             protected Void function(java.lang.Object jsthis, Call<Void> callee) {
544                 return null;
545             }
546         }.var();
547     }
548 
549     /**
550      * <p>Statically accesses the JavaScript global object of the name of this field. 
551      * @see js.core.JsGlobal
552      * @since 1.0
553      */
554     public final static Var<JsGlobal.Array> Array = new Static<JsGlobal.Array>(new Field<JsGlobal.Array>(JsGlobal.Array));
555     /**
556      * <p>Statically accesses the JavaScript global object of the name of this field. 
557      * @see js.core.JsGlobal
558      * @since 1.0
559      */
560     public final static Var<JsGlobal.Boolean> Boolean = new Static<JsGlobal.Boolean>(new Field<JsGlobal.Boolean>(JsGlobal.Boolean));
561     /**
562      * <p>Statically accesses the JavaScript global object of the name of this field. 
563      * @see js.core.JsGlobal
564      * @since 1.0
565      */
566     public final static Var<JsGlobal.Date> Date = new Static<JsGlobal.Date>(new Field<JsGlobal.Date>(JsGlobal.Date));
567     /**
568      * <p>Statically accesses the JavaScript global object of the name of this field. 
569      * @see js.core.JsGlobal
570      * @since 1.0
571      */
572     public final static Var<JsGlobal.Function<JsObject>> Function = new Static<JsGlobal.Function<JsObject>>(new Field<JsGlobal.Function<JsObject>>(JsGlobal.Function));
573     /**
574      * <p>Statically accesses the JavaScript global object of the name of this field. 
575      * @see js.core.JsGlobal
576      * @since 1.0
577      */
578     public final static Var<JsGlobal.Number> Number = new Static<JsGlobal.Number>(new Field<JsGlobal.Number>(JsGlobal.Number));
579     /**
580      * <p>Statically accesses the JavaScript global object of the name of this field. 
581      * @see js.core.JsGlobal
582      * @since 1.0
583      */
584     public final static Var<JsGlobal.Math> Math = new Static<JsGlobal.Math>(new Field<JsGlobal.Math>(JsGlobal.Math));
585     /**
586      * <p>Statically accesses the JavaScript global object of the name of this field. 
587      * @see js.core.JsGlobal
588      * @since 1.0
589      */
590     public final static Var<JsGlobal.Object> Object = new Static<JsGlobal.Object>(new Field<JsGlobal.Object>(JsGlobal.Object));
591     /**
592      * <p>Statically accesses the JavaScript global object of the name of this field. 
593      * @see js.core.JsGlobal
594      * @since 1.0
595      */
596     public final static Var<JsGlobal.RegExp> RegExp = new Static<JsGlobal.RegExp>(new Field<JsGlobal.RegExp>(JsGlobal.RegExp));
597     /**
598      * <p>Statically accesses the JavaScript global object of the name of this field. 
599      * @see js.core.JsGlobal
600      * @since 1.0
601      */
602     public final static Var<JsGlobal.String> String = new Static<JsGlobal.String>(new Field<JsGlobal.String>(JsGlobal.String));
603     /**
604      * <p>Statically accesses the JavaScript global object of the name of this field. 
605      * @see js.core.JsGlobal
606      * @since 1.0
607      */
608     public final static Var<JsGlobal.Error> Error = new Static<JsGlobal.Error>(new Field<JsGlobal.Error>(JsGlobal.Error));
609     /**
610      * <p>Statically accesses the JavaScript global object of the name of this field. 
611      * @see js.core.JsGlobal
612      * @since 1.0
613      */
614     public final static Var<JsGlobal.EvalError> EvalError = new Static<JsGlobal.EvalError>(new Field<JsGlobal.EvalError>(JsGlobal.EvalError));
615     /**
616      * <p>Statically accesses the JavaScript global object of the name of this field. 
617      * @see js.core.JsGlobal
618      * @since 1.0
619      */
620     public final static Var<JsGlobal.RangeError> RangeError = new Static<JsGlobal.RangeError>(new Field<JsGlobal.RangeError>(JsGlobal.RangeError));
621     /**
622      * <p>Statically accesses the JavaScript global object of the name of this field. 
623      * @see js.core.JsGlobal
624      * @since 1.0
625      */
626     public final static Var<JsGlobal.ReferenceError> ReferenceError = new Static<JsGlobal.ReferenceError>(new Field<JsGlobal.ReferenceError>(JsGlobal.ReferenceError));
627     /**
628      * <p>Statically accesses the JavaScript global object of the name of this field. 
629      * @see js.core.JsGlobal
630      * @since 1.0
631      */
632     public final static Var<JsGlobal.SyntaxError> SyntaxError = new Static<JsGlobal.SyntaxError>(new Field<JsGlobal.SyntaxError>(JsGlobal.SyntaxError));
633     /**
634      * <p>Statically accesses the JavaScript global object of the name of this field. 
635      * @see js.core.JsGlobal
636      * @since 1.0
637      */
638     public final static Var<JsGlobal.TypeError> TypeError = new Static<JsGlobal.TypeError>(new Field<JsGlobal.TypeError>(JsGlobal.TypeError));
639     /**
640      * <p>Statically accesses the JavaScript global object of the name of this field. 
641      * @see js.core.JsGlobal
642      * @since 1.0
643      */
644     public final static Var<JsGlobal.URIError> URIError = new Static<JsGlobal.URIError>(new Field<JsGlobal.URIError>(JsGlobal.URIError));
645 }