Java Javascript Mozilla Library booleanValue(String name, Scriptable scope)

Here you can find the source of booleanValue(String name, Scriptable scope)

Description

Return the boolean value of a JavaScript variable.

License

Open Source License

Parameter

Parameter Description
name the JavaScript variable
scope the JavaScript scope to read from

Return

the value of name

Declaration

static boolean booleanValue(String name, Scriptable scope) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.mozilla.javascript.Context;

import org.mozilla.javascript.Scriptable;

import org.mozilla.javascript.UniqueTag;

public class Main {
    /**//w  w  w . ja v  a 2 s.  com
     * Return the boolean value of a JavaScript variable. If the variable is undefined, <i>false</i> is returned.
     * @param name the JavaScript variable
     * @param scope the JavaScript scope to read from
     * @return the value of <i>name</i>
     */
    static boolean booleanValue(String name, Scriptable scope) {
        Object val = scope.get(name, scope);
        if (val == UniqueTag.NOT_FOUND) {
            return false;
        } else {
            return Context.toBoolean(val);
        }
    }
}

Related

  1. addToScriptable(Scriptable scriptable, String name, Properties props)
  2. asObject(final Scriptable scope, final Map map)
  3. callFn(Function function, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
  4. convertArray(NativeArray jsArray)
  5. convertObject(NativeObject jsObject, Map identities)
  6. copyPropertiesToScriptable(Hashtable properties, Scriptable scriptable)