Java Code Examples for jdk.nashorn.internal.runtime.JSType#toBoolean()

The following examples show how to use jdk.nashorn.internal.runtime.JSType#toBoolean() . 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: GenericPropertyDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
    if (sobj.has(CONFIGURABLE)) {
        this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
    } else {
        delete(CONFIGURABLE, false);
    }

    if (sobj.has(ENUMERABLE)) {
        this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
    } else {
        delete(ENUMERABLE, false);
    }

    return this;
}
 
Example 2
Source File: NativeJSAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean has(final int key) {
    if (overrides && super.hasOwnProperty(key)) {
        return true;
    }

    return JSType.toBoolean(callAdaptee(Boolean.FALSE, __has__, key));
}
 
Example 3
Source File: NativeBoolean.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.6.2.1 new Boolean (value)
 *
 * @param newObj is the new operator used to instantiate this NativeBoolean
 * @param self   self reference
 * @param value  value of boolean
 * @return the new NativeBoolean
 */
@Constructor(arity = 1)
public static Object constructor(final boolean newObj, final Object self, final Object value) {
    final boolean flag = JSType.toBoolean(value);

    if (newObj) {
        return new NativeBoolean(flag);
    }

    return flag;
}
 
Example 4
Source File: NativeJSAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean delete(final Object key, final boolean strict) {
    if (overrides && super.hasOwnProperty(key)) {
        return super.delete(key, strict);
    }

    return JSType.toBoolean(callAdaptee(Boolean.TRUE, __delete__, key, strict));
}
 
Example 5
Source File: NativeJSAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean has(final double key) {
    if (overrides && super.hasOwnProperty(key)) {
        return true;
    }

    return JSType.toBoolean(callAdaptee(Boolean.FALSE, __has__, key));
}
 
Example 6
Source File: NativeJSAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean delete(final long key, final boolean strict) {
    if (overrides && super.hasOwnProperty(key)) {
        return super.delete(key, strict);
    }

    return JSType.toBoolean(callAdaptee(Boolean.TRUE, __delete__, key, strict));
}
 
Example 7
Source File: DataPropertyDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
    if (sobj.has(CONFIGURABLE)) {
        this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
    } else {
        delete(CONFIGURABLE, false);
    }

    if (sobj.has(ENUMERABLE)) {
        this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
    } else {
        delete(ENUMERABLE, false);
    }

    if (sobj.has(WRITABLE)) {
        this.writable = JSType.toBoolean(sobj.get(WRITABLE));
    } else {
        delete(WRITABLE, false);
    }

    if (sobj.has(VALUE)) {
        this.value = sobj.get(VALUE);
    } else {
        delete(VALUE, false);
    }

    return this;
}
 
Example 8
Source File: NativeJSAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean delete(final double key, final boolean strict) {
    if (overrides && super.hasOwnProperty(key)) {
        return super.delete(key, strict);
    }

    return JSType.toBoolean(callAdaptee(Boolean.TRUE, __delete__, key, strict));
}
 
Example 9
Source File: DataPropertyDescriptor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
    if (sobj.has(CONFIGURABLE)) {
        this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
    } else {
        delete(CONFIGURABLE, false);
    }

    if (sobj.has(ENUMERABLE)) {
        this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
    } else {
        delete(ENUMERABLE, false);
    }

    if (sobj.has(WRITABLE)) {
        this.writable = JSType.toBoolean(sobj.get(WRITABLE));
    } else {
        delete(WRITABLE, false);
    }

    if (sobj.has(VALUE)) {
        this.value = sobj.get(VALUE);
    } else {
        delete(VALUE, false);
    }

    return this;
}
 
Example 10
Source File: AccessorPropertyDescriptor.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isEnumerable() {
    return JSType.toBoolean(enumerable);
}
 
Example 11
Source File: AccessorPropertyDescriptor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isEnumerable() {
    return JSType.toBoolean(enumerable);
}
 
Example 12
Source File: NativeJSAdapter.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isFrozen() {
    return JSType.toBoolean(callAdaptee(Boolean.FALSE, __isFrozen__));
}
 
Example 13
Source File: NativeJSAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isSealed() {
    return JSType.toBoolean(callAdaptee(Boolean.FALSE, __isSealed__));
}
 
Example 14
Source File: DataPropertyDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isEnumerable() {
    return JSType.toBoolean(enumerable);
}
 
Example 15
Source File: NativeJSAdapter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isFrozen() {
    return JSType.toBoolean(callAdaptee(Boolean.FALSE, __isFrozen__));
}
 
Example 16
Source File: GenericPropertyDescriptor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isConfigurable() {
    return JSType.toBoolean(configurable);
}
 
Example 17
Source File: DataPropertyDescriptor.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isConfigurable() {
    return JSType.toBoolean(configurable);
}
 
Example 18
Source File: AccessorPropertyDescriptor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isConfigurable() {
    return JSType.toBoolean(configurable);
}
 
Example 19
Source File: AccessorPropertyDescriptor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isEnumerable() {
    return JSType.toBoolean(enumerable);
}
 
Example 20
Source File: LiteralNode.java    From nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check if the literal value is boolean true
 * @return true if literal value is boolean true
 */
public boolean isTrue() {
    return JSType.toBoolean(value);
}