package doc.client;
import java.util.ArrayList;
import doc.bo.Document;
import doc.bo.DocumentSearcher;
/**
* Client class of the DocumentSearcher. It's the interface to the enduser
* @author Michael Glatter-Götz
*
* ID date description
* michael 02.10.2006 creation
*
**/
public class DocumentClient
{
/**
* Main method which handles the command line parameters given by the user
* @param asArgs Array of parameters
**/
public static void main(String[] asArgs)
{
DocumentSearcher oDocumentSearcher = new DocumentSearcher();
if ((asArgs[0].contentEquals("-findAll")) && (asArgs.length == 1))
{
ArrayList _aoAllDocuments = oDocumentSearcher.findAll();
for (Document i : _aoAllDocuments)
{
System.out.println(i.toString());
}
}
else if ((asArgs[0].contentEquals("-find")) && (asArgs.length == 2))
{
ArrayList aoFoundDocuments = oDocumentSearcher.findByAuthor(asArgs[1]);
for (Document i : aoFoundDocuments)
{
System.out.println(i.toString());
}
}
else
{
usage();
}
}
/**
* Prints usage information for the DocumentClient
**/
public static void usage()
{
String sOut = "";
sOut += "Usage of the DocumentClient:\n";
sOut += "DocumentClient action [search string]\n\n";
sOut += "action:\n";
sOut += " -findAll finds and prints all documents\n";
sOut += " -find [param] finds all documents written by the given author (param)";
System.out.println(sOut);
}
}