args = line.getArgs();
if(line.hasOption('h') || args.length <= 0){
printHelp();
System.exit(0);
}
Indexer indexer;
IndexerFactory factory = IndexerFactory.getInstance();
String path = null;
if(args.length > 1){
path = args[1];
}
if("init".equalsIgnoreCase(args[0]) ||
"index".equalsIgnoreCase(args[0]) ||
"postprocess".equalsIgnoreCase(args[0]) ||
"finalise".equalsIgnoreCase(args[0])){
if(path != null){
indexer = factory.create(path);
} else {
indexer = factory.create();
}
if(line.hasOption('c')){
int cunckSize = Integer.parseInt(line.getOptionValue('c'));
indexer.setChunkSize(cunckSize);
}
if("index".equalsIgnoreCase(args[0])){
indexer.index();
} else if("postprocess".equalsIgnoreCase(args[0])){
indexer.initialiseIndexing();
indexer.skipIndexEntities();
indexer.postProcessEntities();
indexer.finaliseIndexing();
} else if ("finalise".equalsIgnoreCase(args[0])){
indexer.initialiseIndexing();
indexer.skipIndexEntities();
indexer.skipPostProcessEntities();
indexer.finaliseIndexing();
}
} else {
System.err.println("Unknown command "+args[0]+" (supported: init,index)\n\n");
printHelp();
}