本文整理匯總了Java中org.mozilla.javascript.ScriptableObject.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java ScriptableObject.getProperty方法的具體用法?Java ScriptableObject.getProperty怎麽用?Java ScriptableObject.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mozilla.javascript.ScriptableObject
的用法示例。
在下文中一共展示了ScriptableObject.getProperty方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testJsApi
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
public void testJsApi() throws Exception {
Context cx = Context.enter();
cx.setOptimizationLevel(-1);
Script script = cx.compileReader(new InputStreamReader(
Bug482203.class.getResourceAsStream("conttest.js")),
"", 1, null);
Scriptable scope = cx.initStandardObjects();
script.exec(cx, scope);
for(;;)
{
Object cont = ScriptableObject.getProperty(scope, "c");
if(cont == null)
{
break;
}
((Callable)cont).call(cx, scope, scope, new Object[] { null });
}
}
示例2: testJavaApi
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
public void testJavaApi() throws Exception {
Context cx = Context.enter();
try {
cx.setOptimizationLevel(-1);
Script script = cx.compileReader(new InputStreamReader(
Bug482203.class.getResourceAsStream("conttest.js")),
"", 1, null);
Scriptable scope = cx.initStandardObjects();
cx.executeScriptWithContinuations(script, scope);
for(;;)
{
Object cont = ScriptableObject.getProperty(scope, "c");
if(cont == null)
{
break;
}
cx.resumeContinuation(cont, scope, null);
}
} finally {
Context.exit();
}
}
示例3: createFields
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Benchmark
@SuppressWarnings("unused")
void createFields(int count)
{
Function create = (Function)ScriptableObject.getProperty(scope, "createObject");
create.call(cx, scope, null, new Object[]{count, strings, ints});
}
示例4: accessFields
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Benchmark
@SuppressWarnings("unused")
void accessFields(int count)
{
Function create = (Function)ScriptableObject.getProperty(scope, "createObject");
Object o = create.call(cx, scope, null, new Object[]{1, strings, ints});
Function access = (Function)ScriptableObject.getProperty(scope, "accessObject");
access.call(cx, scope, null, new Object[] {count, o, strings, ints});
}
示例5: iterateFields
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Benchmark
@SuppressWarnings("unused")
void iterateFields(long count)
{
Function create = (Function)ScriptableObject.getProperty(scope, "createObject");
Object o = create.call(cx, scope, null, new Object[]{1, strings, ints});
Function iterate = (Function)ScriptableObject.getProperty(scope, "iterateObject");
iterate.call(cx, scope, null, new Object[] {count, o});
}
示例6: ownKeysFields
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Benchmark
@SuppressWarnings("unused")
void ownKeysFields(long count)
{
Function create = (Function)ScriptableObject.getProperty(scope, "createObject");
Object o = create.call(cx, scope, null, new Object[]{1, strings, ints});
Function iterate = (Function)ScriptableObject.getProperty(scope, "iterateOwnKeysObject");
iterate.call(cx, scope, null, new Object[] {count, o});
}
示例7: deleteFields
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Benchmark
@SuppressWarnings("unused")
void deleteFields(int count)
{
Function create = (Function)ScriptableObject.getProperty(scope, "createObject");
Object o = create.call(cx, scope, null, new Object[]{1, strings, ints});
Function delete = (Function)ScriptableObject.getProperty(scope, "deleteObject");
delete.call(cx, scope, null, new Object[] {count, o, strings, ints});
}
示例8: testJsApi
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
public void testJsApi() throws Exception {
Context cx = RhinoAndroidHelper.prepareContext();
try {
cx.setOptimizationLevel(-1);
Script script = cx.compileString(TestUtils.readAsset("Bug482203.js"),
"", 1, null);
Scriptable scope = cx.initStandardObjects();
script.exec(cx, scope);
int counter = 0;
for(;;)
{
Object cont = ScriptableObject.getProperty(scope, "c");
if(cont == null)
{
break;
}
counter++;
((Callable)cont).call(cx, scope, scope, new Object[] { null });
}
assertEquals(counter, 5);
assertEquals(Double.valueOf(3), ScriptableObject.getProperty(scope, "result"));
} finally {
Context.exit();
}
}
示例9: testJavaApi
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
public void testJavaApi() throws Exception {
Context cx = RhinoAndroidHelper.prepareContext();
try {
cx.setOptimizationLevel(-1);
Script script = cx.compileString(TestUtils.readAsset("Bug482203.js"),
"", 1, null);
Scriptable scope = cx.initStandardObjects();
cx.executeScriptWithContinuations(script, scope);
int counter = 0;
for(;;)
{
Object cont = ScriptableObject.getProperty(scope, "c");
if(cont == null)
{
break;
}
counter++;
cx.resumeContinuation(cont, scope, null);
}
assertEquals(counter, 5);
assertEquals(Double.valueOf(3), ScriptableObject.getProperty(scope, "result"));
} finally {
Context.exit();
}
}
示例10: testCompiledJs
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Test
public void testCompiledJs() throws Exception {
// The main module calls a soy template and alerts the output.
// Replace alert with something that lets us capture the output.
cx.evaluateString(
scope, "var _alerts_ = []; alert = function (s) { _alerts_.push(s); }",
"test", 1, null);
loadJsModule("/closure/js/main.js");
loadJsModule("/closure/js/hello.world.js");
NativeArray alerts = (NativeArray)
ScriptableObject.getProperty(scope, "_alerts_");
assertEquals(
"<div id=\"greeting\">Hello, <b class=\"b\">Cle<eland</b>!</div>",
Context.toString(alerts.get(0)));
}
示例11: get
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
@Override
public Object get(final Object key) {
Object retval;
if (key instanceof Number) {
retval = ScriptableObject.getProperty(s, ((Number) key).intValue());
} else {
retval = ScriptableObject.getProperty(s, String.valueOf(key));
}
return ScriptableConverter.jsToJava(retval);
}
示例12: readPropFoo
import org.mozilla.javascript.ScriptableObject; //導入方法依賴的package包/類
public Object readPropFoo(final Scriptable s) {
return ScriptableObject.getProperty(s, "foo");
}