Java 类org.mozilla.javascript.commonjs.module.provider.ModuleSource 实例源码

项目:https-github.com-hyb1996-NoRootScriptDroid    文件:AssetAndUrlModuleSourceProvider.java   
@Override
protected ModuleSource loadFromPrivilegedLocations(String moduleId, Object validator) throws IOException, URISyntaxException {
    String moduleIdWithExtension = moduleId;
    if (!moduleIdWithExtension.endsWith(".js")) {
        moduleIdWithExtension += ".js";
    }
    if (mModules.contains(moduleIdWithExtension)) {
        return new ModuleSource(new InputStreamReader(mContext.getAssets().open(MODULES_PATH + "/" + moduleIdWithExtension)), null,
                URI.create(moduleIdWithExtension), mBaseURI, validator);
    }
    return super.loadFromPrivilegedLocations(moduleId, validator);
}
项目:Auto.js    文件:AssetAndUrlModuleSourceProvider.java   
@Override
protected ModuleSource loadFromPrivilegedLocations(String moduleId, Object validator) throws IOException, URISyntaxException {
    String moduleIdWithExtension = moduleId;
    if (!moduleIdWithExtension.endsWith(".js")) {
        moduleIdWithExtension += ".js";
    }
    if (mModules.contains(moduleIdWithExtension)) {
        return new ModuleSource(new InputStreamReader(mContext.getAssets().open(MODULES_PATH + "/" + moduleIdWithExtension)), null,
                URI.create(moduleIdWithExtension), mBaseURI, validator);
    }
    return super.loadFromPrivilegedLocations(moduleId, validator);
}
项目:Equella    文件:ScriptableModuleSourceProvider.java   
@SuppressWarnings("nls")
public ModuleSource loadFromScriptableObject(String moduleId) throws UnsupportedEncodingException,
    URISyntaxException
{
    Object object = scriptable.get(moduleId, scriptable);
    if(object !=null)
    {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(object.toString().getBytes("UTF-8"));
        Reader reader = new InputStreamReader(byteArrayInputStream);
        URI uri = new URI("#" + moduleId);

        return new ModuleSource(reader, null, uri, null, null);
    }
    return null;
}
项目:rec-core    文件:NativeModuleSourceProvider.java   
@Override
protected ModuleSource loadFromUri(URI uri, URI base, Object validator)
        throws IOException, URISyntaxException {
    try {
        LOGGER.info(format("Loading js module [%s]", uri.toString()));
        return new ModuleSource(getReader(uri.toString()), null, uri, base, validator);
    } catch (Exception ex) {
        LOGGER.warn(format("Loading js module [%s] failed.", uri.toString()));
        return null;
    }
}
项目:rec-core    文件:NativeModuleSourceProvider.java   
@Override
protected ModuleSource loadFromFallbackLocations(String moduleId, Object validator)
        throws IOException, URISyntaxException {
    LOGGER.info(String.format("Loading js module from fallback location %s", moduleId));
    return new ModuleSource(getReader(moduleId),
            null,
            new URI(moduleId),
            new URI("./"), validator);
}
项目:Equella    文件:ScriptableModuleSourceProvider.java   
@Override
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws IOException,
    URISyntaxException
{
    return loadFromScriptableObject(moduleId);
}
项目:Equella    文件:ScriptableModuleSourceProvider.java   
@Override
public ModuleSource loadSource(URI uri, URI baseUri, Object validator) throws IOException, URISyntaxException
{
    return null;
}