Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.help.internal.search
Class SearchIndex  view SearchIndex download SearchIndex.java

java.lang.Object
  extended byorg.eclipse.help.internal.search.SearchIndex
Direct Known Subclasses:
SearchIndexWithIndexingProgress

public class SearchIndex
extends java.lang.Object

Text search index. Documents added to this index can than be searched against a search query.


Field Summary
private  AnalyzerDescriptor analyzerDescriptor
           
private  boolean closed
           
private  org.eclipse.help.internal.base.util.HelpProperties dependencies
           
private static java.lang.String DEPENDENCIES_VERSION_FILENAME
           
private  PluginVersionInfo docPlugins
           
private  java.io.File inconsistencyFile
           
private  java.io.File indexDir
           
private static java.lang.String INDEXED_CONTRIBUTION_INFO_FILE
           
static java.lang.String INDEXED_DOCS_FILE
           
private  org.eclipse.help.internal.base.util.HelpProperties indexedDocs
           
private  org.apache.lucene.index.IndexReader ir
           
private  org.apache.lucene.index.IndexWriter iw
           
private  java.lang.String locale
           
private  java.nio.channels.FileLock lock
           
private static java.lang.String LUCENE_PLUGIN_ID
           
private  HTMLDocParser parser
           
private  org.apache.lucene.search.IndexSearcher searcher
           
private  java.lang.Object searcherCreateLock
           
private  java.util.Collection searches
           
private  org.eclipse.help.internal.toc.TocManager tocManager
           
 
Constructor Summary
SearchIndex(java.lang.String locale, AnalyzerDescriptor analyzerDesc, org.eclipse.help.internal.toc.TocManager tocManager)
          Constructor.
 
Method Summary
 boolean addDocument(java.lang.String name, java.net.URL url)
          Indexes one document from a stream.
 boolean beginAddBatch()
          Starts additions.
 boolean beginDeleteBatch()
          Starts deletions.
 void close()
          Closes IndexReader used by Searcher.
 boolean endAddBatch()
          Finish additions.
 boolean endDeleteBatch()
          Finish deletions.
 boolean exists()
          Checks if index exists and is usable.
private  org.eclipse.help.internal.base.util.HelpProperties getDependencies()
          Gets properties with versions of Lucene plugin and Analyzer used for indexing
 PluginVersionInfo getDocPlugins()
          Returns the list of all the plugins in this session that have declared a help contribution.
 org.eclipse.help.internal.base.util.HelpProperties getIndexedDocs()
          We use HelpProperties, but a list would suffice.
 java.lang.String getLocale()
           
 org.eclipse.help.internal.toc.TocManager getTocManager()
           
 boolean isClosed()
           
 boolean isInconsistent()
           
private  boolean isLuceneCompatible()
          Gets Lucene plugin version from a file.
 boolean needsUpdating()
          Returns true when the index must be updated.
 void openSearcher()
           
private  java.lang.String readAnalyzerId()
          Gets analyzer identifier from a file.
private  void registerSearch(java.lang.Thread t)
           
 void releaseLock()
           
 boolean removeDocument(java.lang.String name)
          Deletes a single document from the index.
private  void saveDependencies()
          Saves Lucene version and analyzer identifier to a file.
 void search(ISearchQuery searchQuery, ISearchHitCollector collector)
          Performs a query search on this index
 void setInconsistent(boolean inconsistent)
          Writes or deletes inconsistency flag file
 boolean tryLock()
           
private  void unregisterSearch(java.lang.Thread t)
           
private  void unzipProductIndex()
          Finds and unzips prebuild index specified in preferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ir

private org.apache.lucene.index.IndexReader ir

iw

private org.apache.lucene.index.IndexWriter iw

indexDir

private java.io.File indexDir

locale

private java.lang.String locale

tocManager

private org.eclipse.help.internal.toc.TocManager tocManager

analyzerDescriptor

private AnalyzerDescriptor analyzerDescriptor

docPlugins

private PluginVersionInfo docPlugins

indexedDocs

private org.eclipse.help.internal.base.util.HelpProperties indexedDocs

INDEXED_CONTRIBUTION_INFO_FILE

private static final java.lang.String INDEXED_CONTRIBUTION_INFO_FILE
See Also:
Constant Field Values

INDEXED_DOCS_FILE

public static final java.lang.String INDEXED_DOCS_FILE
See Also:
Constant Field Values

DEPENDENCIES_VERSION_FILENAME

private static final java.lang.String DEPENDENCIES_VERSION_FILENAME
See Also:
Constant Field Values

LUCENE_PLUGIN_ID

private static final java.lang.String LUCENE_PLUGIN_ID
See Also:
Constant Field Values

inconsistencyFile

private java.io.File inconsistencyFile

parser

private HTMLDocParser parser

searcher

private org.apache.lucene.search.IndexSearcher searcher

searcherCreateLock

private java.lang.Object searcherCreateLock

dependencies

private org.eclipse.help.internal.base.util.HelpProperties dependencies

closed

private boolean closed

searches

private java.util.Collection searches

lock

private java.nio.channels.FileLock lock
Constructor Detail

SearchIndex

public SearchIndex(java.lang.String locale,
                   AnalyzerDescriptor analyzerDesc,
                   org.eclipse.help.internal.toc.TocManager tocManager)
Constructor.

Method Detail

addDocument

public boolean addDocument(java.lang.String name,
                           java.net.URL url)
Indexes one document from a stream. Index has to be open and close outside of this method


beginAddBatch

public boolean beginAddBatch()
Starts additions. To be called before adding documents.


beginDeleteBatch

public boolean beginDeleteBatch()
Starts deletions. To be called before deleting documents.


removeDocument

public boolean removeDocument(java.lang.String name)
Deletes a single document from the index.


endAddBatch

public boolean endAddBatch()
Finish additions. To be called after adding documents.


endDeleteBatch

public boolean endDeleteBatch()
Finish deletions. To be called after deleting documents.


exists

public boolean exists()
Checks if index exists and is usable.


search

public void search(ISearchQuery searchQuery,
                   ISearchHitCollector collector)
            throws QueryTooComplexException
Performs a query search on this index


getLocale

public java.lang.String getLocale()

getDocPlugins

public PluginVersionInfo getDocPlugins()
Returns the list of all the plugins in this session that have declared a help contribution.


getIndexedDocs

public org.eclipse.help.internal.base.util.HelpProperties getIndexedDocs()
We use HelpProperties, but a list would suffice. We only need the key values.


getDependencies

private org.eclipse.help.internal.base.util.HelpProperties getDependencies()
Gets properties with versions of Lucene plugin and Analyzer used for indexing


readAnalyzerId

private java.lang.String readAnalyzerId()
Gets analyzer identifier from a file.


isLuceneCompatible

private boolean isLuceneCompatible()
Gets Lucene plugin version from a file.


saveDependencies

private void saveDependencies()
Saves Lucene version and analyzer identifier to a file.


isInconsistent

public boolean isInconsistent()

setInconsistent

public void setInconsistent(boolean inconsistent)
Writes or deletes inconsistency flag file


openSearcher

public void openSearcher()
                  throws java.io.IOException

close

public void close()
Closes IndexReader used by Searcher. Should be called on platform shutdown, or when TOCs have changed when no more reading from this index is to be performed.


unzipProductIndex

private void unzipProductIndex()
Finds and unzips prebuild index specified in preferences


needsUpdating

public boolean needsUpdating()
Returns true when the index must be updated.


getTocManager

public org.eclipse.help.internal.toc.TocManager getTocManager()

registerSearch

private void registerSearch(java.lang.Thread t)

unregisterSearch

private void unregisterSearch(java.lang.Thread t)

isClosed

public boolean isClosed()

tryLock

public boolean tryLock()
                throws java.nio.channels.OverlappingFileLockException

releaseLock

public void releaseLock()