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

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

Introduction

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

Prototype

public Collection<Object> values() 

Source Link

Document

Return the values of the properties in the ScriptObject (java.util.Map-like method to help ScriptObjectMirror implementation)

Usage

From source file:capframework.http.core.ConfigFileParser.java

License:Apache License

private void map(NativeArray array, HashMap<String, String> hashMap, String keyName) {
    for (Object obj : array.values()) {
        JD jd = (JD) obj;//from  ww w  .j  a v  a2 s .  c  om
        String request = String.valueOf(jd.get(keyName));
        String location = String.valueOf(jd.get("Location"));
        hashMap.put(request, location);
    }
}

From source file:org.nuxeo.labs.automation.helpers.JSToJava.java

License:Apache License

/**
 * Receives a JavaScript array, returns a Java ArrayList.
 * Does not handle what's inside the arrays, but it should be Java objects.
 * /*from  ww w. j  av a 2s.  c om*/
 * @param inArray
 * @return
 * @since 7.4
 */
// Example of JavaScript
//
// function run(input, params) {
//
// var doc, i;
// var arr = new Array(0);
//
// doc = Repository.GetDocument(input, {'value': "66dbd6d1-2101-4bb4-ac13-9bd3269ca319"});
// arr.push(doc);
// doc = Repository.GetDocument(input, {'value': "3e2c050d-0446-4f9b-8ef6-885c113afd4f"});
// arr.push(doc);
// doc = Repository.GetDocument(input, {'value': "0fcae6cc-9829-4840-87dc-bcb123df7049"});
// arr.push(doc);
//
// var javaArray = JSToJava.arrayToArrayList(arr);
// // Now, we have a DocumentModelList, available for operations
//
// Log(null, {'level': "warn", 'message': "Test length: " + javaArray.length});
//
// for(i = 0; i < javaArray.length; ++i) {
//   Log(null, {'level': "warn", 'message': "Title: " + javaArray.get(i).getTitle()});
// }
//
// }
public ArrayList<Object> arrayToArrayList(NativeArray inArray) {

    ArrayList<Object> javaArray = new ArrayList<Object>();
    javaArray.addAll(inArray.values());
    return javaArray;
}