aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorattila <none@none>2013-05-20 21:25:14 +0200
committerattila <none@none>2013-05-20 21:25:14 +0200
commit2738aad25245692a5d0154e04a69ca6f7c5b771a (patch)
treeb62087d6e2e82312e8bab9d0c55a32f9d1849e17 /docs
parent31d625bbee1d80600d29ee1d7496e0fffa060661 (diff)
downloadnashorn-2738aad25245692a5d0154e04a69ca6f7c5b771a.tar.gz
8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
Reviewed-by: jlaskey, sundar
Diffstat (limited to 'docs')
-rw-r--r--docs/JavaScriptingProgrammersGuide.html10
-rw-r--r--docs/source/javaarray.js4
2 files changed, 7 insertions, 7 deletions
diff --git a/docs/JavaScriptingProgrammersGuide.html b/docs/JavaScriptingProgrammersGuide.html
index a9af9612..a9803f7f 100644
--- a/docs/JavaScriptingProgrammersGuide.html
+++ b/docs/JavaScriptingProgrammersGuide.html
@@ -616,26 +616,26 @@ print(a[0]);
</pre>
<p>
It is also possible to convert between JavaScript and Java arrays.
-Given a JavaScript array and a Java type, <code>Java.toJavaArray</code> returns a Java array with the same initial contents, and with the specified component type.
+Given a JavaScript array and a Java type, <code>Java.to</code> returns a Java array with the same initial contents, and with the specified array type.
</p>
<pre><code>
var anArray = [1, "13", false]
- var javaIntArray = Java.toJavaArray(anArray, "int")
+ var javaIntArray = Java.to(anArray, "int[]")
print(javaIntArray[0]) // prints 1
print(javaIntArray[1]) // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion
print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
</code></pre>
<p>
-You can use either a string or a type object returned from <code>Java.type()</code> to specify the component type of the array.
+You can use either a string or a type object returned from <code>Java.type()</code> to specify the type of the array.
You can also omit the array type, in which case a <code>Object[]</code> will be created.
</p>
<p>
-Given a Java array or Collection, <code>Java.toJavaScriptArray</code> returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.
+Given a Java array or Collection, <code>Java.from</code> returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.
</p>
<pre><code>
var File = Java.type("java.io.File");
var listCurDir = new File(".").listFiles();
-var jsList = Java.toJavaScriptArray(listCurDir);
+var jsList = Java.from(listCurDir);
print(jsList);
</code></pre>
<hr>
diff --git a/docs/source/javaarray.js b/docs/source/javaarray.js
index a02aa3ca..d0de9124 100644
--- a/docs/source/javaarray.js
+++ b/docs/source/javaarray.js
@@ -40,7 +40,7 @@ print(a[0]);
// convert a script array to Java array
var anArray = [1, "13", false];
-var javaIntArray = Java.toJavaArray(anArray, "int");
+var javaIntArray = Java.to(anArray, "int[]");
print(javaIntArray[0]);// prints 1
print(javaIntArray[1]); // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion
print(javaIntArray[2]);// prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
@@ -48,5 +48,5 @@ print(javaIntArray[2]);// prints 0, as boolean false was converted to number 0 a
// convert a Java array to a JavaScript array
var File = Java.type("java.io.File");
var listCurDir = new File(".").listFiles();
-var jsList = Java.toJavaScriptArray(listCurDir);
+var jsList = Java.from(listCurDir);
print(jsList);