import org.apache.lucene.index.IndexWriter;
/**
+ * Abstract class for RepositoryIndexers
*
* @author Edwin Punzalan
*/
protected IndexReader indexReader;
protected IndexWriter indexWriter;
+ /**
+ * method to encapsulate the optimize() method for lucene
+ */
public void optimize()
throws RepositoryIndexerException
{
}
}
+ /**
+ * method used to query the index status
+ *
+ * @param true if the index is open.
+ */
public boolean isOpen()
{
return indexOpen;
}
+ /**
+ * method used to close all open streams to the index directory
+ */
public void close()
throws RepositoryIndexerException
{
}
}
+ /**
+ * method for opening the index directory for indexing operations
+ */
public void open()
throws RepositoryIndexerException
{
}
}
-
protected void getIndexWriter()
throws IOException
{
return new ArtifactRepositoryIndexAnalyzer( new SimpleAnalyzer() );
}
+ /**
+ * method for validating an index directory
+ *
+ * @throws RepositoryIndexerException if the given indexPath is not valid for this type of RepositoryIndexer
+ */
protected void validateIndex()
throws RepositoryIndexerException
{
import org.apache.lucene.analysis.TokenStream;
/**
+ * Class created specifically to index artifacts
*
* @author Edwin Punzalan
*/
{
private Analyzer defaultAnalyzer;
+ /**
+ * constructor to for this analyzer
+ *
+ * @character defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces
+ */
public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
{
this.defaultAnalyzer = defaultAnalyzer;
}
- public TokenStream tokenStream(String fieldName, Reader reader)
+ /**
+ * Method called by lucence during indexing operations
+ *
+ * @character fieldName the field name that the lucene object is currently processing
+ * @character reader a Reader object to the index stream
+ *
+ * @return an analyzer to specific to the field name or the default analyzer if none is present
+ */
+ public TokenStream tokenStream( String fieldName, Reader reader )
{
TokenStream tokenStream;
return tokenStream;
}
+ /**
+ * Class used to tokenize an artifact's version.
+ */
private class VersionTokenizer
extends CharTokenizer
{
+ /**
+ * Constructor with the required reader to the index stream
+ *
+ * @reader the Reader object of the index stream
+ */
public VersionTokenizer( Reader reader )
{
super( reader );
}
- protected boolean isTokenChar( char param )
+ /**
+ * method that lucene calls to check tokenization of a stream character
+ *
+ * @param character char currently being processed
+ *
+ * @return true if the char is a token, false if the char is a stop char
+ */
+ protected boolean isTokenChar( char character )
{
boolean token;
- switch( param )
+ switch( character )
{
case '.':
case '-':
import org.apache.maven.artifact.repository.ArtifactRepository;
/**
+ * Class used to index Artifact objects in a specified repository
*
* @author Edwin Punzalan
*/
private StringBuffer packages;
private StringBuffer files;
+ /**
+ * Constructor
+ * @todo change repository to layout ???
+ *
+ * @param repository the repository where the indexed artifacts are located. This is necessary only to distinguish
+ * between default and legacy directory structure of the artifact location.
+ * @param path the directory where the index is located or will be created.
+ */
public ArtifactRepositoryIndexer( ArtifactRepository repository, String path )
throws RepositoryIndexerException
{
validateIndex();
}
+ /**
+ * method for collecting the available index fields usable for searching
+ *
+ * @return index field names
+ */
public String[] getIndexFields()
{
return FIELDS;
}
+ /**
+ * generic method for indexing
+ *
+ * @param obj the object to be indexed by this indexer
+ */
public void addObjectIndex(Object obj)
throws RepositoryIndexerException
{
}
}
+ /**
+ * method to index a given artifact
+ *
+ * @param artifact the Artifact object to be indexed
+ */
public void addArtifactIndex( Artifact artifact )
throws RepositoryIndexerException
{