01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package jsx.core;
21 
22 import js.Disposable;
23 import js.Js;
24 
25 /**
26  * <p>A utility class providing general operations with its static methods.</p>
27  * <p>Users are encouraged to use the utilities provided by this class instead of the 
28  * <b>opaque</b> methods of {@link js.Js} in consideration of the reuse benefit for 
29  * re-compilation results.</p>
30  * 
31  * @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>
32  */
33 public final class Variables extends Disposable
34 {
35     private Variables() {}
36 
37     /**
38      * <p>Checks if a variable is undefined.</p>
39      * @param v Any value or object.
40      * @return <tt>true</tt> if <tt>v</tt> is undefined; <tt>false</tt>, otherwise.
41      * @since 1.0
42      */
43     public static final boolean undefined(Object v) {
44         return Js.undefined(v);
45     }
46 
47     /**
48      * <p>Checks if a variable is defined.</p>
49      * @param v Any value or object.
50      * @return <tt>true</tt> if <tt>v</tt> is defined; <tt>false</tt>, otherwise.
51      * @since 1.0
52      */
53     public static final boolean defined(Object v) {
54         return Js.defined(v);
55     }
56 
57     /**
58      * <p>Returns a string representation of a variable.</p>
59      * @param v Any value or object.
60      * @return The string representation of the value or object.
61      * @since 1.0
62      */
63     public static final String toString(Object v) {
64         return Js.toString(v);
65     }
66 
67     /**
68      * <p>Returns a string indicating the data-type of the argument.</p>
69      * <p>Simulating the JavaScript <tt>typeof</tt> operator and <tt>typeof()</tt> 
70      * function, this invocation evaluates to "number", "string", or "boolean" if the  
71      * argument is a number, string, or boolean value. It evaluates to "object" for objects 
72      * and arrays. It evaluates to "function" for function instance and to "undefined" if 
73      * the argument is undefined.</p>
74      * @param v Any value or object.
75      * @return A string indicating the data-type of the argument.
76      * @since 1.0
77      */
78     public static final String typeof(Object v) {
79         return Js.typeof(v);
80     }
81 }