mirror of https://github.com/apache/archiva.git
Added javadoc annotations
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@359161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4ee2ce3e6
commit
deba390c88
|
@ -27,6 +27,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.IndexWriter;
|
||||
|
||||
/**
|
||||
* Abstract class for RepositoryIndexers
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
|
@ -38,6 +39,9 @@ public abstract class AbstractRepositoryIndexer
|
|||
protected IndexReader indexReader;
|
||||
protected IndexWriter indexWriter;
|
||||
|
||||
/**
|
||||
* method to encapsulate the optimize() method for lucene
|
||||
*/
|
||||
public void optimize()
|
||||
throws RepositoryIndexerException
|
||||
{
|
||||
|
@ -56,11 +60,19 @@ public abstract class AbstractRepositoryIndexer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
|
@ -86,6 +98,9 @@ public abstract class AbstractRepositoryIndexer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method for opening the index directory for indexing operations
|
||||
*/
|
||||
public void open()
|
||||
throws RepositoryIndexerException
|
||||
{
|
||||
|
@ -99,7 +114,6 @@ public abstract class AbstractRepositoryIndexer
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected void getIndexWriter()
|
||||
throws IOException
|
||||
{
|
||||
|
@ -123,6 +137,11 @@ public abstract class AbstractRepositoryIndexer
|
|||
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
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.analysis.CharTokenizer;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
|
||||
/**
|
||||
* Class created specifically to index artifacts
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
|
@ -33,12 +34,25 @@ public class ArtifactRepositoryIndexAnalyzer
|
|||
{
|
||||
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;
|
||||
|
||||
|
@ -54,19 +68,34 @@ public class ArtifactRepositoryIndexAnalyzer
|
|||
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 '-':
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.maven.artifact.Artifact;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
/**
|
||||
* Class used to index Artifact objects in a specified repository
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
|
@ -62,6 +63,14 @@ public class ArtifactRepositoryIndexer
|
|||
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
|
||||
{
|
||||
|
@ -70,11 +79,21 @@ public class ArtifactRepositoryIndexer
|
|||
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
|
||||
{
|
||||
|
@ -89,6 +108,11 @@ public class ArtifactRepositoryIndexer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method to index a given artifact
|
||||
*
|
||||
* @param artifact the Artifact object to be indexed
|
||||
*/
|
||||
public void addArtifactIndex( Artifact artifact )
|
||||
throws RepositoryIndexerException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue