com.sun.labs.minion.samples
Class MailIndexer

java.lang.Object
  extended by com.sun.labs.minion.samples.MailIndexer

public class MailIndexer
extends java.lang.Object

A main class that indexes a simplified RFC-822ish mail format (mostly fewer headers and no MIME). The aim is to be able to do regression testing on changes to the field store to make sure that it's working correctly.


Field Summary
protected  SearchEngine engine
          The engine that we'll use for searching.
protected  java.util.regex.Pattern header
          A regex pattern for rfc822 headers.
 
Constructor Summary
MailIndexer(java.lang.String indexDir)
          Creates a mail indexer that will index into the given directory.
 
Method Summary
 void close()
          Closes the search engine.
 SearchEngine getSearchEngine()
           
 void indexMBox(java.lang.String mbox)
           
 void indexMBox(java.lang.String mbox, java.lang.String strip)
          Indexes a mailbox at a given path
 void indexMBox(java.net.URL mbox)
           
 void indexMBox(java.net.URL mbox, java.lang.String strip)
          Indexes a mailbox at a given location
static void main(java.lang.String[] args)
          A main program to index a number of mbox files given on the command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

engine

protected SearchEngine engine
The engine that we'll use for searching.


header

protected java.util.regex.Pattern header
A regex pattern for rfc822 headers.

Constructor Detail

MailIndexer

public MailIndexer(java.lang.String indexDir)
            throws SearchEngineException
Creates a mail indexer that will index into the given directory.

Parameters:
indexDir - the name of the directory where the index data will be stored
Throws:
SearchEngineException - if there is any error opening the engine.
Method Detail

getSearchEngine

public SearchEngine getSearchEngine()

close

public void close()
           throws SearchEngineException
Closes the search engine. You need to do this, otherwise the maintenance threads that the search engine starts will never be terminated.

Throws:
SearchEngineException

indexMBox

public void indexMBox(java.lang.String mbox)
               throws java.io.IOException,
                      SearchEngineException
Throws:
java.io.IOException
SearchEngineException

indexMBox

public void indexMBox(java.lang.String mbox,
                      java.lang.String strip)
               throws java.io.IOException,
                      SearchEngineException
Indexes a mailbox at a given path

Parameters:
mbox - the path to the mbox file we want to index
strip - a string to strip from the starts of subjects.
Throws:
java.io.IOException
SearchEngineException

indexMBox

public void indexMBox(java.net.URL mbox)
               throws java.io.IOException,
                      SearchEngineException
Throws:
java.io.IOException
SearchEngineException

indexMBox

public void indexMBox(java.net.URL mbox,
                      java.lang.String strip)
               throws java.io.IOException,
                      SearchEngineException
Indexes a mailbox at a given location

Parameters:
mbox - the path to the mbox file we want to index
Throws:
java.io.IOException
SearchEngineException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        SearchEngineException
A main program to index a number of mbox files given on the command line.

Parameters:
args - the command line arguments
Throws:
java.io.IOException - if there is any exception reading the mbox files
SearchEngineException - if there is any error indexing the data