Clover coverage report - Code Coverage for tapestry release 4.0-beta-6
Coverage timestamp: Wed Sep 7 2005 18:41:34 EDT
file stats: LOC: 60   Methods: 3
NCLOC: 29   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ClasspathAssetFactory.java 50% 87.5% 100% 84.6%
coverage 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.asset;
 16   
 17    import java.util.Locale;
 18   
 19    import org.apache.hivemind.ApplicationRuntimeException;
 20    import org.apache.hivemind.Location;
 21    import org.apache.hivemind.Resource;
 22    import org.apache.hivemind.util.ClasspathResource;
 23    import org.apache.tapestry.IAsset;
 24    import org.apache.tapestry.engine.IEngineService;
 25   
 26    /**
 27    * Creates instances of {@link org.apache.tapestry.asset.PrivateAsset}, which are the holders of
 28    * classpath: resources.
 29    *
 30    * @author Howard M. Lewis Ship
 31    * @since 4.0
 32    */
 33    public class ClasspathAssetFactory implements AssetFactory
 34    {
 35    private IEngineService _assetService;
 36   
 37  50 public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
 38    {
 39  50 Resource asset = baseResource.getRelativeResource(path);
 40  50 Resource localized = asset.getLocalization(locale);
 41   
 42  50 if (localized == null)
 43  0 throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource),
 44    location, null);
 45   
 46  50 return new PrivateAsset((ClasspathResource) localized, _assetService, location);
 47    }
 48   
 49  25 public IAsset createAsset(Resource resource, Location location)
 50    {
 51  25 ClasspathResource cr = (ClasspathResource) resource;
 52   
 53  25 return new PrivateAsset(cr, _assetService, location);
 54    }
 55   
 56  27 public void setAssetService(IEngineService assetService)
 57    {
 58  27 _assetService = assetService;
 59    }
 60    }