Java Code Examples for jdk.nashorn.api.scripting.ScriptObjectMirror#getOwnKeys()

The following examples show how to use jdk.nashorn.api.scripting.ScriptObjectMirror#getOwnKeys() . 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: NativeObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 2
Source File: NativeObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 3
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 4
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 5
Source File: NativeObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 6
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 7
Source File: NativeObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 8
Source File: NativeObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 9
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 10
Source File: NativeObject.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.2.3.14 Object.keys ( O )
 *
 * @param self self reference
 * @param obj  object from which to extract keys
 * @return array of keys in object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object keys(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject)obj;
        return new NativeArray(sobj.getOwnKeys(false));
    } else if (obj instanceof ScriptObjectMirror) {
        final ScriptObjectMirror sobjMirror = (ScriptObjectMirror)obj;
        return new NativeArray(sobjMirror.getOwnKeys(false));
    } else {
        throw notAnObject(obj);
    }
}
 
Example 11
Source File: ConversionTestBase.java    From vertx-codetrans with Apache License 2.0 5 votes vote down vote up
public JsonObject unwrapJsonObject(ScriptObjectMirror obj) {
  JsonObject unwrapped = new JsonObject();
  for (String key : obj.getOwnKeys(true)) {
    Object value = obj.get(key);
    if (value instanceof ScriptObjectMirror) {
      value = unwrapJsonElement((ScriptObjectMirror) value);
    }
    unwrapped.put(key, value);
  }
  return unwrapped;
}