当前位置: 首页>>代码示例>>Java>>正文


Java Scriptable.get方法代码示例

本文整理汇总了Java中org.mozilla.javascript.Scriptable.get方法的典型用法代码示例。如果您正苦于以下问题:Java Scriptable.get方法的具体用法?Java Scriptable.get怎么用?Java Scriptable.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.javascript.Scriptable的用法示例。


在下文中一共展示了Scriptable.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toMap

import org.mozilla.javascript.Scriptable; //导入方法依赖的package包/类
public static Map<String, Object> toMap(Scriptable obj) {
    Map<String, Object> map = new LinkedHashMap<String, Object>();

    for (Object id : obj.getIds()) {
        String key;
        Object value;
        if (id instanceof String) {
            key = (String) id;
            value = obj.get(key, obj);
        } else if (id instanceof Integer) {
            key = id.toString();
            value = obj.get((Integer) id, obj);
        } else {
            throw new IllegalArgumentException(String.format("Unexpected key type: %s (value: %s)", id.getClass().getName(), id));
        }

        map.put(key, toJavaValue(value));
    }

    return map;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:RhinoWorkerUtils.java

示例2: listInvitations

import org.mozilla.javascript.Scriptable; //导入方法依赖的package包/类
/**
   * List the open invitations for this web site.
   * props specifies optional properties to be searched.
   * 
   * @param props inviteeUserName
   *
   * @return the invitations
   */
  public ScriptInvitation<?>[] listInvitations(Scriptable props)
  {
  	InvitationSearchCriteriaImpl crit = new InvitationSearchCriteriaImpl();
  	crit.setResourceName(getShortName());
  	crit.setResourceType(Invitation.ResourceType.WEB_SITE);
  	
  	if (props.has("inviteeUserName", props))
  	{
  		crit.setInvitee((String)props.get("inviteeUserName", props));
    	}
  	if (props.has("invitationType", props))
  	{
  		String invitationType = (String)props.get("invitationType", props);
  		crit.setInvitationType(InvitationType.valueOf(invitationType));
      }

  	List<Invitation> invitations = invitationService.searchInvitation(crit);
  	ScriptInvitation<?>[] ret = new ScriptInvitation[invitations.size()];
      int i = 0;
for(Invitation item : invitations)
{
	ret[i++] = scriptInvitationFactory.toScriptInvitation(item);
}
  	return ret;
  }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:Site.java

示例3: stepExecute

import org.mozilla.javascript.Scriptable; //导入方法依赖的package包/类
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
	variables.clear();

	if (isEnabled()) {
		for (RequestableVariable var : getParentSequence().getAllVariables()) {
			try {
				//evaluate(javascriptContext, scope, var.getName(), "expression", true);
				evaluated = scope.get(var.getName(), scope);
				if (evaluated != null && !(evaluated instanceof Undefined)) {
					if (evaluated instanceof NativeJavaObject) {
						evaluated = ((NativeJavaObject) evaluated).unwrap();
					}
					variables.put(var.getName(), evaluated);
				}
			} catch (Exception e) {
				evaluated = null;
				Engine.logBeans.warn(e.getMessage());
			}
		}
		return super.stepExecute(javascriptContext, scope);
	}
	return false;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:25,代码来源:InputVariablesStep.java

示例4: stepExecute

import org.mozilla.javascript.Scriptable; //导入方法依赖的package包/类
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
	if (isEnabled()) {
		if (super.stepExecute(javascriptContext, scope)) {
			String variableName = getVariableName();
			NodeList list = (NodeList) scope.get(variableName, scope);
			
			Object string = null;
			if (list.getLength() > 0) {
				Node node = list.item(0);
				if (node instanceof Element) {
					Element element = (Element) node;
					string = element.getTextContent();
				} else {
					string = node.getNodeValue();
				}
			}
			scope.put(variableName, scope, string);
			return true;
		}
	}
	return false;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:24,代码来源:SimpleSourceStep.java

示例5: runScript

import org.mozilla.javascript.Scriptable; //导入方法依赖的package包/类
/**
 * 执行JS
 * 
 * @param js js代码
 * @param functionName js方法名称
 * @param functionParams js方法参数
 * @return
 */
public static String runScript(Context context, String js, String functionName, Object[] functionParams) {
	org.mozilla.javascript.Context rhino = org.mozilla.javascript.Context.enter();
	rhino.setOptimizationLevel(-1);
	try {
		Scriptable scope = rhino.initStandardObjects();

		ScriptableObject.putProperty(scope, "javaContext", org.mozilla.javascript.Context.javaToJS(context, scope));
		ScriptableObject.putProperty(scope, "javaLoader", org.mozilla.javascript.Context.javaToJS(context.getClass().getClassLoader(), scope));

		rhino.evaluateString(scope, js, context.getClass().getSimpleName(), 1, null);

		Function function = (Function) scope.get(functionName, scope);

		Object result = function.call(rhino, scope, scope, functionParams);
		if (result instanceof String) {
			return (String) result;
		} else if (result instanceof NativeJavaObject) {
			return (String) ((NativeJavaObject) result).getDefaultValue(String.class);
		} else if (result instanceof NativeObject) {
			return (String) ((NativeObject) result).getDefaultValue(String.class);
		}
		return result.toString();//(String) function.call(rhino, scope, scope, functionParams);
	} finally {
		org.mozilla.javascript.Context.exit();
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:35,代码来源:A6Util.java


注:本文中的org.mozilla.javascript.Scriptable.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。