Java Code Examples for jdk.nashorn.internal.runtime.JSType#toScriptObject()
The following examples show how to use
jdk.nashorn.internal.runtime.JSType#toScriptObject() .
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 jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 2
Source File: NativeObject.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)self; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 3
Source File: NativeObject.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 4
Source File: NativeObject.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 5
Source File: NativeObject.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)self; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 6
Source File: NativeObject.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 7
Source File: NativeObject.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.4.3 Object.prototype.toLocaleString ( ) * * @param self self reference * @return localized ToString */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLocaleString(final Object self) { final Object obj = JSType.toScriptObject(self); if (obj instanceof ScriptObject) { final InvokeByName toStringInvoker = getTO_STRING(); final ScriptObject sobj = (ScriptObject)obj; try { final Object toString = toStringInvoker.getGetter().invokeExact(sobj); if (Bootstrap.isCallable(toString)) { return toStringInvoker.getInvoker().invokeExact(toString, sobj); } } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { throw new RuntimeException(t); } throw typeError("not.a.function", "toString"); } return ScriptRuntime.builtinObjectToString(self); }
Example 8
Source File: ArrayLikeIterator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 9
Source File: ArrayLikeIterator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 10
Source File: ArrayLikeIterator.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory (reverse order) * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> reverseArrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ReverseScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ReverseScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new ReverseJSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new ReverseJavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new ReverseJavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 11
Source File: ArrayLikeIterator.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 12
Source File: ArrayLikeIterator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 13
Source File: ArrayLikeIterator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 14
Source File: ArrayLikeIterator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory (reverse order) * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> reverseArrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ReverseScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ReverseScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new ReverseJSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new ReverseJavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new ReverseJavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 15
Source File: ArrayLikeIterator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory (reverse order) * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> reverseArrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ReverseScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ReverseScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new ReverseJSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new ReverseJavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new ReverseJavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 16
Source File: ArrayLikeIterator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 17
Source File: ArrayLikeIterator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory (reverse order) * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> reverseArrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ReverseScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ReverseScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new ReverseJSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new ReverseJavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new ReverseJavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 18
Source File: ArrayLikeIterator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 19
Source File: ArrayLikeIterator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory (reverse order) * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> reverseArrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ReverseScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ReverseScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new ReverseJSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new ReverseJavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new ReverseJavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }
Example 20
Source File: ArrayLikeIterator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * ArrayLikeIterator factory * @param object object over which to do reverse element iteration * @param includeUndefined should undefined elements be included in the iteration * @return iterator */ public static ArrayLikeIterator<Object> arrayLikeIterator(final Object object, final boolean includeUndefined) { Object obj = object; if (ScriptObject.isArray(obj)) { return new ScriptArrayIterator((ScriptObject) obj, includeUndefined); } obj = JSType.toScriptObject(obj); if (obj instanceof ScriptObject) { return new ScriptObjectIterator((ScriptObject)obj, includeUndefined); } if (obj instanceof JSObject) { return new JSObjectIterator((JSObject)obj, includeUndefined); } if (obj instanceof List) { return new JavaListIterator((List<?>)obj, includeUndefined); } if (obj != null && obj.getClass().isArray()) { return new JavaArrayIterator(obj, includeUndefined); } return new EmptyArrayLikeIterator(); }