This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.indexer.search;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.ArrayList;
023import java.util.List;
024
025/**
026 * SearchResultHit
027 *
028 */
029public class SearchResultHit
030{
031    // The (optional) context for this result.
032    private String context;
033
034    // Basic hit, direct to non-artifact resource.
035    private String url;
036
037    // Advanced hit, reference to groupId.
038    private String groupId;
039
040    //  Advanced hit, reference to artifactId.
041    private String artifactId;
042
043    private String repositoryId = "";
044
045    private List<String> versions = new ArrayList<>();
046
047    private String packaging;
048
049    /**
050     * Plugin goal prefix (only if packaging is "maven-plugin")
051     */
052    private String prefix;
053
054    /**
055     * Plugin goals (only if packaging is "maven-plugin")
056     */
057    private List<String> goals;
058
059    /**
060     * contains osgi metadata Bundle-Version if available
061     *
062     * @since 1.4-M1
063     */
064    private String bundleVersion;
065
066    /**
067     * contains osgi metadata Bundle-SymbolicName if available
068     *
069     * @since 1.4-M1
070     */
071    private String bundleSymbolicName;
072
073    /**
074     * contains osgi metadata Export-Package if available
075     *
076     * @since 1.4-M1
077     */
078    private String bundleExportPackage;
079
080    /**
081     * contains osgi metadata Export-Service if available
082     *
083     * @since 1.4-M1
084     */
085    private String bundleExportService;
086
087    /**
088     * contains osgi metadata Bundle-Description if available
089     *
090     * @since 1.4-M1
091     */
092    private String bundleDescription;
093
094    /**
095     * contains osgi metadata Bundle-Name if available
096     *
097     * @since 1.4-M1
098     */
099    private String bundleName;
100
101    /**
102     * contains osgi metadata Bundle-License if available
103     *
104     * @since 1.4-M1
105     */
106    private String bundleLicense;
107
108    /**
109     * contains osgi metadata Bundle-DocURL if available
110     *
111     * @since 1.4-M1
112     */
113    private String bundleDocUrl;
114
115    /**
116     * contains osgi metadata Import-Package if available
117     *
118     * @since 1.4-M1
119     */
120    private String bundleImportPackage;
121
122    /**
123     * contains osgi metadata Require-Bundle if available
124     *
125     * @since 1.4-M1
126     */
127    private String bundleRequireBundle;
128
129    private String classifier;
130
131    /**
132     * file extension of the search result
133     * @since 1.4-M2
134     */
135    private String fileExtension;
136
137    public String getContext()
138    {
139        return context;
140    }
141
142    public void setContext( String context )
143    {
144        this.context = context;
145    }
146
147    public String getUrl()
148    {
149        return url;
150    }
151
152    public void setUrl( String url )
153    {
154        this.url = url;
155    }
156
157    public String getUrlFilename()
158    {
159        return this.url.substring( this.url.lastIndexOf( '/' ) );
160    }
161
162    public String getArtifactId()
163    {
164        return artifactId;
165    }
166
167    public void setArtifactId( String artifactId )
168    {
169        this.artifactId = artifactId;
170    }
171
172    public String getGroupId()
173    {
174        return groupId;
175    }
176
177    public void setGroupId( String groupId )
178    {
179        this.groupId = groupId;
180    }
181
182    public List<String> getVersions()
183    {
184        return versions;
185    }
186
187    public void setVersions( List<String> versions )
188    {
189        this.versions = versions;
190    }
191
192    public String getRepositoryId()
193    {
194        return repositoryId;
195    }
196
197    public void setRepositoryId( String repositoryId )
198    {
199        this.repositoryId = repositoryId;
200    }
201
202    public void addVersion( String version )
203    {
204        versions.add( version );
205    }
206
207    public String getBundleVersion()
208    {
209        return bundleVersion;
210    }
211
212    public void setBundleVersion( String bundleVersion )
213    {
214        this.bundleVersion = bundleVersion;
215    }
216
217    public String getBundleSymbolicName()
218    {
219        return bundleSymbolicName;
220    }
221
222    public void setBundleSymbolicName( String bundleSymbolicName )
223    {
224        this.bundleSymbolicName = bundleSymbolicName;
225    }
226
227    public String getBundleExportPackage()
228    {
229        return bundleExportPackage;
230    }
231
232    public void setBundleExportPackage( String bundleExportPackage )
233    {
234        this.bundleExportPackage = bundleExportPackage;
235    }
236
237    public String getBundleExportService()
238    {
239        return bundleExportService;
240    }
241
242    public void setBundleExportService( String bundleExportService )
243    {
244        this.bundleExportService = bundleExportService;
245    }
246
247    public String getPrefix()
248    {
249        return prefix;
250    }
251
252    public void setPrefix( String prefix )
253    {
254        this.prefix = prefix;
255    }
256
257    public List<String> getGoals()
258    {
259        return goals;
260    }
261
262    public void setGoals( List<String> goals )
263    {
264        this.goals = goals;
265    }
266
267    public String getBundleDescription()
268    {
269        return bundleDescription;
270    }
271
272    public void setBundleDescription( String bundleDescription )
273    {
274        this.bundleDescription = bundleDescription;
275    }
276
277    public String getBundleName()
278    {
279        return bundleName;
280    }
281
282    public void setBundleName( String bundleName )
283    {
284        this.bundleName = bundleName;
285    }
286
287    public String getBundleLicense()
288    {
289        return bundleLicense;
290    }
291
292    public void setBundleLicense( String bundleLicense )
293    {
294        this.bundleLicense = bundleLicense;
295    }
296
297    public String getBundleDocUrl()
298    {
299        return bundleDocUrl;
300    }
301
302    public void setBundleDocUrl( String bundleDocUrl )
303    {
304        this.bundleDocUrl = bundleDocUrl;
305    }
306
307    public String getBundleImportPackage()
308    {
309        return bundleImportPackage;
310    }
311
312    public void setBundleImportPackage( String bundleImportPackage )
313    {
314        this.bundleImportPackage = bundleImportPackage;
315    }
316
317    public String getBundleRequireBundle()
318    {
319        return bundleRequireBundle;
320    }
321
322    public void setBundleRequireBundle( String bundleRequireBundle )
323    {
324        this.bundleRequireBundle = bundleRequireBundle;
325    }
326
327    public String getPackaging()
328    {
329        return packaging;
330    }
331
332    public void setPackaging( String packaging )
333    {
334        this.packaging = packaging;
335    }
336
337    public String getType()
338    {
339        return getPackaging();
340    }
341
342    public String getClassifier()
343    {
344        return classifier;
345    }
346
347    public void setClassifier( String classifier )
348    {
349        this.classifier = classifier;
350    }
351
352    public String getFileExtension()
353    {
354        return fileExtension;
355    }
356
357    public void setFileExtension( String fileExtension )
358    {
359        this.fileExtension = fileExtension;
360    }
361
362    @Override
363    public String toString()
364    {
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( '\'' );
388        sb.append( '}' );
389        return sb.toString();
390    }
391
392    @Override
393    public boolean equals( Object o )
394    {
395        if ( this == o )
396        {
397            return true;
398        }
399        if ( o == null || getClass() != o.getClass() )
400        {
401            return false;
402        }
403
404        SearchResultHit that = (SearchResultHit) o;
405
406        if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
407        {
408            return false;
409        }
410        if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
411        {
412            return false;
413        }
414        if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
415        {
416            return false;
417        }
418        if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
419        {
420            return false;
421        }
422
423        return true;
424    }
425
426    @Override
427    public int hashCode()
428    {
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 );
433        return result;
434    }
435}