Clover coverage report - Code Coverage for tapestry release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:39:46 PST
file stats: LOC: 97   Methods: 6
NCLOC: 42   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DescribedLocation.java 100% 100% 100% 100%
coverage
 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  165 public DescribedLocation(Resource resource, String description)
 37    {
 38  165 Defense.notNull(resource, "resource");
 39  165 Defense.notNull(description, "description");
 40   
 41  165 _resource = resource;
 42  165 _description = description;
 43    }
 44   
 45    /**
 46    * Returns the description provided in the constructor.
 47    */
 48   
 49  1 public String toString()
 50    {
 51  1 return _description;
 52    }
 53   
 54    /**
 55    * Returns the resource provided in the constructor.
 56    */
 57   
 58  1 public Resource getResource()
 59    {
 60  1 return _resource;
 61    }
 62   
 63    /**
 64    * Always returns 0.
 65    */
 66   
 67  1 public int getLineNumber()
 68    {
 69  1 return 0;
 70    }
 71   
 72    /**
 73    * Always returns 0.
 74    */
 75   
 76  1 public int getColumnNumber()
 77    {
 78  1 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  5 public boolean equals(Object other)
 86    {
 87  5 if (other instanceof DescribedLocation)
 88    {
 89  3 DescribedLocation otherLocation = (DescribedLocation) other;
 90   
 91  3 return _resource.equals(otherLocation._resource)
 92    && _description.equals(otherLocation._description);
 93    }
 94   
 95  2 return false;
 96    }
 97    }