84 |
84 |
85 /** |
85 /** |
86 * Create a {@code SimpleScriptContext}. |
86 * Create a {@code SimpleScriptContext}. |
87 */ |
87 */ |
88 public SimpleScriptContext() { |
88 public SimpleScriptContext() { |
|
89 this(new InputStreamReader(System.in), |
|
90 new PrintWriter(System.out , true), |
|
91 new PrintWriter(System.err, true)); |
89 engineScope = new SimpleBindings(); |
92 engineScope = new SimpleBindings(); |
90 globalScope = null; |
93 globalScope = null; |
91 reader = new InputStreamReader(System.in); |
94 } |
92 writer = new PrintWriter(System.out , true); |
95 |
93 errorWriter = new PrintWriter(System.err, true); |
96 /** |
|
97 * Package-private constructor to avoid needless creation of reader and writers. |
|
98 * It is the caller's responsability to initialize the engine scope. |
|
99 * |
|
100 * @param reader the reader |
|
101 * @param writer the writer |
|
102 * @param errorWriter the error writer |
|
103 */ |
|
104 SimpleScriptContext(Reader reader, Writer writer, Writer errorWriter) { |
|
105 this.reader = reader; |
|
106 this.writer = writer; |
|
107 this.errorWriter = errorWriter; |
94 } |
108 } |
95 |
109 |
96 /** |
110 /** |
97 * Sets a <code>Bindings</code> of attributes for the given scope. If the value |
111 * Sets a <code>Bindings</code> of attributes for the given scope. If the value |
98 * of scope is <code>ENGINE_SCOPE</code> the given <code>Bindings</code> replaces the |
112 * of scope is <code>ENGINE_SCOPE</code> the given <code>Bindings</code> replaces the |