Search in sources :

Example 96 with ScriptException

use of javax.script.ScriptException in project jgnash by ccavanaugh.

the class ImportFilter method getDescription.

public String getDescription() {
    try (final Reader reader = getReader()) {
        engine.eval(reader);
        final Invocable invocable = (Invocable) engine;
        final Object result = invocable.invokeFunction("getDescription", Locale.getDefault());
        return result.toString();
    } catch (final ScriptException | IOException | NoSuchMethodException e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    return "";
}
Also used : Invocable(javax.script.Invocable) ScriptException(javax.script.ScriptException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException)

Example 97 with ScriptException

use of javax.script.ScriptException in project jgnash by ccavanaugh.

the class ImportFilter method processMemo.

public String processMemo(final String memo) {
    try (final Reader reader = getReader()) {
        engine.eval(reader);
        final Invocable invocable = (Invocable) engine;
        final Object result = invocable.invokeFunction("processMemo", memo);
        return result.toString();
    } catch (final ScriptException | IOException | NoSuchMethodException e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    return memo;
}
Also used : Invocable(javax.script.Invocable) ScriptException(javax.script.ScriptException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException)

Example 98 with ScriptException

use of javax.script.ScriptException in project jgnash by ccavanaugh.

the class ImportFilter method processPayee.

public String processPayee(final String payee) {
    try (final Reader reader = getReader()) {
        engine.eval(reader);
        final Invocable invocable = (Invocable) engine;
        final Object result = invocable.invokeFunction("processPayee", payee);
        return result.toString();
    } catch (final ScriptException | IOException | NoSuchMethodException e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    return payee;
}
Also used : Invocable(javax.script.Invocable) ScriptException(javax.script.ScriptException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException)

Aggregations

ScriptException (javax.script.ScriptException)98 IOException (java.io.IOException)41 ScriptEngine (javax.script.ScriptEngine)36 Bindings (javax.script.Bindings)27 ScriptEngineManager (javax.script.ScriptEngineManager)17 CompiledScript (javax.script.CompiledScript)12 InputStreamReader (java.io.InputStreamReader)11 Invocable (javax.script.Invocable)11 ScriptContext (javax.script.ScriptContext)10 Map (java.util.Map)9 SimpleBindings (javax.script.SimpleBindings)8 Reader (java.io.Reader)7 HashMap (java.util.HashMap)7 File (java.io.File)6 Writer (java.io.Writer)6 ArrayList (java.util.ArrayList)6 SlingBindings (org.apache.sling.api.scripting.SlingBindings)6 MissingMethodException (groovy.lang.MissingMethodException)5 MissingPropertyException (groovy.lang.MissingPropertyException)5 DelegatingMetaClass (groovy.lang.DelegatingMetaClass)4