當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。