Bill,
I've put out a new jar file,
ftp://ftp.parc.xerox.com/transient/janssen/plucker-build-1.3exp.jar,
which implements the new API I outlined on plucker-dev. In particular,
it implements the following interface:
package org.plkr.distiller.API;
public interface Invocation {
int invoke (java.lang.String[] arguments,
java.io.OutputStream optional_output_channel,
java.lang.String optional_input_String,
java.util.Hashtable optional_config_parameters,
org.plkr.distiller.API.Callback optional_status_callback)
throws java.lang.Exception;
};
where the class org.plkr.distiller.InvokePluckerBuildFromJava actually
implements the interface.
The Callback class looks like:
package org.plkr.distiller.API;
public interface Callback {
void update (int number_collected, int number_in_queue);
};
I've tested it, and it all seems to work. You can either use it in
command-line mode, with
java -jar plucker-build-1.3exp.jar ARGS
or call it from a Java program. Note that "null" can be passed for
any of the parameters marked as optional. Here's a simple program I
used to test the API:
import java.io.*;
import java.util.*;
import org.plkr.distiller.API.Callback;
public class call_plucker {
public static void main(String[] args) {
Callback cb = new Callback() {
public void update (int ncollected, int nqueued) {
System.out.println("== " + ncollected + " collected, "
+ nqueued + " in queue ==");
}
};
ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
String input_string =
"<BODY><A HREF=\"http://www.plkr.org/\">Plucker</A></BODY>";
Hashtable config_options = new Hashtable();
// set some initial configuration options
config_options.put("home_maxdepth", "2");
config_options.put("verbosity", "0");
// call the distiller
try {
int result = new
org.plkr.distiller.InvokePluckerBuildFromJava().invoke(args,
output_stream,
input_string,
config_options,
cb);
System.out.println("distiller returns " + result);
// write the file
FileOutputStream f = new FileOutputStream ("foo.plkr");
f.write(output_stream.toByteArray());
f.flush();
f.close();
output_stream.close();
System.out.println("wrote foo.plkr");
System.exit(0);
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(1);
}
}
};
Please try it for a bit and see if I've missed something. I'll check
things in then; I still have to figure out how to build this properly
from a Makefile, and where to put the generated javadoc output.
This API will also be available for use with Python in the next
release. And I could probably be persuaded to put together a C API as
well if Robert wanted one.
Bill
_______________________________________________
plucker-dev mailing list
[EMAIL PROTECTED]
http://lists.rubberchicken.org/mailman/listinfo/plucker-dev