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 org.apache.commons.lang.StringUtils;
23 import org.apache.maven.archiva.model.ArchivaArtifact;
25 import java.util.ArrayList;
26 import java.util.List;
31 * @version $Id: SearchResultHit.java 740552 2009-02-04 01:09:17Z oching $
33 public class SearchResultHit
35 // The (optional) context for this result.
36 private String context;
38 // Basic hit, direct to non-artifact resource.
41 // Advanced hit, reference to groupId.
42 private String groupId;
44 // Advanced hit, reference to artifactId.
45 private String artifactId;
47 // TODO: remove/deprecate this field!
48 private String version = "";
50 private String repositoryId = "";
52 private List<String> versions = new ArrayList<String>();
54 private ArchivaArtifact artifact;
56 public String getContext()
61 public void setContext( String context )
63 this.context = context;
66 public String getUrl()
71 public void setUrl( String url )
76 public String getUrlFilename()
78 return this.url.substring( this.url.lastIndexOf( '/' ) );
81 public String getArtifactId()
86 public void setArtifactId( String artifactId )
88 this.artifactId = artifactId;
91 public void setArtifact( ArchivaArtifact artifact )
93 this.artifact = artifact;
94 final String ver = artifact.getVersion();
96 if ( !this.versions.contains( ver ) )
98 this.versions.add( ver );
101 if ( StringUtils.isBlank( this.groupId ) )
103 this.groupId = artifact.getGroupId();
106 if ( StringUtils.isBlank( this.artifactId ) )
108 this.artifactId = artifact.getArtifactId();
111 if ( StringUtils.isBlank( this.version ) )
117 public ArchivaArtifact getArtifact()
122 public String getGroupId()
127 public void setGroupId( String groupId )
129 this.groupId = groupId;
132 public String getVersion()
137 public void setVersion(String version)
139 this.version = version;
142 public List<String> getVersions()
147 public void setVersions(List<String> versions)
149 this.versions = versions;
152 public String getRepositoryId()
157 public void setRepositoryId( String repositoryId )
159 this.repositoryId = repositoryId;
162 public void addVersion( String version )
164 if( versions == null )
166 versions = new ArrayList<String>();
169 versions.add( version );