Example usage for jdk.nashorn.internal.runtime Undefined getEmpty

List of usage examples for jdk.nashorn.internal.runtime Undefined getEmpty

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime Undefined getEmpty.

Prototype

public static Undefined getEmpty() 

Source Link

Document

Get the value of empty .

Usage

From source file:com.mckoi.mwpui.nodejs.nashorn.NashornJSSystem.java

License:Open Source License

/**
 * Wraps the given Nashorn Object as a GJSObject.
 * //w  ww .ja v a2 s . c  o  m
 * @param js_object
 * @return 
 */
final Object wrapAsGJS(Object nashorn_value) {
    if (nashorn_value == null) {
        return null;
    } else if (nashorn_value == Undefined.getUndefined() || nashorn_value == Undefined.getEmpty()) {
        return GJSStatics.UNDEFINED;
    } else if (nashorn_value instanceof CharSequence) {
        return nashorn_value.toString();
    } else if (nashorn_value instanceof Number || nashorn_value instanceof Boolean) {
        return nashorn_value;
    }
    // Wrap ScriptObject,
    if (nashorn_value instanceof ScriptObject) {
        nashorn_value = instance_global.wrap((ScriptObject) nashorn_value);
    }
    if (nashorn_value instanceof JSObject) {
        JSObject nashorn_object = (JSObject) nashorn_value;
        GJSObject gjs_ob = getGJSFromNative(nashorn_object);
        if (gjs_ob == null) {
            gjs_ob = new NashornGJSObjectWrap(this, nashorn_object);
        }
        return gjs_ob;
    } else if (nashorn_value instanceof NashornException) {
        return wrappedGJSException((NashornException) nashorn_value);
    } else {
        return nashorn_value;
        //      throw new GJavaScriptException("Unable to convert Nashorn value: " +
        //                                                  (nashorn_value.getClass()));
    }

}