FileDocCategorySizeDatePackage
PlayIndexer.javaAPI DocExample3357Wed May 18 09:39:02 BST 2005com.discursive.jccook.xml.bardsearch

PlayIndexer

public class PlayIndexer extends Object

Fields Summary
private static Logger
logger
private IndexWriter
indexWriter
private org.apache.commons.digester.Digester
digester
private DigestContext
context
Constructors Summary
public PlayIndexer(IndexWriter pIndexWriter)

        indexWriter = pIndexWriter;
    
Methods Summary
public voidindex(java.io.File playXml)

        context = new DigestContext();
        digester.push( context );
        digester.parse( playXml );
        logger.info( "Parsed: " + playXml.getAbsolutePath() );
    
public voidinit()

        URL playRules = PlayIndexer.class.getResource("play-digester-rules.xml");
        digester = DigesterLoader.createDigester( playRules );
        digester.setValidating(false);
    
public voidprocessSpeech()

        Document doc = new Document();
        doc.add(Field.Text("play", context.playTitle));
        doc.add(Field.Text("act", context.actTitle));
        doc.add(Field.Text("scene", context.sceneTitle));
        doc.add(Field.Text("speaker", context.speaker));
        doc.add(Field.Text("speech", context.speech.toString()));
        try {
            indexWriter.addDocument( doc );
        } catch( IOException ioe ) {
            logger.error( "Unable to add document to index", ioe);
        }