Coverage Report - org.apache.maven.wagon.resource.Resource
 
Classes in this File Line Coverage Branch Coverage Complexity
Resource
65 %
26/40
44 %
8/18
2,333
 
 1  
 package org.apache.maven.wagon.resource;
 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.maven.wagon.WagonConstants;
 23  
 
 24  
 /**
 25  
  * Describes resources which can be downloaded from the repository
 26  
  * or uploaded to repository.
 27  
  * <p/>
 28  
  * This class contains minimal set of informations, which
 29  
  * are needed to reuse wagon in maven 1.
 30  
  *
 31  
  * @author <a href="michal@codehaus.org">Michal Maczka</a>
 32  
  * @version $Id: Resource.java 682047 2008-08-02 21:07:38Z hboutemy $
 33  
  */
 34  
 
 35  
 public class Resource
 36  
 {
 37  
     private String name;
 38  
 
 39  
     private long lastModified;
 40  
 
 41  33
     private long contentLength = WagonConstants.UNKNOWN_LENGTH;
 42  
 
 43  
     public Resource()
 44  2
     {
 45  
 
 46  2
     }
 47  
 
 48  
     public Resource( String name )
 49  31
     {
 50  31
         this.name = name;
 51  31
     }
 52  
 
 53  
     public String getName()
 54  
     {
 55  9
         return name;
 56  
     }
 57  
 
 58  
     public void setName( String name )
 59  
     {
 60  3
         this.name = name;
 61  3
     }
 62  
 
 63  
     /**
 64  
      * Returns the value of the last-modified header field.
 65  
      * The result is the number of milliseconds since January 1, 1970 GMT.
 66  
      *
 67  
      * @return the date the resource  was last modified, or WagonConstants.UNKNOWN_LENGTH
 68  
      *         if not known.
 69  
      */
 70  
     public long getLastModified()
 71  
     {
 72  9
         return lastModified;
 73  
     }
 74  
 
 75  
     public void setLastModified( long lastModified )
 76  
     {
 77  20
         this.lastModified = lastModified;
 78  20
     }
 79  
 
 80  
     public long getContentLength()
 81  
     {
 82  3
         return contentLength;
 83  
     }
 84  
 
 85  
     public void setContentLength( long contentLength )
 86  
     {
 87  4
         this.contentLength = contentLength;
 88  4
     }
 89  
 
 90  
     public String toString()
 91  
     {
 92  3
         return name;
 93  
     }
 94  
     
 95  
     public String inspect()
 96  
     {
 97  0
         return name + "[len = " + contentLength + "; mod = " + lastModified + "]";
 98  
     }
 99  
 
 100  
     public int hashCode()
 101  
     {
 102  0
         final int prime = 31;
 103  0
         int result = 1;
 104  0
         result = prime * result + (int) ( contentLength ^ ( contentLength >>> 32 ) );
 105  0
         result = prime * result + (int) ( lastModified ^ ( lastModified >>> 32 ) );
 106  0
         result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
 107  0
         return result;
 108  
     }
 109  
 
 110  
     public boolean equals( Object obj )
 111  
     {
 112  7
         if ( this == obj )
 113  
         {
 114  1
             return true;
 115  
         }
 116  6
         if ( obj == null )
 117  
         {
 118  0
             return false;
 119  
         }
 120  6
         if ( getClass() != obj.getClass() )
 121  
         {
 122  0
             return false;
 123  
         }
 124  6
         final Resource other = (Resource) obj;
 125  6
         if ( contentLength != other.contentLength )
 126  
         {
 127  0
             return false;
 128  
         }
 129  6
         if ( lastModified != other.lastModified )
 130  
         {
 131  0
             return false;
 132  
         }
 133  6
         if ( name == null )
 134  
         {
 135  0
             if ( other.name != null )
 136  
             {
 137  0
                 return false;
 138  
             }
 139  
         }
 140  6
         else if ( !name.equals( other.name ) )
 141  
         {
 142  0
             return false;
 143  
         }
 144  6
         return true;
 145  
     }
 146  
 }