本文整理了Java中com.eclipsesource.v8.V8.getInteger()
方法的一些代码示例,展示了V8.getInteger()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.getInteger()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:getInteger
暂无
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the integer value associated with this key. If the value
* associated with this key does not exist, or if it's not an integer, then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The integer value associated with this key, or V8ResultUndefined
* if the key does not exist or the value is not an integer.
*/
public int getInteger(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
return v8.getInteger(v8.getV8RuntimePtr(), objectHandle, key);
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the integer value associated with this key. If the value
* associated with this key does not exist, or if it's not an integer, then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The integer value associated with this key, or V8ResultUndefined
* if the key does not exist or the value is not an integer.
*/
public int getInteger(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
return v8.getInteger(v8.getV8RuntimePtr(), objectHandle, key);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = V8ResultUndefined.class)
public void testGetIntWrongType() {
v8.executeVoidScript("x = 'foo'");
v8.getInteger("x");
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = V8ResultUndefined.class)
public void testGetIntDoesNotExist() {
v8.executeVoidScript("");
v8.getInteger("x");
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetIntFromDouble() {
v8.executeVoidScript("x = 7.7");
int result = v8.getInteger("x");
assertEquals(7, result);
}
代码示例来源:origin: eclipsesource/J2V8
/*** Get Int ***/
@Test
public void testGetInt() {
v8.executeVoidScript("x = 7");
int result = v8.getInteger("x");
assertEquals(7, result);
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetIntReplaceValue() {
v8.executeVoidScript("x = 7; x = 8");
int result = v8.getInteger("x");
assertEquals(8, result);
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testVoidFunctionCallNullParameters() {
v8.executeVoidScript("function foo() {x=7;}");
v8.executeVoidFunction("foo", null);
assertEquals(7, v8.getInteger("x"));
}
代码示例来源:origin: eclipsesource/J2V8
/*** Void Function ***/
@Test
public void testSimpleVoidFunction() {
v8.executeVoidScript("function foo() {x=1}");
v8.executeVoidFunction("foo", null);
assertEquals(1, v8.getInteger("x"));
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testVoidFunctionCallNoParameters() {
v8.executeVoidScript("function foo() {x=7;}");
V8Array parameters = new V8Array(v8);
v8.executeVoidFunction("foo", parameters);
assertEquals(7, v8.getInteger("x"));
parameters.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testAddGet() {
v8.add("string", "string");
v8.add("int", 7);
v8.add("double", 3.1);
v8.add("boolean", true);
assertEquals("string", v8.getString("string"));
assertEquals(7, v8.getInteger("int"));
assertEquals(3.1, v8.getDouble("double"), 0.00001);
assertTrue(v8.getBoolean("boolean"));
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_win32_x86_64
/**
* Returns the integer value associated with this key. If the value
* associated with this key does not exist, or if it's not an integer, then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The integer value associated with this key, or V8ResultUndefined
* if the key does not exist or the value is not an integer.
*/
public int getInteger(final String key) {
v8.checkThread();
checkReleased();
return v8.getInteger(v8.getV8RuntimePtr(), objectHandle, key);
}
代码示例来源:origin: com.eclipsesource.j2v8/j2v8_macosx_x86_64
/**
* Returns the integer value associated with this key. If the value
* associated with this key does not exist, or if it's not an integer, then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The integer value associated with this key, or V8ResultUndefined
* if the key does not exist or the value is not an integer.
*/
public int getInteger(final String key) {
v8.checkThread();
checkReleased();
return v8.getInteger(v8.getV8RuntimePtr(), objectHandle, key);
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testCreateMatrix() {
V8Array a1 = new V8Array(v8);
V8Array a2 = new V8Array(v8);
V8Array a3 = new V8Array(v8);
a1.push(1);
a1.push(2);
a1.push(3);
a2.push(4);
a2.push(5);
a2.push(6);
a3.push(7);
a3.push(8);
a3.push(9);
V8Array array = new V8Array(v8);
array.push(a1);
array.push(a2);
array.push(a3);
V8Array parameters = new V8Array(v8);
parameters.push(array);
v8.executeVoidScript("var total = 0; function add(matrix) { for(var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { total = total + matrix[i][j]; }}};");
v8.executeVoidFunction("add", parameters);
int result = v8.getInteger("total");
assertEquals(45, result);
a1.close();
a2.close();
a3.close();
array.close();
parameters.close();
}
内容来源于网络,如有侵权,请联系作者删除!