org.apache.lenya.lucene.index
Class AbstractIndexer

java.lang.Object
  extended by org.apache.lenya.lucene.index.AbstractIndexer
All Implemented Interfaces:
Indexer
Direct Known Subclasses:
ConfigurableIndexer, DefaultIndexer

public abstract class AbstractIndexer
extends java.lang.Object
implements Indexer

Abstract base class for indexers. The factory method #getDocumentCreator(String[]) is used to create a DocumentCreator from the command-line arguments.


Nested Class Summary
 class AbstractIndexer.CreateIndexHandler
          DOCUMENT ME!
static class AbstractIndexer.DefaultIndexFilter
          FileFilter used to obtain the files to index.
static class AbstractIndexer.DeleteHandler
          Deletes all stale documents up to the document representing the next file.
 class AbstractIndexer.IndexHandler
          DOCUMENT ME!
 class AbstractIndexer.UpdateIndexHandler
          DOCUMENT ME!
 
Constructor Summary
AbstractIndexer()
          Creates a new instance of AbstractIndexer
 
Method Summary
 void configure(org.w3c.dom.Element indexer, java.lang.String configFileName)
          Initializes this indexer with command-line parameters.
abstract  DocumentCreator createDocumentCreator(org.w3c.dom.Element indexer, java.lang.String configFileName)
          DOCUMENT ME!
 void createIndex(java.io.File dumpDirectory, java.io.File index)
          Creates a new index.
protected  void deleteStaleDocuments(java.io.File dumpDirectory, java.io.File index)
          Delete the stale documents.
 void doIndex(java.io.File dumpDirectory, java.io.File index, boolean create)
          Index files
protected  DocumentCreator getDocumentCreator()
          Returns the DocumentCreator of this indexer.
 java.io.FileFilter getFilter(org.w3c.dom.Element indexer, java.lang.String configFileName)
          Returns the filter used to receive the indexable files.
 void indexDocument(java.io.File file)
          Updates the index re one document old documents to be deleted unchanged documents, to be left alone, or new documents, to be indexed.
 void updateIndex(java.io.File dumpDirectory, java.io.File index)
          Updates the index incrementally.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractIndexer

public AbstractIndexer()
Creates a new instance of AbstractIndexer

Method Detail

getDocumentCreator

protected DocumentCreator getDocumentCreator()
Returns the DocumentCreator of this indexer.


configure

public void configure(org.w3c.dom.Element indexer,
                      java.lang.String configFileName)
               throws java.lang.Exception
Initializes this indexer with command-line parameters.

Specified by:
configure in interface Indexer
Throws:
java.lang.Exception

createDocumentCreator

public abstract DocumentCreator createDocumentCreator(org.w3c.dom.Element indexer,
                                                      java.lang.String configFileName)
                                               throws java.lang.Exception
DOCUMENT ME!

Parameters:
element - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.Exception - DOCUMENT ME!

updateIndex

public void updateIndex(java.io.File dumpDirectory,
                        java.io.File index)
                 throws java.lang.Exception
Updates the index incrementally. Walk directory hierarchy in uid order, while keeping uid iterator from existing index in sync. Mismatches indicate one of:
  1. old documents to be deleted
  2. unchanged documents, to be left alone, or
  3. new documents, to be indexed.

Specified by:
updateIndex in interface Indexer
Throws:
java.lang.Exception

indexDocument

public void indexDocument(java.io.File file)
                   throws java.lang.Exception
Updates the index re one document
  1. old documents to be deleted
  2. unchanged documents, to be left alone, or
  3. new documents, to be indexed.

Specified by:
indexDocument in interface Indexer
Throws:
java.lang.Exception

createIndex

public void createIndex(java.io.File dumpDirectory,
                        java.io.File index)
                 throws java.lang.Exception
Creates a new index.

Specified by:
createIndex in interface Indexer
Throws:
java.lang.Exception

doIndex

public void doIndex(java.io.File dumpDirectory,
                    java.io.File index,
                    boolean create)
Index files

Parameters:
dumpDirectory - Directory where the files to be indexed are located
index - Directory where the index shall be located
create - true means the index will be created from scratch, false means it will be indexed incrementally

deleteStaleDocuments

protected void deleteStaleDocuments(java.io.File dumpDirectory,
                                    java.io.File index)
                             throws java.lang.Exception
Delete the stale documents.

Throws:
java.lang.Exception

getFilter

public java.io.FileFilter getFilter(org.w3c.dom.Element indexer,
                                    java.lang.String configFileName)
Returns the filter used to receive the indexable files. Might be overwritten by inherited class.



Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.