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;
29 public class SearchResultHit
31 // The (optional) context for this result.
32 private String context;
34 // Basic hit, direct to non-artifact resource.
37 // Advanced hit, reference to groupId.
38 private String groupId;
40 // Advanced hit, reference to artifactId.
41 private String artifactId;
43 private String repositoryId = "";
45 private List<String> versions = new ArrayList<>();
47 private String packaging;
50 * Plugin goal prefix (only if packaging is "maven-plugin")
52 private String prefix;
55 * Plugin goals (only if packaging is "maven-plugin")
57 private List<String> goals;
60 * contains osgi metadata Bundle-Version if available
64 private String bundleVersion;
67 * contains osgi metadata Bundle-SymbolicName if available
71 private String bundleSymbolicName;
74 * contains osgi metadata Export-Package if available
78 private String bundleExportPackage;
81 * contains osgi metadata Export-Service if available
85 private String bundleExportService;
88 * contains osgi metadata Bundle-Description if available
92 private String bundleDescription;
95 * contains osgi metadata Bundle-Name if available
99 private String bundleName;
102 * contains osgi metadata Bundle-License if available
106 private String bundleLicense;
109 * contains osgi metadata Bundle-DocURL if available
113 private String bundleDocUrl;
116 * contains osgi metadata Import-Package if available
120 private String bundleImportPackage;
123 * contains osgi metadata Require-Bundle if available
127 private String bundleRequireBundle;
129 private String classifier;
132 * file extension of the search result
135 private String fileExtension;
137 public String getContext()
142 public void setContext( String context )
144 this.context = context;
147 public String getUrl()
152 public void setUrl( String url )
157 public String getUrlFilename()
159 return this.url.substring( this.url.lastIndexOf( '/' ) );
162 public String getArtifactId()
167 public void setArtifactId( String artifactId )
169 this.artifactId = artifactId;
172 public String getGroupId()
177 public void setGroupId( String groupId )
179 this.groupId = groupId;
182 public List<String> getVersions()
187 public void setVersions( List<String> versions )
189 this.versions = versions;
192 public String getRepositoryId()
197 public void setRepositoryId( String repositoryId )
199 this.repositoryId = repositoryId;
202 public void addVersion( String version )
204 versions.add( version );
207 public String getBundleVersion()
209 return bundleVersion;
212 public void setBundleVersion( String bundleVersion )
214 this.bundleVersion = bundleVersion;
217 public String getBundleSymbolicName()
219 return bundleSymbolicName;
222 public void setBundleSymbolicName( String bundleSymbolicName )
224 this.bundleSymbolicName = bundleSymbolicName;
227 public String getBundleExportPackage()
229 return bundleExportPackage;
232 public void setBundleExportPackage( String bundleExportPackage )
234 this.bundleExportPackage = bundleExportPackage;
237 public String getBundleExportService()
239 return bundleExportService;
242 public void setBundleExportService( String bundleExportService )
244 this.bundleExportService = bundleExportService;
247 public String getPrefix()
252 public void setPrefix( String prefix )
254 this.prefix = prefix;
257 public List<String> getGoals()
262 public void setGoals( List<String> goals )
267 public String getBundleDescription()
269 return bundleDescription;
272 public void setBundleDescription( String bundleDescription )
274 this.bundleDescription = bundleDescription;
277 public String getBundleName()
282 public void setBundleName( String bundleName )
284 this.bundleName = bundleName;
287 public String getBundleLicense()
289 return bundleLicense;
292 public void setBundleLicense( String bundleLicense )
294 this.bundleLicense = bundleLicense;
297 public String getBundleDocUrl()
302 public void setBundleDocUrl( String bundleDocUrl )
304 this.bundleDocUrl = bundleDocUrl;
307 public String getBundleImportPackage()
309 return bundleImportPackage;
312 public void setBundleImportPackage( String bundleImportPackage )
314 this.bundleImportPackage = bundleImportPackage;
317 public String getBundleRequireBundle()
319 return bundleRequireBundle;
322 public void setBundleRequireBundle( String bundleRequireBundle )
324 this.bundleRequireBundle = bundleRequireBundle;
327 public String getPackaging()
332 public void setPackaging( String packaging )
334 this.packaging = packaging;
337 public String getType()
339 return getPackaging();
342 public String getClassifier()
347 public void setClassifier( String classifier )
349 this.classifier = classifier;
352 public String getFileExtension()
354 return fileExtension;
357 public void setFileExtension( String fileExtension )
359 this.fileExtension = fileExtension;
363 public String toString()
365 final StringBuilder sb = new StringBuilder();
366 sb.append( "SearchResultHit" );
367 sb.append( "{context='" ).append( context ).append( '\'' );
368 sb.append( ", url='" ).append( url ).append( '\'' );
369 sb.append( ", groupId='" ).append( groupId ).append( '\'' );
370 sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
371 sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
372 sb.append( ", versions=" ).append( versions );
373 sb.append( ", packaging='" ).append( packaging ).append( '\'' );
374 sb.append( ", prefix='" ).append( prefix ).append( '\'' );
375 sb.append( ", goals=" ).append( goals );
376 sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
377 sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
378 sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
379 sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
380 sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
381 sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
382 sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
383 sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
384 sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
385 sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
386 sb.append( ", classifier='" ).append( classifier ).append( '\'' );
387 sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
389 return sb.toString();
393 public boolean equals( Object o )
399 if ( o == null || getClass() != o.getClass() )
404 SearchResultHit that = (SearchResultHit) o;
406 if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
410 if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
414 if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
418 if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
427 public int hashCode()
429 int result = groupId != null ? groupId.hashCode() : 0;
430 result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
431 result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
432 result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );