Coverage Report - org.apache.tapestry.util.DescribedLocation
 
Classes in this File Line Coverage Branch Coverage Complexity
DescribedLocation
0%
0/14
0%
0/6
1.5
 
 1  
 // Copyright 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.util;
 16  
 
 17  
 import org.apache.hivemind.Location;
 18  
 import org.apache.hivemind.Resource;
 19  
 import org.apache.hivemind.util.Defense;
 20  
 
 21  
 /**
 22  
  * Implementation of {@link org.apache.hivemind.Location} that is used to describe a location within
 23  
  * a resource. This is used when the location within the resource can't be expressed as a line and
 24  
  * column. One example is for setting the location of an annotation. This is useful for line-precise
 25  
  * exception reporting of errors related to annotations.
 26  
  * 
 27  
  * @author Howard Lewis Ship
 28  
  * @since 4.0
 29  
  */
 30  
 public class DescribedLocation implements Location
 31  
 {
 32  
     private final Resource _resource;
 33  
 
 34  
     private final String _description;
 35  
 
 36  
     public DescribedLocation(Resource resource, String description)
 37  0
     {
 38  0
         Defense.notNull(resource, "resource");
 39  0
         Defense.notNull(description, "description");
 40  
 
 41  0
         _resource = resource;
 42  0
         _description = description;
 43  0
     }
 44  
 
 45  
     /**
 46  
      * Returns the description provided in the constructor.
 47  
      */
 48  
 
 49  
     public String toString()
 50  
     {
 51  0
         return _description;
 52  
     }
 53  
 
 54  
     /**
 55  
      * Returns the resource provided in the constructor.
 56  
      */
 57  
 
 58  
     public Resource getResource()
 59  
     {
 60  0
         return _resource;
 61  
     }
 62  
 
 63  
     /**
 64  
      * Always returns 0.
 65  
      */
 66  
 
 67  
     public int getLineNumber()
 68  
     {
 69  0
         return 0;
 70  
     }
 71  
 
 72  
     /**
 73  
      * Always returns 0.
 74  
      */
 75  
 
 76  
     public int getColumnNumber()
 77  
     {
 78  0
         return 0;
 79  
     }
 80  
 
 81  
     /**
 82  
      * A DescribedLocation is equal to another only if their resources are equal, and their
 83  
      * descriptions are equal.
 84  
      */
 85  
     public boolean equals(Object other)
 86  
     {
 87  0
         if (other instanceof DescribedLocation)
 88  
         {
 89  0
             DescribedLocation otherLocation = (DescribedLocation) other;
 90  
 
 91  0
             return _resource.equals(otherLocation._resource)
 92  
                     && _description.equals(otherLocation._description);
 93  
         }
 94  
 
 95  0
         return false;
 96  
     }
 97  
 }