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


Java ScriptableObject.get方法代码示例

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


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

示例1: decryptSignature

import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
private String decryptSignature(String encryptedSig, String decryptionCode) throws DecryptException {
    Context context = Context.enter();
    context.setOptimizationLevel(-1);
    Object result;
    try {
        ScriptableObject scope = context.initStandardObjects();
        context.evaluateString(scope, decryptionCode, "decryptionCode", 1, null);
        Function decryptionFunc = (Function) scope.get("decrypt", scope);
        result = decryptionFunc.call(context, scope, scope, new Object[]{encryptedSig});
    } catch (Exception e) {
        throw new DecryptException("could not get decrypt signature", e);
    } finally {
        Context.exit();
    }
    return result == null ? "" : result.toString();
}
 
开发者ID:TeamNewPipe,项目名称:NewPipeExtractor,代码行数:17,代码来源:YoutubeStreamExtractor.java

示例2: 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);
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:JscriptWorkflowDefinition.java

示例3: 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);
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:ScriptNode.java

示例4: decipherKey

import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
/**
 * After finding the decrypted code in the js html5 player code
 * run the code passing the encryptedSig parameter
 *
 * @param encryptedSig
 * @param html5player
 * @return
 * @throws Exception
 */
private static String decipherKey(String encryptedSig, String html5player)
        throws Exception {
    String decipherFunc = loadFunction(html5player);
    Context context = Context.enter();
    // Rhino interpreted mode
    context.setOptimizationLevel(-1);
    Object result = null;
    try {
        ScriptableObject scope = context.initStandardObjects();
        context.evaluateString(scope, decipherFunc, "decipherFunc", 1, null);
        Function decryptionFunc = (Function) scope.get("decrypt", scope);
        result = decryptionFunc.call(context, scope, scope, new Object[]{encryptedSig});
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Context.exit();
    }
    if (result == null) {
        return "";
    } else {
        return result.toString();
    }
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:33,代码来源:YoutubeLinkRetriever.java

示例5: validateJson

import org.mozilla.javascript.ScriptableObject; //导入方法依赖的package包/类
private boolean validateJson(JSONObject jsFunction, JSONObject requestJsonObject, JSONObject errorMessage) {
    String code = jsFunction.getString("#text");
    String functionName = jsFunction.getString("@name");
    if (jsFunction.has("@language")) {
        String language = jsFunction.getString("@language");
        if ("groovy".equalsIgnoreCase(language)) {
            GroovyCodeExecutionManager executionManager = new GroovyCodeExecutionManager(code, functionName,
                    requestJsonObject, errorMessage);
            return executionManager.executeGroovy();
        }
    }

    try {
        Context context = Context.enter();
        ScriptableObject scope = context.initStandardObjects();

        context.evaluateString(scope, code, functionName, 1, null);

        Function function = (Function) scope.get(functionName, scope);
        Object result = function.call(context, scope, scope, new Object[]{requestJsonObject.toString(),
                errorMessage.toString()});
        String returnErrorMessage = (String) Context.jsToJava(result, String.class);
        JSONObject actualMessage = JSONObject.fromObject(returnErrorMessage);
        if (!actualMessage.isEmpty()) {
            errorMessage.accumulate("result", actualMessage);
            return false;
        }
    } catch (Exception unknownException) {
        logger.error("Error occurred", unknownException);
    } finally {
        Context.exit();
    }
    return true;
}
 
开发者ID:helicalinsight,项目名称:helicalinsight,代码行数:35,代码来源:GenericValidation.java

示例6: 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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:58,代码来源:ScriptNode.java


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