Coverage Report - org.apache.archiva.indexer.search.SearchResultHit
 
Classes in this File Line Coverage Branch Coverage Complexity
SearchResultHit
0%
0/42
0%
0/10
0
 
 1  
 package org.apache.archiva.indexer.search;
 2  
 
 3  
 /*
 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
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 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
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.apache.maven.archiva.model.ArchivaArtifact;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * SearchResultHit 
 30  
  *
 31  
  * @version $Id: SearchResultHit.java 740552 2009-02-04 01:09:17Z oching $
 32  
  */
 33  0
 public class SearchResultHit
 34  
 {
 35  
     // The (optional) context for this result.
 36  
     private String context;
 37  
 
 38  
     // Basic hit, direct to non-artifact resource.
 39  
     private String url;
 40  
 
 41  
     // Advanced hit, reference to groupId.
 42  
     private String groupId;
 43  
 
 44  
     //  Advanced hit, reference to artifactId.
 45  
     private String artifactId;
 46  
 
 47  
     // TODO: remove/deprecate this field!
 48  0
     private String version = "";
 49  
     
 50  0
     private String repositoryId = "";
 51  
 
 52  0
     private List<String> versions = new ArrayList<String>();
 53  
 
 54  
     private ArchivaArtifact artifact;
 55  
 
 56  
     public String getContext()
 57  
     {
 58  0
         return context;
 59  
     }
 60  
 
 61  
     public void setContext( String context )
 62  
     {
 63  0
         this.context = context;
 64  0
     }
 65  
 
 66  
     public String getUrl()
 67  
     {
 68  0
         return url;
 69  
     }
 70  
 
 71  
     public void setUrl( String url )
 72  
     {
 73  0
         this.url = url;
 74  0
     }
 75  
 
 76  
     public String getUrlFilename()
 77  
     {
 78  0
         return this.url.substring( this.url.lastIndexOf( '/' ) );
 79  
     }
 80  
 
 81  
     public String getArtifactId()
 82  
     {
 83  0
         return artifactId;
 84  
     }
 85  
 
 86  
     public void setArtifactId( String artifactId )
 87  
     {
 88  0
         this.artifactId = artifactId;
 89  0
     }
 90  
 
 91  
     public void setArtifact( ArchivaArtifact artifact )
 92  
     {
 93  0
         this.artifact = artifact;
 94  0
         final String ver = artifact.getVersion();
 95  
 
 96  0
         if ( !this.versions.contains( ver ) )
 97  
         {
 98  0
             this.versions.add( ver );
 99  
         }
 100  
 
 101  0
         if ( StringUtils.isBlank( this.groupId ) )
 102  
         {
 103  0
             this.groupId = artifact.getGroupId();
 104  
         }
 105  
 
 106  0
         if ( StringUtils.isBlank( this.artifactId ) )
 107  
         {
 108  0
             this.artifactId = artifact.getArtifactId();
 109  
         }
 110  
 
 111  0
         if ( StringUtils.isBlank( this.version ) )
 112  
         {
 113  0
             this.version = ver;            
 114  
         }
 115  0
     }
 116  
 
 117  
     public ArchivaArtifact getArtifact()
 118  
     {
 119  0
         return artifact;
 120  
     }
 121  
 
 122  
     public String getGroupId()
 123  
     {
 124  0
         return groupId;
 125  
     }
 126  
 
 127  
     public void setGroupId( String groupId )
 128  
     {
 129  0
         this.groupId = groupId;
 130  0
     }
 131  
 
 132  
     public String getVersion()
 133  
     {
 134  0
         return version;
 135  
     }
 136  
 
 137  
     public void setVersion(String version)
 138  
     {
 139  0
         this.version = version;
 140  0
     }
 141  
 
 142  
     public List<String> getVersions()
 143  
     {
 144  0
         return versions;
 145  
     }
 146  
 
 147  
     public void setVersions(List<String> versions)
 148  
     {
 149  0
         this.versions = versions;
 150  0
     }
 151  
 
 152  
     public String getRepositoryId()
 153  
     {
 154  0
         return repositoryId;
 155  
     }
 156  
 
 157  
     public void setRepositoryId( String repositoryId )
 158  
     {
 159  0
         this.repositoryId = repositoryId;
 160  0
     }
 161  
     
 162  
     public void addVersion( String version )
 163  
     {
 164  0
         if( versions == null )
 165  
         {
 166  0
             versions = new ArrayList<String>();
 167  
         }
 168  
         
 169  0
         versions.add( version );
 170  0
     }
 171  
 }