Added javadocs

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@367470 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Edwin L. Punzalan 2006-01-10 03:12:17 +00:00
parent 6707098809
commit ec0735c119
19 changed files with 321 additions and 20 deletions

View File

@ -40,6 +40,14 @@ public abstract class AbstractRepositoryIndex
protected ArtifactRepository repository;
/**
* Class constructor
*
* @param indexPath
* @param repository
* @param indexFields
* @throws RepositoryIndexException
*/
protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository, String[] indexFields )
throws RepositoryIndexException
{
@ -57,7 +65,7 @@ public abstract class AbstractRepositoryIndex
}
/**
* method to encapsulate the optimize() method for lucene
* @see org.apache.maven.repository.indexing.RepositoryIndex#optimize()
*/
public void optimize()
throws RepositoryIndexException
@ -78,9 +86,7 @@ public abstract class AbstractRepositoryIndex
}
/**
* method used to query the index status
*
* @return true if the index is open.
* @see org.apache.maven.repository.indexing.RepositoryIndex#isOpen()
*/
public boolean isOpen()
{
@ -88,7 +94,7 @@ public abstract class AbstractRepositoryIndex
}
/**
* method used to close all open streams to the index directory
* @see org.apache.maven.repository.indexing.RepositoryIndex#close()
*/
public void close()
throws RepositoryIndexException
@ -109,11 +115,20 @@ public abstract class AbstractRepositoryIndex
}
}
/**
* @see org.apache.maven.repository.indexing.RepositoryIndex#getIndexPath()
*/
public String getIndexPath()
{
return indexPath;
}
/**
* Method to retrieve the lucene IndexWriter used in creating/updating the index
*
* @return the lucene IndexWriter object used to update the index
* @throws IOException
*/
protected IndexWriter getIndexWriter()
throws IOException
{
@ -173,6 +188,9 @@ public abstract class AbstractRepositoryIndex
indexOpen = true;
}
/**
* @see org.apache.maven.repository.indexing.RepositoryIndex#getRepository()
*/
public ArtifactRepository getRepository()
{
return repository;

View File

@ -36,7 +36,7 @@ import java.util.Iterator;
import java.util.List;
/**
*
* Abstract Class to hold common codes for the different RepositoryIndexSearcher
*/
public abstract class AbstractRepositoryIndexSearcher
extends AbstractLogEnabled
@ -55,12 +55,7 @@ public abstract class AbstractRepositoryIndexSearcher
}
/**
* Search the artifact based on the search criteria specified in the query
* object. Returns a list of artifact objects
*
* @param query the query object that contains the search criteria
* @return List
* @throws RepositoryIndexSearchException
* @see RepositoryIndexSearcher#search(org.apache.maven.repository.indexing.query.Query)
*/
public List search( Query query )
throws RepositoryIndexSearchException
@ -111,6 +106,14 @@ public abstract class AbstractRepositoryIndexSearcher
return docs;
}
/**
* Method to create a lucene Query object from a single query phrase
*
* @param field the index field name to search into
* @param value the index field value to match the field with
* @return a lucene Query object representing the query phrase field = value
* @throws ParseException
*/
private org.apache.lucene.search.Query createLuceneQuery( String field, String value )
throws ParseException
{
@ -128,6 +131,13 @@ public abstract class AbstractRepositoryIndexSearcher
return qry;
}
/**
* Method to create a lucene Query object by converting a prepared Query object
*
* @param query the prepared Query object to be converted into a lucene Query object
* @return a lucene Query object to represent the passed Query object
* @throws ParseException
*/
private org.apache.lucene.search.Query createLuceneQuery( Query query )
throws ParseException
{

View File

@ -34,7 +34,7 @@ import java.util.zip.ZipFile;
/**
* Class used to index Artifact objects in a specified repository
* Class used to index Artifact objects in a specific repository
*
* @author Edwin Punzalan
*/
@ -66,6 +66,14 @@ public class ArtifactRepositoryIndex
private Digester digester;
/**
* Class constructor
*
* @param indexPath the path where the lucene index will be created/updated.
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
* @throws RepositoryIndexException
*/
public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
throws RepositoryIndexException
{
@ -74,9 +82,7 @@ public class ArtifactRepositoryIndex
}
/**
* method to get the Analyzer used to create indices
*
* @return the Analyzer object used to create the artifact indices
* @see org.apache.maven.repository.indexing.RepositoryIndex#getAnalyzer()
*/
public Analyzer getAnalyzer()
{
@ -89,9 +95,10 @@ public class ArtifactRepositoryIndex
}
/**
* method to index a given artifact
* Method to index a given artifact
*
* @param artifact the Artifact object to be indexed
* @throws RepositoryIndexException
*/
public void indexArtifact( Artifact artifact )
throws RepositoryIndexException
@ -174,11 +181,21 @@ public class ArtifactRepositoryIndex
}
}
/**
* @see RepositoryIndex#isKeywordField(String)
*/
public boolean isKeywordField( String field )
{
return false;
}
/**
* Method to test a zip entry if it is a java class, and adds it to the classes buffer
*
* @param entry the zip entry to test for java class
* @param classes the String buffer to add the java class if the test result as true
* @return true if the zip entry is a java class and was successfully added to the buffer
*/
private boolean addIfClassEntry( ZipEntry entry, StringBuffer classes )
{
boolean isAdded = false;
@ -203,6 +220,13 @@ public class ArtifactRepositoryIndex
return isAdded;
}
/**
* Method to add a class package to the buffer of packages
*
* @param name the complete path name of the class
* @param packages the packages buffer
* @return true if the package is successfully added
*/
private boolean addClassPackage( String name, StringBuffer packages )
{
boolean isAdded = false;
@ -221,6 +245,13 @@ public class ArtifactRepositoryIndex
return isAdded;
}
/**
* Method to add the zip entry as a file list
*
* @param entry the zip entry to be added
* @param files the buffer of files to update
* @return true if the file was successfully added
*/
private boolean addFile( ZipEntry entry, StringBuffer files )
{
String name = entry.getName();

View File

@ -26,7 +26,6 @@ import java.io.File;
* This class searches the index for existing artifacts that contains the
* specified query string.
*
* @author Maria Odea Ching
*/
public class ArtifactRepositoryIndexSearcher
extends AbstractRepositoryIndexSearcher
@ -45,6 +44,9 @@ public class ArtifactRepositoryIndexSearcher
this.factory = factory;
}
/**
* @see AbstractRepositoryIndexSearcher#createSearchedObjectFromIndexDocument(org.apache.lucene.document.Document)
*/
protected Object createSearchedObjectFromIndexDocument( Document doc )
{
String groupId = doc.get( ArtifactRepositoryIndex.FLD_GROUPID );

View File

@ -38,23 +38,35 @@ public class DefaultRepositoryIndexingFactory
*/
private ArtifactFactory artifactFactory;
/**
* @see RepositoryIndexingFactory#createArtifactRepositoryIndexSearcher(ArtifactRepositoryIndex)
*/
public ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index )
{
return new ArtifactRepositoryIndexSearcher( index, artifactFactory );
}
/**
* @see RepositoryIndexingFactory#createArtifactRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
*/
public ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new ArtifactRepositoryIndex( indexPath, repository, digester );
}
/**
* @see RepositoryIndexingFactory#createPomRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
*/
public PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new PomRepositoryIndex( indexPath, repository, digester, artifactFactory );
}
/**
* @see RepositoryIndexingFactory#createPomRepositoryIndexSearcher(PomRepositoryIndex)
*/
public PomRepositoryIndexSearcher createPomRepositoryIndexSearcher( PomRepositoryIndex index )
{
return new PomRepositoryIndexSearcher( index, artifactFactory );

View File

@ -40,6 +40,8 @@ import java.util.Iterator;
import java.util.List;
/**
* Class to create index entries for a given pom in a repository
*
* @author Edwin Punzalan
*/
public class PomRepositoryIndex
@ -79,6 +81,15 @@ public class PomRepositoryIndex
private static final List KEYWORD_FIELDS = Arrays.asList(
new String[]{FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL} );
/**
* Class Constructor
*
* @param indexPath the path where the index is available or will be made available
* @param repository the repository where objects indexed by this class resides
* @param digester the digester to be used for generating checksums
* @param artifactFactory the factory for building artifact objects
* @throws RepositoryIndexException
*/
public PomRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester,
ArtifactFactory artifactFactory )
throws RepositoryIndexException
@ -88,6 +99,9 @@ public class PomRepositoryIndex
this.artifactFactory = artifactFactory;
}
/**
* @see org.apache.maven.repository.indexing.RepositoryIndex#getAnalyzer()
*/
public Analyzer getAnalyzer()
{
if ( analyzer == null )
@ -98,6 +112,12 @@ public class PomRepositoryIndex
return analyzer;
}
/**
* Method to create the index fields for a Model object into the index
*
* @param pom the Model object to be indexed
* @throws RepositoryIndexException
*/
public void indexPom( Model pom )
throws RepositoryIndexException
{
@ -160,11 +180,20 @@ public class PomRepositoryIndex
}
}
/**
* @see RepositoryIndex#isKeywordField(String)
*/
public boolean isKeywordField( String field )
{
return KEYWORD_FIELDS.contains( field );
}
/**
* Method to index license urls found inside the passed pom
*
* @param doc the index object to create the fields for the license urls
* @param pom the Model object to be indexed
*/
private void indexLicenseUrls( Document doc, Model pom )
{
List licenseList = pom.getLicenses();
@ -187,6 +216,12 @@ public class PomRepositoryIndex
}
}
/**
* Method to index declared dependencies found inside the passed pom
*
* @param doc the index object to create the fields for the dependencies
* @param pom the Model object to be indexed
*/
private void indexDependencies( Document doc, Model pom )
{
List dependencyList = pom.getDependencies();
@ -206,6 +241,13 @@ public class PomRepositoryIndex
}
}
/**
* Method to index plugins to a specified index field
*
* @param doc the index object to create the fields for the plugins
* @param field the index field to store the passed plugin
* @param plugins the iterator to the list of plugins to be indexed
*/
private void indexPlugins( Document doc, String field, Iterator plugins )
{
while ( plugins.hasNext() )
@ -216,6 +258,13 @@ public class PomRepositoryIndex
}
}
/**
* Method to index report plugins to a specified index field
*
* @param doc the index object to create the fields for the report plugins
* @param field the index field to store the passed report plugin
* @param plugins the iterator to the list of report plugins to be indexed
*/
private void indexReportPlugins( Document doc, String field, Iterator plugins )
{
while ( plugins.hasNext() )
@ -226,6 +275,14 @@ public class PomRepositoryIndex
}
}
/**
* Method to generate the computed checksum of an existing file using the specified algorithm.
*
* @param algorithm the algorithm to be used to generate the checksum
* @param file the file to match the generated checksum
* @return a string representing the checksum
* @throws RepositoryIndexException
*/
private String getChecksum( String algorithm, String file )
throws RepositoryIndexException
{
@ -243,6 +300,14 @@ public class PomRepositoryIndex
}
}
/**
* Method to create the unique artifact id to represent the artifact in the repository
*
* @param groupId the artifact groupId
* @param artifactId the artifact artifactId
* @param version the artifact version
* @return the String id to uniquely represent the artifact
*/
private String getId( String groupId, String artifactId, String version )
{
return groupId + ":" + artifactId + ":" + version;

View File

@ -20,6 +20,8 @@ import org.apache.lucene.document.Document;
import org.apache.maven.artifact.factory.ArtifactFactory;
/**
* The PomRepositoryIndexSearcher is used to search for artifacts in the index created by a PomRepositoryIndex class.
*
* @author Edwin Punzalan
*/
public class PomRepositoryIndexSearcher
@ -27,12 +29,20 @@ public class PomRepositoryIndexSearcher
{
private ArtifactFactory factory;
/**
*
* @param index the PomRepositoryIndex
* @param artifactFactory
*/
public PomRepositoryIndexSearcher( RepositoryIndex index, ArtifactFactory artifactFactory )
{
super( index );
this.factory = artifactFactory;
}
/**
* @see AbstractRepositoryIndexSearcher#createSearchedObjectFromIndexDocument(org.apache.lucene.document.Document)
*/
protected Object createSearchedObjectFromIndexDocument( Document doc )
{
String groupId = doc.get( PomRepositoryIndex.FLD_GROUPID );

View File

@ -24,19 +24,46 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
*/
public interface RepositoryIndex
{
/**
* Method used to query the index status
*
* @return true if the index is open.
*/
boolean isOpen();
/**
* Method to close open streams to the index directory
*/
void close()
throws RepositoryIndexException;
ArtifactRepository getRepository();
/**
* Method to encapsulate the optimize() method for lucene
*/
void optimize()
throws RepositoryIndexException;
/**
* Method to retrieve the lucene analyzer object used in creating the document fields for this index
*
* @return lucene Analyzer object used in creating the index fields
*/
Analyzer getAnalyzer();
/**
* Method to retrieve the path where the index is made available
*
* @return the path where the index resides
*/
String getIndexPath();
/**
* Tests an index field if it is a keyword field
*
* @param field the name of the index field to test
* @return true if the index field passed is a keyword, otherwise its false
*/
boolean isKeywordField( String field );
}

View File

@ -21,7 +21,7 @@ import org.apache.maven.repository.indexing.query.Query;
import java.util.List;
/**
* @author Maria Odea Ching
*
*/
public interface RepositoryIndexSearcher
{

View File

@ -27,13 +27,41 @@ public interface RepositoryIndexingFactory
{
String ROLE = RepositoryIndexingFactory.class.getName();
/**
* Method to create an instance of the ArtifactRepositoryIndexSearcher
*
* @param index the ArtifactRepositoryIndex instance that the returned searcher will be searching into
* @return the ArtifactRepositoryIndexSearcher instance
*/
ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index );
/**
* Method to create an instance of the ArtifactRepositoryIndex
*
* @param indexPath the path where the index will be created/updated
* @param repository the repository where the indexed artifacts are located
* @return the ArtifactRepositoryIndex instance
* @throws RepositoryIndexException
*/
ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
/**
* Method to create an instance of the PomRepositoryIndex
*
* @param indexPath the path where the index will be created/updated
* @param repository the repository where the indexed poms are located
* @return the PomRepositoryIndex instance
* @throws RepositoryIndexException
*/
PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
/**
* Method to create an instance of the PomRepositoryIndexSearcher
*
* @param index the PomRepositoryIndex instance that the returned searcher will be searching into
* @return the PomRepositoryIndexSearcher instance
*/
PomRepositoryIndexSearcher createPomRepositoryIndexSearcher( PomRepositoryIndex index );
}

View File

@ -29,21 +29,35 @@ public abstract class AbstractCompoundQueryTerm
*/
private Query query;
/**
* Class constructor
*
* @param query the query represented by this object
*/
protected AbstractCompoundQueryTerm( Query query )
{
this.query = query;
}
/**
* @see CompoundQueryTerm#isRequired()
*/
public boolean isRequired()
{
return false;
}
/**
* @see CompoundQueryTerm#isProhibited()
*/
public boolean isProhibited()
{
return false;
}
/**
* @see CompoundQueryTerm#getQuery()
*/
public Query getQuery()
{
return query;

View File

@ -24,11 +24,19 @@ package org.apache.maven.repository.indexing.query;
public class AndQueryTerm
extends AbstractCompoundQueryTerm
{
/**
* Class constructor
*
* @param query the Query object represented by this object
*/
public AndQueryTerm( Query query )
{
super( query );
}
/**
* @see AbstractCompoundQueryTerm#isRequired()
*/
public boolean isRequired()
{
return true;

View File

@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.List;
/**
* Class to hold multiple SinglePhraseQueries and/or other CompoundQueries.
*
* @author Edwin Punzalan
*/
public class CompoundQuery
@ -27,26 +29,52 @@ public class CompoundQuery
{
protected List queries;
/**
* Class constructor
*/
public CompoundQuery()
{
queries = new ArrayList();
}
/**
* Appends a required Query object to this Query object. The Query object will be encapsulated inside an
* AndQueryTerm object.
*
* @param query the Query object to be appended to this Query object
*/
public void and( Query query )
{
queries.add( new AndQueryTerm( query ) );
}
/**
* Appends an optional Query object to this Query object. The Query object will be encapsulated inside an
* OrQueryTerm object.
*
* @param query the Query object to be appended to this Query object
*/
public void or( Query query )
{
queries.add( new OrQueryTerm( query ) );
}
/**
* Appends a prohibited Query object to this Query object. The Query object will be encapsulated inside an
* NotQueryTerm object.
*
* @param query the Query object to be appended to this Query object
*/
public void not( Query query )
{
queries.add( new NotQueryTerm( query ) );
}
/**
* Method to get the List of Queries appended into this
*
* @return List of all Queries added to this Query
*/
public List getQueries()
{
return queries;

View File

@ -23,9 +23,24 @@ package org.apache.maven.repository.indexing.query;
*/
public interface CompoundQueryTerm
{
/**
* Method to test if the Query is a search requirement
*
* @return true if this Query is a search requirement, otherwise returns false
*/
boolean isRequired();
/**
* Method to test if the Query is prohibited in the search result
*
* @return true if this Query is prohibited in the search result
*/
boolean isProhibited();
/**
* Method to get the Query object represented by this object
*
* @return the Query object represented by this object
*/
Query getQuery();
}

View File

@ -24,11 +24,19 @@ package org.apache.maven.repository.indexing.query;
public class NotQueryTerm
extends AbstractCompoundQueryTerm
{
/**
* Class constructor
*
* @param query the Query object represented by this Query object
*/
public NotQueryTerm( Query query )
{
super( query );
}
/**
* @see CompoundQueryTerm#isProhibited()
*/
public boolean isProhibited()
{
return true;

View File

@ -24,6 +24,11 @@ package org.apache.maven.repository.indexing.query;
public class OrQueryTerm
extends AbstractCompoundQueryTerm
{
/**
* Class constructor
*
* @param query the Query object represented by this Query object
*/
public OrQueryTerm( Query query )
{
super( query );

View File

@ -18,6 +18,8 @@ package org.apache.maven.repository.indexing.query;
*/
/**
* Interface to label the query classes
*
* @author Edwin Punzalan
*/
public interface Query

View File

@ -18,6 +18,8 @@ package org.apache.maven.repository.indexing.query;
*/
/**
* Class to hold a single field search condition
*
* @author Edwin Punzalan
*/
public class SinglePhraseQuery
@ -27,17 +29,33 @@ public class SinglePhraseQuery
private String value;
/**
* Class constructor
*
* @param field the index field to search
* @param value the index value requirement
*/
public SinglePhraseQuery( String field, String value )
{
this.field = field;
this.value = value;
}
/**
* Method to retrieve the name of the index field searched
*
* @return the name of the index field
*/
public String getField()
{
return field;
}
/**
* Method to retrieve the value used in searching the index field
*
* @return the value to corresspond the index field
*/
public String getValue()
{
return value;

View File

@ -34,7 +34,7 @@ import java.util.Iterator;
import java.util.List;
/**
* @author Edwin Punzalan/Maria Odea Ching
* @author Edwin Punzalan
*/
public class ArtifactRepositoryIndexingTest
extends PlexusTestCase