Example usage for jdk.nashorn.internal.runtime JSType toBoolean

List of usage examples for jdk.nashorn.internal.runtime JSType toBoolean

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime JSType toBoolean.

Prototype

public static boolean toBoolean(final Object obj) 

Source Link

Document

JavaScript compliant conversion of Object to boolean See ECMA 9.2 ToBoolean

Usage

From source file:com.eas.client.RemoteServerModulesProxy.java

private ServerModuleInfo readInfo(String aModuleName, JSObject jsProxy) {
    Set<String> functions = new HashSet<>();
    JSObject jsFunctions = (JSObject) jsProxy.getMember(CREATE_MODULE_RESPONSE_FUNCTIONS_PROP);
    int length = JSType.toInteger(jsFunctions.getMember(LENGTH_PROP_NAME));
    for (int i = 0; i < length; i++) {
        String fName = JSType.toString(jsFunctions.getSlot(i));
        functions.add(fName);/*from   ww  w  .ja va2  s.c om*/
    }
    boolean permitted = JSType.toBoolean(jsProxy.getMember(CREATE_MODULE_RESPONSE_IS_PERMITTED_PROP));
    return new ServerModuleInfo(aModuleName, functions, permitted);
}

From source file:com.eas.client.threetier.json.FieldsJSONReader.java

public static void readFields(JSObject pa, Fields aFields) {
    int length = JSType.toInteger(pa.getMember("length"));
    for (int i = 0; i < length; i++) {
        JSObject po = (JSObject) pa.getSlot(i);
        assert po != null;
        String name = JSType.toString(po.getMember(NAME_PROP_NAME));
        String desc = JSType.toString(po.getMember(DESCRIPTION_PROP_NAME));

        String type = po.hasMember(TYPE_PROP_NAME) && po.getMember(TYPE_PROP_NAME) != null
                ? JSType.toString(po.getMember(TYPE_PROP_NAME))
                : null;/*from   w  ww . j  a v a2 s.  c om*/
        boolean pk = JSType.toBoolean(po.getMember(PK_PROP_NAME));
        boolean nullable = JSType.toBoolean(po.getMember(NULLABLE_PROP_NAME));
        Field f = aFields instanceof Parameters ? new Parameter(name) : new Field(name);
        f.setDescription(desc);
        f.setType(type);
        f.setPk(pk);
        f.setNullable(nullable);
        aFields.add(f);
    }
}