From: Edwin L. Punzalan Date: Tue, 27 Dec 2005 02:57:56 +0000 (+0000) Subject: Refactor and code formatting only X-Git-Tag: archiva-0.9-alpha-1~1043 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36a17707a6ee58412a38f10bd710160b0f2b0643;p=archiva.git Refactor and code formatting only git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@359163 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositorySearcher.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositorySearcher.java index 58a71bd4d..03294883b 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositorySearcher.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositorySearcher.java @@ -47,7 +47,9 @@ import org.apache.maven.artifact.versioning.VersionRange; * specified query string. * */ -public class ArtifactRepositorySearcher implements RepositorySearcher { +public class ArtifactRepositorySearcher + implements RepositorySearcher +{ private IndexSearcher searcher; private ArtifactRepository repository; @@ -66,26 +68,25 @@ public class ArtifactRepositorySearcher implements RepositorySearcher { * @param indexPath * @param repository */ - public ArtifactRepositorySearcher(String indexPath, - ArtifactRepository repository) { - + public ArtifactRepositorySearcher( String indexPath, + ArtifactRepository repository ) + { this.repository = repository; factory = new DefaultArtifactFactory(); - try { - searcher = new IndexSearcher(indexPath); - } catch (IOException ie) { + try + { + searcher = new IndexSearcher( indexPath ); + } + catch ( IOException ie ) + { ie.printStackTrace(); } } protected Analyzer getAnalyzer() { - //PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new SimpleAnalyzer()); - //wrapper.addAnalyzer(VERSION, new StandardAnalyzer()); - - //return wrapper; - return new ArtifactRepositoryIndexAnalyzer(new SimpleAnalyzer()); + return new ArtifactRepositoryIndexAnalyzer( new SimpleAnalyzer() ); } /** @@ -96,27 +97,19 @@ public class ArtifactRepositorySearcher implements RepositorySearcher { * @param searchField * @return */ - public List searchArtifact(String queryString, String searchField) { - - - QueryParser parser = new QueryParser(searchField, - getAnalyzer()); - Query qry = null; + public List searchArtifact( String queryString, String searchField ) + { List artifactList = new ArrayList(); try { - qry = parser.parse(queryString); - } catch (ParseException pe) { - pe.printStackTrace(); - return artifactList; - } - - try { - Hits hits = searcher.search(qry); + QueryParser parser = new QueryParser( searchField, getAnalyzer() ); + Query qry = parser.parse( queryString ); + Hits hits = searcher.search( qry ); //System.out.println("HITS SIZE --> " + hits.length()); - for (int i = 0; i < hits.length(); i++) { - Document doc = hits.doc(i); + for ( int i = 0; i < hits.length(); i++ ) + { + Document doc = hits.doc( i ); // System.out.println("==========================="); // System.out.println("NAME :: " + (String) doc.get(NAME)); // System.out.println("GROUP ID :: " + (String) @@ -134,42 +127,41 @@ public class ArtifactRepositorySearcher implements RepositorySearcher { // System.out.println("FILES :: " + (String) doc.get(FILES)); // System.out.println("==========================="); - String name = (String) doc.get(NAME); + String name = (String) doc.get( NAME ); String type = ""; - if ((name.substring(name.length() - 3).toLowerCase()) - .equals(JAR_TYPE)) + if ( ( name.substring( name.length() - 3 ).toLowerCase() ).equals( JAR_TYPE ) ) + { type = JAR_TYPE; - else if ((name.substring(name.length() - 3).toLowerCase()) - .equals(XML_TYPE) - || (name.substring(name.length() - 3).toLowerCase()) - .equals(POM_TYPE)) + } + else if ( ( name.substring( name.length() - 3 ).toLowerCase() ).equals( XML_TYPE ) || + ( name.substring( name.length() - 3 ).toLowerCase() ).equals( POM_TYPE ) ) + { type = POM_TYPE; + } - if (!type.equals("") && type != null) { - ArtifactHandler handler = new DefaultArtifactHandler(type); - VersionRange version = VersionRange - .createFromVersion((String) doc.get(VERSION)); + if ( type != null && type.length() > 0 ) + { + ArtifactHandler handler = new DefaultArtifactHandler( type ); + VersionRange version = VersionRange.createFromVersion( (String) doc.get( VERSION ) ); - Artifact artifact = new DefaultArtifact((String) doc - .get(GROUPID), (String) doc.get(ARTIFACTID), - version, "compile", type, "", handler); + Artifact artifact = new DefaultArtifact((String) doc.get( GROUPID ), (String) doc.get( ARTIFACTID ), + version, "compile", type, "", handler ); /* * Artifact artifact = factory.createArtifact((String) * doc.get(GROUPID), (String) doc.get(ARTIFACTID), (String) * doc.get(VERSION), "", type); */ - artifact.setRepository(repository); - artifact.setFile(new File(repository.getBasedir() + "/" - + (String) doc.get(NAME))); + artifact.setRepository( repository ); + artifact.setFile( new File( repository.getBasedir() + "/" + (String) doc.get( NAME ) ) ); - artifactList.add(artifact); + artifactList.add( artifact ); } } - - } catch (IOException ie) { - ie.printStackTrace(); - return artifactList; + } + catch ( Exception e ) + { + e.printStackTrace(); } return artifactList; diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositorySearcher.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositorySearcher.java index 79f11ed5e..d8119d5e8 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositorySearcher.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositorySearcher.java @@ -34,6 +34,6 @@ public interface RepositorySearcher { * @param searchField * @return */ - public List searchArtifact(String queryString, String searchField); + public List searchArtifact( String queryString, String searchField ); }