System.out.println("Element occurrences in collection "
+ current.getName());
System.out
.println("--------------------------------------------"
+ "-----------");
final IndexQueryService service = (IndexQueryService) current
.getService("IndexQueryService", "1.0");
final Occurrences[] elements = service.getIndexedElements(true);
for (int i = 0; i < elements.length; i++) {
System.out
.println(formatString(elements[i].getTerm().toString(),
Integer.toString(elements[i]
.getOccurrences()), 50));
}
return true;
} else if (args[0].equalsIgnoreCase("terms")) {
if (args.length < 3) {
System.out
.println("Usage: terms [xpath] sequence-start sequence-end");
return true;
}
final IndexQueryService service = (IndexQueryService) current
.getService("IndexQueryService", "1.0");
Occurrences[] terms;
if (args.length == 3) {
terms = service.scanIndexTerms(args[1], args[2], true);
} else {
terms = service.scanIndexTerms(args[1], args[2], args[3]);
}
System.out.println("Element occurrences in collection " + current.getName());
System.out.println("-------------------------------------------------------");
for (int i = 0; i < terms.length; i++) {
System.out.println(formatString(terms[i].getTerm().toString(), Integer.toString(terms[i].getOccurrences()), 50));
}
} else if (args[0].equalsIgnoreCase("xupdate")) {
if (startGUI) {
messageln("command not supported in GUI mode.");
return true;
}
String lastLine, command = "";
try {
while (true) {
lastLine = console.readLine("| ");
if (lastLine == null || lastLine.length() == 0) {
break;
}
command += lastLine;
}
} catch (final EOFException e) {
//TODO report error?
} catch (final IOException e) {
//TODO report error?
}
final String xupdate = "<xu:modifications version=\"1.0\" "
+ "xmlns:xu=\"http://www.xmldb.org/xupdate\">"
+ command + "</xu:modifications>";
final XUpdateQueryService service = (XUpdateQueryService) current
.getService("XUpdateQueryService", "1.0");
final long mods = service.update(xupdate);
System.out.println(mods + " modifications processed.");
} else if (args[0].equalsIgnoreCase("map")) {
final StringTokenizer tok = new StringTokenizer(args[1], "= ");
final String prefix;