本文整理汇总了Java中org.mozilla.javascript.xml.XMLObject.ecmaGet方法的典型用法代码示例。如果您正苦于以下问题:Java XMLObject.ecmaGet方法的具体用法?Java XMLObject.ecmaGet怎么用?Java XMLObject.ecmaGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.xml.XMLObject
的用法示例。
在下文中一共展示了XMLObject.ecmaGet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入方法依赖的package包/类
public static Object getObjectElem(Scriptable obj, Object elem,
Context cx)
{
if (obj instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, elem);
}
Object result;
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
result = ScriptableObject.getProperty(obj, index);
} else {
result = ScriptableObject.getProperty(obj, s);
}
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}
示例2: getObjectProp
import org.mozilla.javascript.xml.XMLObject; //导入方法依赖的package包/类
public static Object getObjectProp(Scriptable obj, String property,
Context cx)
{
if (obj instanceof XMLObject) {
// TODO: Change XMLObject to just use Scriptable interface
// to avoid paying cost of instanceof check on *every property
// lookup* !
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, property);
}
Object result = ScriptableObject.getProperty(obj, property);
if (result == Scriptable.NOT_FOUND) {
if (cx.hasFeature(Context.FEATURE_STRICT_MODE)) {
Context.reportWarning(ScriptRuntime.getMessage1(
"msg.ref.undefined.prop", property));
}
result = Undefined.instance;
}
return result;
}
示例3: getObjectIndex
import org.mozilla.javascript.xml.XMLObject; //导入方法依赖的package包/类
public static Object getObjectIndex(Scriptable obj, int index,
Context cx)
{
if (obj instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, Integer.valueOf(index));
}
Object result = ScriptableObject.getProperty(obj, index);
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}
示例4: nameOrFunction
import org.mozilla.javascript.xml.XMLObject; //导入方法依赖的package包/类
private static Object nameOrFunction(Context cx, Scriptable scope,
Scriptable parentScope, String name,
boolean asFunctionCall)
{
Object result;
Scriptable thisObj = scope; // It is used only if asFunctionCall==true.
XMLObject firstXMLObject = null;
for (;;) {
if (scope instanceof NativeWith) {
Scriptable withObj = scope.getPrototype();
if (withObj instanceof XMLObject) {
XMLObject xmlObj = (XMLObject)withObj;
if (xmlObj.ecmaHas(cx, name)) {
// function this should be the target object of with
thisObj = xmlObj;
result = xmlObj.ecmaGet(cx, name);
break;
}
if (firstXMLObject == null) {
firstXMLObject = xmlObj;
}
} else {
result = ScriptableObject.getProperty(withObj, name);
if (result != Scriptable.NOT_FOUND) {
// function this should be the target object of with
thisObj = withObj;
break;
}
}
} else if (scope instanceof NativeCall) {
// NativeCall does not prototype chain and Scriptable.get
// can be called directly.
result = scope.get(name, scope);
if (result != Scriptable.NOT_FOUND) {
if (asFunctionCall) {
// ECMA 262 requires that this for nested funtions
// should be top scope
thisObj = ScriptableObject.
getTopLevelScope(parentScope);
}
break;
}
} else {
// Can happen if Rhino embedding decided that nested
// scopes are useful for what ever reasons.
result = ScriptableObject.getProperty(scope, name);
if (result != Scriptable.NOT_FOUND) {
thisObj = scope;
break;
}
}
scope = parentScope;
parentScope = parentScope.getParentScope();
if (parentScope == null) {
result = topScopeName(cx, scope, name);
if (result == Scriptable.NOT_FOUND) {
if (firstXMLObject == null || asFunctionCall) {
throw notFoundError(scope, name);
}
// The name was not found, but we did find an XML
// object in the scope chain and we are looking for name,
// not function. The result should be an empty XMLList
// in name context.
result = firstXMLObject.ecmaGet(cx, name);
}
// For top scope thisObj for functions is always scope itself.
thisObj = scope;
break;
}
}
if (asFunctionCall) {
if (!(result instanceof Callable)) {
throw notFunctionError(result, name);
}
storeScriptable(cx, thisObj);
}
return result;
}