Example usage for jdk.nashorn.api.scripting URLReader URLReader

List of usage examples for jdk.nashorn.api.scripting URLReader URLReader

Introduction

In this page you can find the example usage for jdk.nashorn.api.scripting URLReader URLReader.

Prototype

public URLReader(final URL url) 

Source Link

Document

Constructor

Usage

From source file:blue.lapis.nocturne.test.mapping.io.reader.EnigmaReaderTest.java

License:Open Source License

@BeforeClass
public static void initialize() throws IOException {
    loadMain();//w w  w.j  a v  a  2  s .  com
    EnigmaReader reader = new EnigmaReader(
            new BufferedReader(new URLReader(ClassLoader.getSystemResource("mappings/example.eng"))));
    helper = new ReaderTestHelper(reader.read());
}

From source file:blue.lapis.nocturne.test.mapping.io.reader.JamReaderTest.java

License:Open Source License

@BeforeClass
public static void initialize() throws IOException {
    loadMain();//from   w  ww.  j a v a2 s . c  o m
    JamReader reader = new JamReader(
            new BufferedReader(new URLReader(ClassLoader.getSystemResource("mappings/example.jam"))));
    helper = new ReaderTestHelper(reader.read());
}

From source file:blue.lapis.nocturne.test.mapping.io.reader.SrgReaderTest.java

License:Open Source License

@BeforeClass
public static void initialize() throws IOException {
    loadMain();//from  w w  w .  j ava  2 s. c o m
    SrgReader reader = new SrgReader(
            new BufferedReader(new URLReader(ClassLoader.getSystemResource("mappings/example.srg"))));
    helper = new ReaderTestHelper(reader.read());
}

From source file:de.axelfaust.alfresco.nashorn.repo.junit.runners.ScriptFile.java

License:Open Source License

protected static Object executeScriptFromResource(final URL resource, final String shortName,
        final ScriptContext scriptContext) throws ScriptException {
    try (@SuppressWarnings("restriction")
    Reader reader = new URLReader(resource)) {
        scriptContext.setAttribute(ScriptEngine.FILENAME, shortName, ScriptContext.ENGINE_SCOPE);
        return NASHORN_ENGINE.eval(reader, scriptContext);
    } catch (final IOException e) {
        throw new ScriptException(e);
    }/*from w  w w .j  av a 2 s.  c  om*/
}

From source file:de.axelfaust.alfresco.nashorn.repo.junit.tests.SimpleScriptTestCase.java

License:Open Source License

protected static Object executeScriptFromResource(final URL resource, final ScriptEngine engine,
        final ScriptContext ctxt) throws ScriptException {
    try (Reader reader = new URLReader(resource)) {
        ctxt.setAttribute(ScriptEngine.FILENAME, resource.toString(), ScriptContext.ENGINE_SCOPE);
        return engine.eval(reader, ctxt);
    } catch (final IOException e) {
        throw new ScriptException(e);
    }//from  w w  w  . ja v  a2  s .  c o  m
}

From source file:de.axelfaust.alfresco.nashorn.repo.processor.NashornScriptProcessor.java

License:Open Source License

protected Object executeScriptFromResource(final URL resource) throws ScriptException {
    this.initialisationStateLock.readLock().lock();
    try {/*  ww  w  .  ja v a 2s.  com*/
        LOGGER.debug("Executing script from resource {}", resource);
        try (Reader reader = new URLReader(resource)) {
            this.engine.getContext().setAttribute(ScriptEngine.FILENAME, resource.toString(),
                    ScriptContext.ENGINE_SCOPE);
            return this.engine.eval(reader);
        } catch (final IOException e) {
            throw new ScriptException(e);
        } finally {
            LOGGER.trace("Execution of script from resource {} completed", resource);
        }
    } finally {
        this.initialisationStateLock.readLock().unlock();
    }
}

From source file:JsonProgramas.parcerJson.java

public parcerJson() {

    System.out.println(nombrePrograma);
    try {/*w  ww  .java 2 s.c  om*/
        JSONParser parser = new JSONParser();
        URL urljson = new URL(
                "http://multimedia.telesurtv.net/api/programa/?ultimo=100&mostrar=nombre&mostrar=slug");
        JSONArray jsonArray = (JSONArray) parser.parse(new URLReader(urljson));
        for (Object o : jsonArray) {
            JSONObject prog = (JSONObject) o;

            String strNombrePrograma = (String) prog.get("nombre");
            String strSlug = (String) prog.get("slug");
            programas.put(strNombrePrograma, strSlug);
        }

    } catch (Exception e) {
    }
}