org.mozilla.javascript.annotations.JSConstructor Java Examples

The following examples show how to use org.mozilla.javascript.annotations.JSConstructor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: File.java    From astor with GNU General Public License v2.0 10 votes vote down vote up
/**
 * The Java method defining the JavaScript File constructor.
 *
 * If the constructor has one or more arguments, and the
 * first argument is not undefined, the argument is converted
 * to a string as used as the filename.<p>
 *
 * Otherwise System.in or System.out is assumed as appropriate
 * to the use.
 */
@JSConstructor
public static Scriptable jsConstructor(Context cx, Object[] args,
                                       Function ctorObj,
                                       boolean inNewExpr)
{
    File result = new File();
    if (args.length == 0 || args[0] == Context.getUndefinedValue()) {
        result.name = "";
        result.file = null;
    } else {
        result.name = Context.toString(args[0]);
        result.file = new java.io.File(result.name);
    }
    return result;
}
 
Example #2
Source File: DefineClassTest.java    From rhino-android with Apache License 2.0 5 votes vote down vote up
@JSConstructor
public void jsConstructorMethod() {
    put("initialized", this, Boolean.TRUE);
}
 
Example #3
Source File: Counter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@JSConstructor
public Counter(int a) { count = a; }