KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > script > Interpreter


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.script;
19
20 import java.io.IOException JavaDoc;
21 import java.io.Reader JavaDoc;
22 import java.io.Writer JavaDoc;
23
24 /**
25  * An hight level interface that represents an interpreter engine of
26  * a particular scripting language.
27  *
28  * @author <a HREF="mailto:cjolif@ilog.fr">Christophe Jolif</a>
29  * @version $Id: Interpreter.java,v 1.9 2004/08/18 07:14:53 vhardy Exp $
30  */

31 public interface Interpreter extends org.apache.batik.i18n.Localizable {
32     /**
33      * This method should evaluate a piece of script associated to a given
34      * description.
35      *
36      * @param scriptreader a <code>java.io.Reader</code> on the piece of script
37      * @param description description which can be later used (e.g., for error
38      * messages).
39      * @return if no exception is thrown during the call, should return the
40      * value of the last expression evaluated in the script
41      */

42     public Object JavaDoc evaluate(Reader JavaDoc scriptreader, String JavaDoc description)
43         throws InterpreterException, IOException JavaDoc;
44
45     /**
46      * This method should evaluate a piece of script.
47      *
48      * @param scriptreader a <code>java.io.Reader</code> on the piece of script
49      * @return if no exception is thrown during the call, should return the
50      * value of the last expression evaluated in the script
51      */

52     public Object JavaDoc evaluate(Reader JavaDoc scriptreader)
53         throws InterpreterException, IOException JavaDoc;
54
55     /**
56      * This method should evaluate a piece of script using a <code>String</code>
57      * instead of a <code>Reader</code>. This usually allows do easily do some
58      * caching.
59      *
60      * @param script the piece of script
61      * @return if no exception is thrown during the call, should return the
62      * value of the last expression evaluated in the script
63      */

64     public Object JavaDoc evaluate(String JavaDoc script)
65         throws InterpreterException;
66
67     /**
68      * This method should register a particular Java <code>Object</code> in
69      * the environment of the interpreter.
70      *
71      * @param name the name of the script object to create
72      * @param object the Java object
73      */

74     public void bindObject(String JavaDoc name, Object JavaDoc object);
75
76     /**
77      * This method should change the output <code>Writer</code> that will be
78      * used when output function of the scripting langage is used.
79      *
80      * @param output the new out <code>Writer</code>.
81      */

82     public void setOut(Writer JavaDoc output);
83
84     /**
85      * This method can dispose resources used by the interpreter when it is
86      * no longer used. Be careful, you SHOULD NOT use this interpreter instance
87      * after calling this method.
88      */

89     public void dispose();
90 }
91
Popular Tags