01: /* Copyright 2007 David N. Welton - DedaSys LLC - http://www.dedasys.com
02:
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14: */
15:
16: package org.hecl.java;
17:
18: import org.hecl.HeclException;
19: import org.hecl.Interp;
20: import org.hecl.ObjectThing;
21: import org.hecl.StringThing;
22: import org.hecl.Thing;
23:
24: /**
25: * The <code>HeclJavaCmd</code> class implements the "java" command,
26: * which can be used to access, instantiate and call methods of Java
27: * classes.
28: *
29: * @author <a href="mailto:davidw@dedasys.com">David N. Welton</a>
30: * @version 1.0
31: */
32: public class HeclJavaCmd implements org.hecl.Command {
33:
34: public HeclJavaCmd() {
35: }
36:
37: public Thing cmdCode(Interp interp, Thing[] argv)
38: throws HeclException {
39: JavaCmd.load(interp, argv[1].toString(), argv[2].toString());
40: return argv[2];
41: }
42:
43: public static void load(Interp interp) throws HeclException {
44: interp.addCommand("java", new HeclJavaCmd());
45: }
46:
47: public static void unload(Interp interp) {
48: interp.removeCommand("java");
49: }
50: }
|