org.ceryle.xnode.search
Class XNodeIndexer

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

public class XNodeIndexer
extends Indexer

Extends Indexer (which extends Thread) to build an index for the XNode-based database. This supports incremental indexing of a single document if one or more documents are set via setXNodeID(XNodeID), otherwise this will index the entire XNodeStore.

Note that this class is not reentrant.

Since:
JDK1.4
Version:
$Id: XNodeIndexer.java,v 1.16 2007-06-20 04:42:40 altheim Exp $
Author:
Murray Altheim

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
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
XNodeIndexer(MessageWriter msgwriter, ProgressBar progressbar, boolean closeOnComplete)
          Constructor with a MessageWriter and ProgressBar.
XNodeIndexer(MessageWriter msgwriter, ProgressBar progressbar, XNodeID xid, boolean closeOnComplete)
          Constructor with a MessageWriter, ProgressBar, and a single document, as represented by the XNodeID.
 
Method Summary
 void cancel()
          Cancel any running indexing operation.
 File getIndexDirectory()
          Lazily creates or returns the existing index directory, whose path is set from a property.
protected static boolean isAcceptableFormat(XNode xnode)
          Checks the document format of the provided XNode (via its DC.Format property) to see if it is readable by the search engine, returning true if acceptable.
 boolean restoreIndex()
          Restore the existing index after opening a new session, returning true if successful.
 void run()
          Despite this being an extension of Thread, this method should not be called directly - instead, use Indexer.index(boolean).
 void setXNodeID(XNodeID xid)
          Set the document to be indexed via its XNodeID.
 
Methods inherited from class org.ceryle.util.search.Indexer
closeIndex, deleteIndex, getAnalyzer, getIndexReader, getIndexWriter, getMessageHandler, getMessageWriter, getProgressBar, getStopWords, getVersion, hasProgressBar, index, 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
 

Constructor Detail

XNodeIndexer

public XNodeIndexer(MessageWriter msgwriter,
                    ProgressBar progressbar,
                    boolean closeOnComplete)
             throws SearchException
Constructor with a MessageWriter and ProgressBar. If setXNodeID(XNodeID) is not called to set individual documents, this will cause the entire XNodeStore to be indexed. The closeOnComplete flag is false, the index will remain open following an index operation to allow merging.

Throws:
SearchException

XNodeIndexer

public XNodeIndexer(MessageWriter msgwriter,
                    ProgressBar progressbar,
                    XNodeID xid,
                    boolean closeOnComplete)
             throws SearchException
Constructor with a MessageWriter, ProgressBar, and a single document, as represented by the XNodeID. Additional documents can be added via setXNodeID(XNodeID). The closeOnComplete flag is false, the index will remain open following an index operation to allow merging.

Throws:
SearchException
Method Detail

cancel

public void cancel()
Cancel any running indexing operation.


setXNodeID

public void setXNodeID(XNodeID xid)
Set the document to be indexed via its XNodeID. This can be called multiple times to queue a list of documents.


run

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

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

isAcceptableFormat

protected static boolean isAcceptableFormat(XNode xnode)
Checks the document format of the provided XNode (via its DC.Format property) to see if it is readable by the search engine, returning true if acceptable. The acceptable formats currently include plain text, wiki text, HTML and XHTML.


restoreIndex

public boolean restoreIndex()
Restore the existing index after opening a new session, returning true if successful. Note that the return value only indicates that the IndexReader was able to open the index. The Indexer's isIndexed() method should be used to determine index availability.

Specified by:
restoreIndex in class Indexer

getIndexDirectory

public File getIndexDirectory()
                       throws IOException
Lazily creates or returns the existing index directory, whose path is set from a property.

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


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