1 package org.apache.archiva.indexer.search;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.ArrayList;
23 import java.util.List;
28 * @version $Id: SearchResultHit.java 740552 2009-02-04 01:09:17Z oching $
30 public class SearchResultHit
32 // The (optional) context for this result.
33 private String context;
35 // Basic hit, direct to non-artifact resource.
38 // Advanced hit, reference to groupId.
39 private String groupId;
41 // Advanced hit, reference to artifactId.
42 private String artifactId;
44 private String repositoryId = "";
46 private List<String> versions = new ArrayList<String>();
48 private String packaging;
51 * Plugin goal prefix (only if packaging is "maven-plugin")
53 private String prefix;
56 * Plugin goals (only if packaging is "maven-plugin")
58 private List<String> goals;
61 * contains osgi metadata Bundle-Version if available
65 private String bundleVersion;
68 * contains osgi metadata Bundle-SymbolicName if available
72 private String bundleSymbolicName;
75 * contains osgi metadata Export-Package if available
79 private String bundleExportPackage;
82 * contains osgi metadata Export-Service if available
86 private String bundleExportService;
89 * contains osgi metadata Bundle-Description if available
93 private String bundleDescription;
96 * contains osgi metadata Bundle-Name if available
100 private String bundleName;
103 * contains osgi metadata Bundle-License if available
107 private String bundleLicense;
110 * contains osgi metadata Bundle-DocURL if available
114 private String bundleDocUrl;
117 * contains osgi metadata Import-Package if available
121 private String bundleImportPackage;
124 * contains osgi metadata Require-Bundle if available
128 private String bundleRequireBundle;
130 private String classifier;
133 * file extension of the search result
136 private String fileExtension;
138 public String getContext()
143 public void setContext( String context )
145 this.context = context;
148 public String getUrl()
153 public void setUrl( String url )
158 public String getUrlFilename()
160 return this.url.substring( this.url.lastIndexOf( '/' ) );
163 public String getArtifactId()
168 public void setArtifactId( String artifactId )
170 this.artifactId = artifactId;
173 public String getGroupId()
178 public void setGroupId( String groupId )
180 this.groupId = groupId;
183 public List<String> getVersions()
188 public void setVersions( List<String> versions )
190 this.versions = versions;
193 public String getRepositoryId()
198 public void setRepositoryId( String repositoryId )
200 this.repositoryId = repositoryId;
203 public void addVersion( String version )
205 versions.add( version );
208 public String getBundleVersion()
210 return bundleVersion;
213 public void setBundleVersion( String bundleVersion )
215 this.bundleVersion = bundleVersion;
218 public String getBundleSymbolicName()
220 return bundleSymbolicName;
223 public void setBundleSymbolicName( String bundleSymbolicName )
225 this.bundleSymbolicName = bundleSymbolicName;
228 public String getBundleExportPackage()
230 return bundleExportPackage;
233 public void setBundleExportPackage( String bundleExportPackage )
235 this.bundleExportPackage = bundleExportPackage;
238 public String getBundleExportService()
240 return bundleExportService;
243 public void setBundleExportService( String bundleExportService )
245 this.bundleExportService = bundleExportService;
248 public String getPrefix()
253 public void setPrefix( String prefix )
255 this.prefix = prefix;
258 public List<String> getGoals()
263 public void setGoals( List<String> goals )
268 public String getBundleDescription()
270 return bundleDescription;
273 public void setBundleDescription( String bundleDescription )
275 this.bundleDescription = bundleDescription;
278 public String getBundleName()
283 public void setBundleName( String bundleName )
285 this.bundleName = bundleName;
288 public String getBundleLicense()
290 return bundleLicense;
293 public void setBundleLicense( String bundleLicense )
295 this.bundleLicense = bundleLicense;
298 public String getBundleDocUrl()
303 public void setBundleDocUrl( String bundleDocUrl )
305 this.bundleDocUrl = bundleDocUrl;
308 public String getBundleImportPackage()
310 return bundleImportPackage;
313 public void setBundleImportPackage( String bundleImportPackage )
315 this.bundleImportPackage = bundleImportPackage;
318 public String getBundleRequireBundle()
320 return bundleRequireBundle;
323 public void setBundleRequireBundle( String bundleRequireBundle )
325 this.bundleRequireBundle = bundleRequireBundle;
328 public String getPackaging()
333 public void setPackaging( String packaging )
335 this.packaging = packaging;
338 public String getType()
340 return getPackaging();
343 public String getClassifier()
348 public void setClassifier( String classifier )
350 this.classifier = classifier;
353 public String getFileExtension()
355 return fileExtension;
358 public void setFileExtension( String fileExtension )
360 this.fileExtension = fileExtension;
364 public String toString()
366 final StringBuilder sb = new StringBuilder();
367 sb.append( "SearchResultHit" );
368 sb.append( "{context='" ).append( context ).append( '\'' );
369 sb.append( ", url='" ).append( url ).append( '\'' );
370 sb.append( ", groupId='" ).append( groupId ).append( '\'' );
371 sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
372 sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
373 sb.append( ", versions=" ).append( versions );
374 sb.append( ", packaging='" ).append( packaging ).append( '\'' );
375 sb.append( ", prefix='" ).append( prefix ).append( '\'' );
376 sb.append( ", goals=" ).append( goals );
377 sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
378 sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
379 sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
380 sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
381 sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
382 sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
383 sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
384 sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
385 sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
386 sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
387 sb.append( ", classifier='" ).append( classifier ).append( '\'' );
388 sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
390 return sb.toString();
394 public boolean equals( Object o )
400 if ( o == null || getClass() != o.getClass() )
405 SearchResultHit that = (SearchResultHit) o;
407 if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
411 if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
415 if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
419 if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
428 public int hashCode()
430 int result = groupId != null ? groupId.hashCode() : 0;
431 result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
432 result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
433 result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );