当前位置: 首页>>代码示例>>Java>>正文


Java ScriptObject.isArray方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptObject.isArray方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptObject.isArray方法的具体用法?Java ScriptObject.isArray怎么用?Java ScriptObject.isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.runtime.ScriptObject的用法示例。


在下文中一共展示了ScriptObject.isArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrap

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Make a script object mirror on given object if needed.
 *
 * @param obj object to be wrapped/converted
 * @param homeGlobal global to which this object belongs.
 * @param jsonCompatible if true, the created wrapper will implement the Java {@code List} interface if
 * {@code obj} is a JavaScript {@code Array} object. Arrays retrieved through its properties (transitively)
 * will also implement the list interface.
 * @return wrapped/converted object
 */
private static Object wrap(final Object obj, final Object homeGlobal, final boolean jsonCompatible) {
    if(obj instanceof ScriptObject) {
        if (!(homeGlobal instanceof Global)) {
            return obj;
        }
        final ScriptObject sobj = (ScriptObject)obj;
        final Global global = (Global)homeGlobal;
        final ScriptObjectMirror mirror = new ScriptObjectMirror(sobj, global, jsonCompatible);
        if (jsonCompatible && sobj.isArray()) {
            return new JSONListAdapter(mirror, global);
        }
        return mirror;
    } else if(obj instanceof ConsString) {
        return obj.toString();
    } else if (jsonCompatible && obj instanceof ScriptObjectMirror) {
        // Since choosing JSON compatible representation is an explicit decision on user's part, if we're asked to
        // wrap a mirror that was not JSON compatible, explicitly create its compatible counterpart following the
        // principle of least surprise.
        return ((ScriptObjectMirror)obj).asJSONCompatible();
    }
    return obj;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:ScriptObjectMirror.java

示例2: arrayLikeIterator

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ArrayLikeIterator.java

示例3: reverseArrayLikeIterator

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ArrayLikeIterator.java

示例4: isArrayWithDefaultToString

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private static boolean isArrayWithDefaultToString(final Object result, final Global global) {
    if (result instanceof ScriptObject) {
        final ScriptObject sobj = (ScriptObject) result;
        return sobj.isArray() && sobj.get("toString") == global.getArrayPrototype().get("toString");
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Shell.java

示例5: bulkable

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Determine if Java bulk array operations may be used on the underlying
 * storage. This is possible only if the object's prototype chain is empty
 * or each of the prototypes in the chain is empty.
 *
 * @param self the object to examine
 * @return true if optimizable
 */
private static boolean bulkable(final ScriptObject self) {
    return self.isArray() && !hasInheritedArrayEntries(self) && !self.isLengthNotWritable();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:NativeArray.java


注:本文中的jdk.nashorn.internal.runtime.ScriptObject.isArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。