本文整理汇总了Java中org.mozilla.javascript.ScriptableObject.getIds方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptableObject.getIds方法的具体用法?Java ScriptableObject.getIds怎么用?Java ScriptableObject.getIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ScriptableObject
的用法示例。
在下文中一共展示了ScriptableObject.getIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractScriptablePropertiesToMap
import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
/**
* Helper to extract a map of properties from a scriptable object (generally an associative array)
*
* @param scriptable The scriptable object to extract name/value pairs from.
* @param map The map to add the converted name/value pairs to.
*/
private void extractScriptablePropertiesToMap(ScriptableObject scriptable, Map<QName, Serializable> map)
{
// get all the keys to the provided properties
// and convert them to a Map of QName to Serializable objects
Object[] propIds = scriptable.getIds();
for (int i = 0; i < propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that are formed of Strings i.e. QName.toString()
if (propId instanceof String)
{
// get the value out for the specified key - it must be Serializable
String key = (String)propId;
Object value = scriptable.get(key, scriptable);
if (value instanceof Serializable)
{
value = getValueConverter().convertValueForRepo((Serializable)value);
map.put(createQName(key), (Serializable)value);
}
}
}
}
示例2: extractScriptableProperties
import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
/**
* Extract a map of properties from a scriptable object (generally an associative array)
*
* @param scriptable The scriptable object to extract name/value pairs from.
* @param map The map to add the converted name/value pairs to.
*/
private void extractScriptableProperties(ScriptableObject scriptable, Map<QName, Serializable> map)
{
// we need to get all the keys to the properties provided
// and convert them to a Map of QName to Serializable objects
Object[] propIds = scriptable.getIds();
for (int i = 0; i < propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that are formed of Strings i.e. QName.toString()
if (propId instanceof String)
{
// get the value out for the specified key - it must be Serializable
String key = (String)propId;
Object value = scriptable.get(key, scriptable);
if (value instanceof Serializable)
{
value = getValueConverter().convertValueForRepo((Serializable)value);
map.put(createQName(key), (Serializable)value);
}
}
}
}
示例3: startWorkflow
import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
/**
* Start workflow instance from workflow definition
*
* @param workflowPackage workflow package node to 'attach' to the new workflow
* instance
* @param properties Associative array of properties used to populate the
* start task properties
* @return the initial workflow path
*/
@SuppressWarnings("unchecked")
public JscriptWorkflowPath startWorkflow(ScriptNode workflowPackage,
Object properties)
{
WorkflowService workflowService = this.serviceRegistry.getWorkflowService();
// if properties object is a scriptable object, then extract property name/value pairs
// into property Map<QName, Serializable>, otherwise leave property map as null
Map<QName, Serializable> workflowParameters = null;
if (properties instanceof ScriptableObject)
{
ScriptableObject scriptableProps = (ScriptableObject)properties;
workflowParameters = new HashMap<QName, Serializable>(scriptableProps.getIds().length);
extractScriptablePropertiesToMap(scriptableProps, workflowParameters);
}
// attach given workflow package node if it is not null
if (workflowPackage != null)
{
if (workflowParameters == null)
{
workflowParameters = new HashMap<QName, Serializable>(1);
}
workflowParameters.put(WorkflowModel.ASSOC_PACKAGE, getValueConverter().convertValueForRepo(workflowPackage));
}
// provide a default context, if one is not specified
Serializable context = workflowParameters.get(WorkflowModel.PROP_CONTEXT);
if (context == null)
{
workflowParameters.put(WorkflowModel.PROP_CONTEXT, workflowPackage.getNodeRef());
}
WorkflowPath cmrWorkflowPath = workflowService.startWorkflow(this.id, workflowParameters);
return new JscriptWorkflowPath(cmrWorkflowPath, this.serviceRegistry, this.scope);
}
示例4: processTemplate
import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
private String processTemplate(String template, NodeRef templateRef, ScriptableObject args)
{
Object person = (Object)scope.get("person", scope);
Object companyhome = (Object)scope.get("companyhome", scope);
Object userhome = (Object)scope.get("userhome", scope);
// build default model for the template processing
Map<String, Object> model = this.services.getTemplateService().buildDefaultModel(
(person.equals(UniqueTag.NOT_FOUND)) ? null : ((ScriptNode)((Wrapper)person).unwrap()).getNodeRef(),
(companyhome.equals(UniqueTag.NOT_FOUND)) ? null : ((ScriptNode)((Wrapper)companyhome).unwrap()).getNodeRef(),
(userhome.equals(UniqueTag.NOT_FOUND)) ? null : ((ScriptNode)((Wrapper)userhome).unwrap()).getNodeRef(),
templateRef,
null);
// add the current node as either the document/space as appropriate
if (this.getIsDocument())
{
model.put("document", this.nodeRef);
model.put("space", getPrimaryParentAssoc().getParentRef());
}
else
{
model.put("space", this.nodeRef);
}
// add the supplied args to the 'args' root object
if (args != null)
{
// we need to get all the keys to the properties provided
// and convert them to a Map of QName to Serializable objects
Object[] propIds = args.getIds();
Map<String, String> templateArgs = new HashMap<String, String>(propIds.length);
for (int i = 0; i < propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that are formed of Strings i.e. QName.toString()
if (propId instanceof String)
{
// get the value out for the specified key - make sure it is Serializable
Object value = args.get((String) propId, args);
value = getValueConverter().convertValueForRepo((Serializable)value);
if (value != null)
{
templateArgs.put((String) propId, value.toString());
}
}
}
// add the args to the model as the 'args' root object
model.put("args", templateArgs);
}
// execute template!
// TODO: check that script modified nodes are reflected...
return this.services.getTemplateService().processTemplateString(null, template, model);
}