本文整理了Java中com.eclipsesource.v8.V8Array.getDoubles()
方法的一些代码示例,展示了V8Array.getDoubles()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8Array.getDoubles()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8Array
类名称:V8Array
方法名:getDoubles
[英]Returns the doubles contained in a subset of a V8Array. If the subset contains elements other than doubles, then a V8ResultUndefined exception is thrown. Furthermore, if the subset is not entirely contained within the array, then V8ResultUndefined exception is also thrown.
[中]返回包含在V8Array子集中的双精度数。如果子集包含除double之外的元素,则会引发V8ResultUndefined异常。此外,如果子集不完全包含在数组中,那么也会抛出V8ResultUndefined异常。
代码示例来源:origin: eclipsesource/J2V8
/**
* Creates a Java array from a V8Array. The type of the Array must be specified.
* Currently, only INTEGER, DOUBLE, BOOLEAN and STRING are supported.
* The V8Array must only contain elements of type 'arrayType'.
*
* This method will use J2V8's bulk array copy making it faster than iterating over
* all the elements in the array.
*
* @param array The V8Array to convert to a Java Array.
* @param arrayType The type of the V8Array to convert.
*
* @return A Java array representing a V8Array.
*/
public static Object getTypedArray(final V8Array array, final int arrayType) {
int length = array.length();
if (arrayType == V8Value.INTEGER) {
return array.getIntegers(0, length);
} else if (arrayType == V8Value.DOUBLE) {
return array.getDoubles(0, length);
} else if (arrayType == V8Value.BOOLEAN) {
return array.getBooleans(0, length);
} else if (arrayType == V8Value.STRING) {
return array.getStrings(0, length);
}
throw new RuntimeException("Unsupported bulk load type: " + arrayType);
}
代码示例来源:origin: eclipsesource/J2V8
doubleArray = new double[length];
array.getDoubles(0, length, doubleArray);
return doubleArray;
} else if (arrayType == V8Value.BOOLEAN) {
代码示例来源:origin: eclipsesource/J2V8
/**
* Creates a Java array from a V8Array. The type of the Array must be specified.
* Currently, only INTEGER, DOUBLE, BOOLEAN and STRING are supported.
* The V8Array must only contain elements of type 'arrayType'.
*
* This method will use J2V8's bulk array copy making it faster than iterating over
* all the elements in the array.
*
* @param array The V8Array to convert to a Java Array.
* @param arrayType The type of the V8Array to convert.
*
* @return A Java array representing a V8Array.
*/
public static Object getTypedArray(final V8Array array, final int arrayType) {
int length = array.length();
if (arrayType == V8Value.INTEGER) {
return array.getIntegers(0, length);
} else if (arrayType == V8Value.DOUBLE) {
return array.getDoubles(0, length);
} else if (arrayType == V8Value.BOOLEAN) {
return array.getBooleans(0, length);
} else if (arrayType == V8Value.STRING) {
return array.getStrings(0, length);
}
throw new RuntimeException("Unsupported bulk load type: " + arrayType);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testGetDoubles2Undefined() {
V8Array undefined = v8.getArray("array");
undefined.getDoubles(0, 1, new double[1]);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testGetDoublesUndefined() {
V8Array undefined = v8.getArray("array");
undefined.getDoubles(0, 1);
}
代码示例来源:origin: eclipsesource/J2V8
doubleArray = new double[length];
array.getDoubles(0, length, doubleArray);
return doubleArray;
} else if (arrayType == V8Value.BOOLEAN) {
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = IndexOutOfBoundsException.class)
public void testGetDoublesSmallerArray() {
V8Array a = v8.executeArrayScript("[1,2,3.3,4.4]");
double[] result = new double[3];
try {
a.getDoubles(0, 4, result);
} finally {
a.close();
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetDoubleSameSizeArray() {
V8Array a = v8.executeArrayScript("[1,2.2,3.3,4]");
double[] result = new double[4];
int size = a.getDoubles(0, 4, result);
assertEquals(4, size);
a.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetDoublesBiggerArray() {
V8Array a = v8.executeArrayScript("[1.1,2.2,3,4]");
double[] result = new double[40];
int size = a.getDoubles(0, 4, result);
assertEquals(4, size);
a.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetSubArrayOfDoubles() {
V8Array a = v8.executeArrayScript("[1.1,2.1,3.1,4.1,5.1];");
double[] result = a.getDoubles(4, 1);
assertEquals(1, result.length);
assertEquals(5.1, result[0], 0.000001);
a.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetSubArrayOfDoubles2() {
V8Array a = v8.executeArrayScript("[1.1,2.1,3.1,4.1,5.1];");
double[] result = a.getDoubles(3, 2);
assertEquals(2, result.length);
assertEquals(4.1, result[0], 0.000001);
assertEquals(5.1, result[1], 0.000001);
a.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetDoublesPopulatesArray() {
V8Array a = v8.executeArrayScript("[1.1,2.2,3.3,4]");
double[] result = new double[4];
a.getDoubles(0, 4, result);
assertEquals(1.1, result[0], 0.000001);
assertEquals(2.2, result[1], 0.000001);
assertEquals(3.3, result[2], 0.000001);
assertEquals(4, result[3], 0.000001);
a.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetArrayOfDoubles() {
V8Array a = v8.executeArrayScript("[1.1,2.1,3.1,4.1,5.1];");
double[] result = a.getDoubles(0, 5);
assertEquals(5, result.length);
assertEquals(1.1, result[0], 000001);
assertEquals(2.1, result[1], 000001);
assertEquals(3.1, result[2], 000001);
assertEquals(4.1, result[3], 000001);
assertEquals(5.1, result[4], 000001);
a.close();
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_win32_x86_64
/**
* Creates a Java array from a V8Array. The type of the Array must be specified.
* Currently, only INTEGER, DOUBLE, BOOLEAN and STRING are supported.
* The V8Array must only contain elements of type 'arrayType'.
*
* This method will use J2V8's bulk array copy making it faster than iterating over
* all the elements in the array.
*
* @param array The V8Array to convert to a Java Array.
* @param arrayType The type of the V8Array to convert.
*
* @return A Java array representing a V8Array.
*/
public static Object getTypedArray(final V8Array array, final int arrayType) {
int length = array.length();
if (arrayType == V8Value.INTEGER) {
return array.getIntegers(0, length);
} else if (arrayType == V8Value.DOUBLE) {
return array.getDoubles(0, length);
} else if (arrayType == V8Value.BOOLEAN) {
return array.getBooleans(0, length);
} else if (arrayType == V8Value.STRING) {
return array.getStrings(0, length);
}
throw new RuntimeException("Unsupported bulk load type: " + arrayType);
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_macosx_x86_64
/**
* Creates a Java array from a V8Array. The type of the Array must be specified.
* Currently, only INTEGER, DOUBLE, BOOLEAN and STRING are supported.
* The V8Array must only contain elements of type 'arrayType'.
*
* This method will use J2V8's bulk array copy making it faster than iterating over
* all the elements in the array.
*
* @param array The V8Array to convert to a Java Array.
* @param arrayType The type of the V8Array to convert.
*
* @return A Java array representing a V8Array.
*/
public static Object getTypedArray(final V8Array array, final int arrayType) {
int length = array.length();
if (arrayType == V8Value.INTEGER) {
return array.getIntegers(0, length);
} else if (arrayType == V8Value.DOUBLE) {
return array.getDoubles(0, length);
} else if (arrayType == V8Value.BOOLEAN) {
return array.getBooleans(0, length);
} else if (arrayType == V8Value.STRING) {
return array.getStrings(0, length);
}
throw new RuntimeException("Unsupported bulk load type: " + arrayType);
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_win32_x86_64
doubleArray = new double[length];
array.getDoubles(0, length, doubleArray);
return doubleArray;
} else if (arrayType == V8Value.BOOLEAN) {
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_macosx_x86_64
doubleArray = new double[length];
array.getDoubles(0, length, doubleArray);
return doubleArray;
} else if (arrayType == V8Value.BOOLEAN) {
内容来源于网络,如有侵权,请联系作者删除!