优化
This commit is contained in:
@@ -5,8 +5,9 @@ package com.script;
|
|||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
public abstract class AbstractScriptEngine
|
@SuppressWarnings("unused")
|
||||||
implements ScriptEngine {
|
public abstract class AbstractScriptEngine implements ScriptEngine {
|
||||||
|
|
||||||
protected ScriptContext context = new SimpleScriptContext();
|
protected ScriptContext context = new SimpleScriptContext();
|
||||||
|
|
||||||
public AbstractScriptEngine() {
|
public AbstractScriptEngine() {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ package com.script;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface Bindings
|
@SuppressWarnings("UnnecessaryModifier")
|
||||||
extends Map<String, Object> {
|
public interface Bindings extends Map<String, Object> {
|
||||||
@Override
|
@Override
|
||||||
public boolean containsKey(Object var1);
|
public boolean containsKey(Object var1);
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public interface Bindings
|
|||||||
public Object put(String var1, Object var2);
|
public Object put(String var1, Object var2);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ? extends Object> var1);
|
public void putAll(Map<? extends String, ?> var1);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object remove(Object var1);
|
public Object remove(Object var1);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package com.script;
|
|||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
|
@SuppressWarnings("UnnecessaryModifier")
|
||||||
public interface Compilable {
|
public interface Compilable {
|
||||||
public CompiledScript compile(Reader var1) throws ScriptException;
|
public CompiledScript compile(Reader var1) throws ScriptException;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.script;
|
package com.script;
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "UnnecessaryModifier"})
|
||||||
public interface Invocable {
|
public interface Invocable {
|
||||||
public <T> T getInterface(Class<T> var1);
|
public <T> T getInterface(Class<T> var1);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import java.io.Reader;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "UnnecessaryModifier"})
|
||||||
public interface ScriptContext {
|
public interface ScriptContext {
|
||||||
|
|
||||||
public static final int ENGINE_SCOPE = 100;
|
public static final int ENGINE_SCOPE = 100;
|
||||||
public static final int GLOBAL_SCOPE = 200;
|
public static final int GLOBAL_SCOPE = 200;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package com.script;
|
|||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "UnnecessaryModifier"})
|
||||||
public interface ScriptEngine {
|
public interface ScriptEngine {
|
||||||
public static final String FILENAME = "javax.script.filename";
|
public static final String FILENAME = "javax.script.filename";
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.script;
|
package com.script;
|
||||||
|
|
||||||
public class ScriptException
|
@SuppressWarnings("unused")
|
||||||
extends Exception {
|
public class ScriptException extends Exception {
|
||||||
private int columnNumber;
|
private int columnNumber;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private int lineNumber;
|
private int lineNumber;
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SimpleBindings
|
public class SimpleBindings implements Bindings {
|
||||||
implements Bindings {
|
|
||||||
private Map<String, Object> map;
|
private Map<String, Object> map;
|
||||||
|
|
||||||
public SimpleBindings(Map<String, Object> m) {
|
public SimpleBindings(Map<String, Object> m) {
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SimpleScriptContext
|
public class SimpleScriptContext implements ScriptContext {
|
||||||
implements ScriptContext {
|
|
||||||
private static List<Integer> scopes = new ArrayList<Integer>(2);
|
private static List<Integer> scopes = new ArrayList<Integer>(2);
|
||||||
protected Bindings engineScope = new SimpleBindings();
|
protected Bindings engineScope = new SimpleBindings();
|
||||||
protected Writer errorWriter = new PrintWriter(System.err, true);
|
protected Writer errorWriter = new PrintWriter(System.err, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user