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: 90   Methods: 5
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NamespaceResourcesImpl.java - 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.services.impl;
 16   
 17    import org.apache.hivemind.Location;
 18    import org.apache.hivemind.Resource;
 19    import org.apache.hivemind.util.Defense;
 20    import org.apache.tapestry.IAsset;
 21    import org.apache.tapestry.asset.AssetSource;
 22    import org.apache.tapestry.engine.ISpecificationSource;
 23    import org.apache.tapestry.services.NamespaceResources;
 24    import org.apache.tapestry.spec.IComponentSpecification;
 25    import org.apache.tapestry.spec.ILibrarySpecification;
 26   
 27    /**
 28    * Implementation of {@link org.apache.tapestry.services.NamespaceResources}.
 29    *
 30    * @author Howard M. Lewis Ship
 31    */
 32    public class NamespaceResourcesImpl implements NamespaceResources
 33    {
 34    private final ISpecificationSource _specificationSource;
 35   
 36    private final AssetSource _assetSource;
 37   
 38  42 public NamespaceResourcesImpl(ISpecificationSource source, AssetSource assetSource)
 39    {
 40  42 Defense.notNull(source, "source");
 41  42 Defense.notNull(assetSource, "assetSource");
 42   
 43  42 _specificationSource = source;
 44  42 _assetSource = assetSource;
 45    }
 46   
 47  18 public ILibrarySpecification findChildLibrarySpecification(Resource parentResource,
 48    String path, Location location)
 49    {
 50  18 Resource childResource = findSpecificationResource(parentResource, path, location);
 51   
 52  18 return _specificationSource.getLibrarySpecification(childResource);
 53   
 54    }
 55   
 56  345 private Resource findSpecificationResource(Resource libraryResource, String path,
 57    Location location)
 58    {
 59    // TODO: This is where we'll play with assets and asset prefixes
 60   
 61  345 IAsset childAsset = _assetSource.findAsset(libraryResource, path, null, location);
 62   
 63  345 Resource childResource = childAsset.getResourceLocation();
 64   
 65  345 return childResource;
 66    }
 67   
 68  44 public IComponentSpecification getPageSpecification(Resource resource,
 69    String specificationPath, Location location)
 70    {
 71  44 Resource pageSpecificationResource = findSpecificationResource(
 72    resource,
 73    specificationPath,
 74    location);
 75   
 76  44 return _specificationSource.getPageSpecification(pageSpecificationResource);
 77    }
 78   
 79  283 public IComponentSpecification getComponentSpecification(Resource resource,
 80    String specificationPath, Location location)
 81    {
 82  283 Resource componentSpecificationResource = findSpecificationResource(
 83    resource,
 84    specificationPath,
 85    location);
 86   
 87  283 return _specificationSource.getComponentSpecification(componentSpecificationResource);
 88    }
 89   
 90    }