Clover coverage report - Code Coverage for tapestry release 4.0-beta-10
Coverage timestamp: Sat Oct 8 2005 19:08:05 EDT
file stats: LOC: 80   Methods: 5
NCLOC: 44   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ClasspathAssetFactory.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.asset;
 16   
 17    import java.util.Locale;
 18   
 19    import org.apache.hivemind.ApplicationRuntimeException;
 20    import org.apache.hivemind.ClassResolver;
 21    import org.apache.hivemind.Location;
 22    import org.apache.hivemind.Resource;
 23    import org.apache.hivemind.util.ClasspathResource;
 24    import org.apache.tapestry.IAsset;
 25    import org.apache.tapestry.engine.IEngineService;
 26   
 27    /**
 28    * Creates instances of {@link org.apache.tapestry.asset.PrivateAsset}, which are the holders of
 29    * classpath: resources.
 30    *
 31    * @author Howard M. Lewis Ship
 32    * @since 4.0
 33    */
 34    public class ClasspathAssetFactory implements AssetFactory
 35    {
 36    private ClassResolver _classResolver;
 37   
 38    private IEngineService _assetService;
 39   
 40  400 public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
 41    {
 42  400 Resource asset = baseResource.getRelativeResource(path);
 43  400 Resource localized = asset.getLocalization(locale);
 44   
 45  400 if (localized == null)
 46  1 throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource),
 47    location, null);
 48   
 49  399 return createAsset(localized, location);
 50    }
 51   
 52  6 public IAsset createAbsoluteAsset(String path, Locale locale, Location location)
 53    {
 54  6 Resource base = new ClasspathResource(_classResolver, path);
 55  6 Resource localized = base.getLocalization(locale);
 56   
 57  6 if (localized == null)
 58  1 throw new ApplicationRuntimeException(AssetMessages.missingClasspathResource(path),
 59    location, null);
 60   
 61  5 return createAsset(localized, location);
 62    }
 63   
 64  429 public IAsset createAsset(Resource resource, Location location)
 65    {
 66  429 ClasspathResource cr = (ClasspathResource) resource;
 67   
 68  429 return new PrivateAsset(cr, _assetService, location);
 69    }
 70   
 71  43 public void setAssetService(IEngineService assetService)
 72    {
 73  43 _assetService = assetService;
 74    }
 75   
 76  43 public void setClassResolver(ClassResolver classResolver)
 77    {
 78  43 _classResolver = classResolver;
 79    }
 80    }