List of usage examples for javax.script ScriptContext getScopes
public List<Integer> getScopes();
List
of all the valid values for scope in the ScriptContext. From source file:Main.java
public static void main(String[] args) { ScriptContext ctx = new SimpleScriptContext(); List<Integer> scopes = ctx.getScopes(); System.out.println("Supported Scopes: " + scopes); ctx.setAttribute("year", 2015, ENGINE_SCOPE); Bindings globalBindings = new SimpleBindings(); ctx.setBindings(globalBindings, GLOBAL_SCOPE); ctx.setAttribute("year", 2014, GLOBAL_SCOPE); ctx.setAttribute("name", "Jack", GLOBAL_SCOPE); String nameValue = (String) ctx.getAttribute("name"); System.out.println("nameValue = " + nameValue); int engineScopeYear = (Integer) ctx.getAttribute("year", ENGINE_SCOPE); int globalScopeYear = (Integer) ctx.getAttribute("year", GLOBAL_SCOPE); System.out.println("engineScopeYear = " + engineScopeYear); System.out.println("globalScopeYear = " + globalScopeYear); }