org.ceryle.util.search
Class FSIndexer

java.lang.Object
  extended by java.lang.Thread
      extended by org.ceryle.util.search.Indexer
          extended by org.ceryle.util.search.FSIndexer
All Implemented Interfaces:
Runnable

public class FSIndexer
extends Indexer

Extends the Indexer API to build an index for the provided file system (FS) directory. This wraps a lot of existing functionality into one general package, which nevertheless does not currently provide support for proprietary document formats.

Note that this class is not reentrant.

Since:
JDK1.4
Version:
$Id: FSIndexer.java,v 1.12 2007-06-20 01:28:34 altheim Exp $
Author:
Murray Altheim

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  Set m_directories
           
 
Fields inherited from class org.ceryle.util.search.Indexer
ANALYZER_SIMPLE, ANALYZER_STANDARD, ANALYZER_TYPE, create, m_analyzer, m_indexDirectory, m_writer, mh, mw, progress, SEARCH_INDEX_PATH, srvs, THREAD_PRIORITY
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FSIndexer(MessageWriter msgwriter, ProgressBar progressbar)
          Constructor for a file system indexer, with a MessageWriter and optional ProgressBar.
 
Method Summary
 File getIndexDirectory()
          Lazily creates or returns the existing index directory, whose path is set from a property.
 void index(boolean createIndex)
          Index the selected directories.
protected  void indexDocuments(org.apache.lucene.index.IndexWriter writer, File file)
          Used recursively to index a directory's documents.
 boolean restoreIndex()
          Restore the existing index after opening a new session, returning the IndexReader if successful, null if not.
 void run()
          Despite this being an extension of Thread, this method should not be called directly - instead, use index(boolean).
 void setSourceDirectories(Set directories)
          Sets the Set of source directories to be indexed.
 
Methods inherited from class org.ceryle.util.search.Indexer
closeIndex, deleteIndex, getAnalyzer, getIndexReader, getIndexWriter, getMessageHandler, getMessageWriter, getProgressBar, getStopWords, getVersion, hasProgressBar, isCreateIndex, isIndexed, mergeIndex, setCreateIndex, setIndexDirectory, setIsIndexed, setProgressBar
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_directories

protected Set m_directories
Constructor Detail

FSIndexer

public FSIndexer(MessageWriter msgwriter,
                 ProgressBar progressbar)
          throws SearchException
Constructor for a file system indexer, with a MessageWriter and optional ProgressBar. The Set of source directories are not supplied here, and must be set prior to indexing with the setSourceDirectories(Set) method.

Parameters:
msgwriter - to receive status and other messages.
progressbar - (optional) to track search status.
Throws:
SearchException
Method Detail

setSourceDirectories

public void setSourceDirectories(Set directories)
Sets the Set of source directories to be indexed.


run

public void run()
Despite this being an extension of Thread, this method should not be called directly - instead, use index(boolean).

Specified by:
run in interface Runnable
Specified by:
run in class Indexer

indexDocuments

protected void indexDocuments(org.apache.lucene.index.IndexWriter writer,
                              File file)
                       throws IOException,
                              SearchException
Used recursively to index a directory's documents.

Throws:
IOException
SearchException

index

public void index(boolean createIndex)
Index the selected directories. If createIndex is true, any existing index will be overwritten.

Overrides:
index in class Indexer

getIndexDirectory

public File getIndexDirectory()
                       throws IOException
Lazily creates or returns the existing index directory, whose path is set from a property. This must be called at least once prior to searching to set the value.

Overrides:
getIndexDirectory in class Indexer
Throws:
IOException - if for any reason the directory is not made available.

restoreIndex

public boolean restoreIndex()
Restore the existing index after opening a new session, returning the IndexReader if successful, null if not.

Specified by:
restoreIndex in class Indexer


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.