Java to MINERVA Interface

Embed MINERVA in your Java programs:

See also the javadoc style documentation.

If you only want to extend MINERVA with some Java classes/methods, then we recommend to use the MINERVA Extender minervax. This tools also allows to generate a new main program, which shows how to activate MINERVA.

If you want to use the class Minerva as a kind of thread not in charge of user interaction, for example because you prefer to use a GUI written with some other tool, then you can instantiate the class Minerva directly, invoke and obtain results with its method execute.

At instantiation time take care to supply the needed parameters; see the minerva* scripts for examples. If you invoke MINERVA from an applet you must also supply the reference to the applet.

The class Minerva knows two constructors:

    public Minerva(String[] args)
    public Minerva(Applet applet, String[] args)

The former is for convenience, it simply calls Minerva(null,args). Use the second one for invokation from an applet.

Example:

public class Test extends Applet {
    Minerva minerva = null;
    ...
    public void start() {
        String args = new String[2];
        args[0] = "-c";
        args[1] = "/minerva/minervagui.mca";
        minerva = new Minerva(this, args);
        ...
    }
    ...
}

The interface from Java to MINERVA knows the following classes. (Abstract methods of the superclasses are of course defined in the subclasses but are not again listed there.)

The following desribes the invocation interface of MINERVA from Java. The methods execute expect objects of type MinervaTerm. The methods execute can return results to Java.

When execute is called successfully, all objects of type MinervaVariable are associated (setValue()) with the terms they are unified with at exit time of the call.

Example:

import com.ifcomputer.minerva.*;

public class Test {

private static MinervaTerm makeChar(char c) { return new MinervaAtom(String.valueOf(c)); }

private static MinervaTerm makeList(String s) { MinervaTerm list = new MinervaAtom("[]"); for ( int i = s.length()-1; i >= 0; --i ) list = new MinervaList(makeChar(s.charAt(i)), list); return list; }

public static void main(String args[]) throws Exception { Minerva minerva = new Minerva(args); MinervaVariable v = new MinervaVariable(); MinervaTerm l1 = makeList("abc"); MinervaTerm l2 = makeList("def"); if ( minerva.execute("append", l1, l2, v) ) { System.out.println("append("+l1+", "+l2+") = "+v.getValue()); } else { System.out.println("execution failed"); } } }


Darueber read on...