The class SearchDemo is an applet, so it extends the class Applet. SearchDemo defines init() and main() methods which allow it to run as an applet or as a stand alone (command line) program.
/**
* Applet/application for simple query interface. Can be used as an
* example for those who want to create their own java interface.
* This example demonstrates search only. Browse, determining
* the schema of the search server and obtaining the taxonomy
* of the search server will be demonstrated in other examples.
*/
public class SearchDemo extends Applet {
/** Run as an applet. */
public void init() {
String rdm = getParameter("RDMServer");
SimpleSearch ss = new SimpleSearch(rdm);
SearchPanel sp = new SearchPanel(ss);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(sp);
}
/** Run as an application. */
public static void main(String argv[]) throws Exception {
int args = argv.length;
String SOIFOutputFile = null;
if (args != 1 && args != 2 && args != 3) {
System.out.println("args: RDMServer [query]
[soif_output_file_name]");
return;
}
String rdm = argv[0]; // rdm search server, eg,
// http://portal.siroe.com:2222/ps/search
SimpleSearch ss = new SimpleSearch(rdm);
if (args == 3) {
--args;
ss.setSOIFfile(argv[2]); // dump raw soif results to this file
}
if (args == 1) {
// run from a search box
Frame f = new Frame();
SearchPanel sp = new SearchPanel(ss);
f.add(sp);
f.pack();
f.show();
}
else {
// run from command line
String query = argv[1];
ss.doSearch(query);
}
}
}
|
There is a helper class called SearchPanel which handle the applet GUI. It sets up a search panel with a text box to enter a query and a submit button to run the query. See the source file for more details.