Example usage for jdk.nashorn.internal.objects NativeArray construct

List of usage examples for jdk.nashorn.internal.objects NativeArray construct

Introduction

In this page you can find the example usage for jdk.nashorn.internal.objects NativeArray construct.

Prototype

@SpecializedFunction(isConstructor = true)
public static NativeArray construct(final boolean newObj, final Object self, final double length) 

Source Link

Document

ECMA 15.4.2.2 new Array (len) Specialized constructor for one double argument (length)

Usage

From source file:com.threecrickets.jvm.json.nashorn.NashornJsonImplementation.java

License:Mozilla Public License

public Object createArray(int length) {
    return NativeArray.construct(true, null, length);
}

From source file:com.threecrickets.jvm.json.nashorn.util.NashornNativeUtil.java

License:Mozilla Public License

public static NativeArray newArray(int length) {
    return (NativeArray) NativeArray.construct(false, null, length);
}

From source file:org.bson.jvm.nashorn.NativeArrayCodec.java

License:Apache License

public NativeArray decode(BsonReader reader, DecoderContext decoderContext) {
    List<Object> list = new ArrayList<Object>();

    reader.readStartArray();//from w  w w .java2s . c  om
    while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
        Object item = BsonUtil.read(reader, decoderContext, codecRegistry, bsonTypeClassMap);
        list.add(item);
    }
    reader.readEndArray();

    NativeArray nativeArray = (NativeArray) NativeArray.construct(true, null, list.size());
    int index = 0;
    for (Object item : list)
        nativeArray.set(index++, item, 0);
    return nativeArray;
}