public class IndexDatabase
extends java.lang.Object
Constructor and Description |
---|
IndexDatabase()
Create a new instance of the Index Database.
|
IndexDatabase(Project project)
Create a new instance of an Index Database for a given project
|
Modifier and Type | Method and Description |
---|---|
boolean |
addDirectory(java.lang.String dir)
By default the indexer will traverse all directories in the project.
|
void |
addIndexChangedListener(IndexChangedListener listener)
Register an object to receive events when modifications is done to the
index database.
|
void |
createSpellingSuggestions()
Generate a spelling suggestion for the definitions stored in defs
|
boolean |
equals(java.lang.Object obj) |
static Definitions |
getDefinitions(java.io.File file)
Get the latest definitions for a file from the index.
|
static org.apache.lucene.index.IndexReader |
getIndexReader(java.lang.String path)
Get an indexReader for the Index database where a given file
|
int |
hashCode() |
void |
interrupt()
Interrupt the index generation (and the index generation will stop as
soon as possible)
|
static void |
listAllFiles()
List all files in all of the index databases
|
static void |
listAllFiles(java.util.List<java.lang.String> subFiles)
List all files in some of the index databases
|
void |
listFiles()
List all of the files in this index database
|
void |
listTokens(int freq) |
void |
optimize()
Optimize the index database
|
void |
removeIndexChangedListener(IndexChangedListener listener)
Remove an object from the lists of objects to receive events when
modifications is done to the index database
|
void |
update()
Update the content of this index database
|
static void |
update(java.util.concurrent.ExecutorService executor,
IndexChangedListener listener,
java.util.List<java.lang.String> paths)
Update the index database for a number of sub-directories
|
static void |
updateAll(java.util.concurrent.ExecutorService executor)
Update the index database for all of the projects.
|
public IndexDatabase() throws java.io.IOException
java.io.IOException
- if an error occurs while creating directoriespublic IndexDatabase(Project project) throws java.io.IOException
project
- the project to create the database forjava.io.IOException
- if an errror occurs while creating directoriespublic static void updateAll(java.util.concurrent.ExecutorService executor) throws java.io.IOException
executor
- An executor to run the jobjava.io.IOException
- if an error occurspublic static void update(java.util.concurrent.ExecutorService executor, IndexChangedListener listener, java.util.List<java.lang.String> paths) throws java.io.IOException
executor
- An executor to run the joblistener
- where to signal the changes to the databasepaths
- java.io.IOException
- if an error occurspublic boolean addDirectory(java.lang.String dir)
dir
- The directory to scantrue
if the file is added, false othpublic void update() throws java.io.IOException, HistoryException
java.io.IOException
- if an error occursHistoryException
- if an error occurs when accessing the historypublic void optimize()
public void createSpellingSuggestions()
public void interrupt()
public void addIndexChangedListener(IndexChangedListener listener)
listener
- the object to receive the eventspublic void removeIndexChangedListener(IndexChangedListener listener)
listener
- the object to removepublic static void listAllFiles() throws java.io.IOException
java.io.IOException
- if an error occurspublic static void listAllFiles(java.util.List<java.lang.String> subFiles) throws java.io.IOException
subFiles
- Subdirectories for the various projects to list the files
for (or null or an empty list to dump all projects)java.io.IOException
- if an error occurspublic void listFiles() throws java.io.IOException
java.io.IOException
- If an IO error occurs while reading from the databasepublic void listTokens(int freq) throws java.io.IOException
java.io.IOException
public static org.apache.lucene.index.IndexReader getIndexReader(java.lang.String path)
path
- the file to get the database forpublic static Definitions getDefinitions(java.io.File file) throws java.io.IOException, org.apache.lucene.queryParser.ParseException, java.lang.ClassNotFoundException
file
- the file whose definitions to findnull
if they could not
be foundjava.io.IOException
- if an error happens when accessing the indexorg.apache.lucene.queryParser.ParseException
- if an error happens when building the Lucene queryjava.lang.ClassNotFoundException
- if the class for the stored definitions
instance cannot be foundpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object