Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 67   Methods: 4
NCLOC: 34   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ContextAssetFactory.java 50% 87.5% 100% 85.7%
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.tapestry.IAsset;
 23   
 import org.apache.tapestry.web.WebContext;
 24   
 import org.apache.tapestry.web.WebContextResource;
 25   
 
 26   
 /**
 27   
  * For the moment, all "context:" prefixed asset paths are interpreted relative to the web context
 28   
  * (the web application's root folder).
 29   
  * 
 30   
  * @author Howard M. Lewis Ship
 31   
  * @since 4.0
 32   
  */
 33   
 public class ContextAssetFactory implements AssetFactory
 34   
 {
 35   
     private WebContext _context;
 36   
 
 37   
     private String _contextPath;
 38   
 
 39   
     private Resource _servletRoot;
 40   
 
 41  5
     public void initializeService()
 42   
     {
 43  5
         _servletRoot = new WebContextResource(_context, "/");
 44   
     }
 45   
 
 46  6
     public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
 47   
     {
 48  6
         Resource assetResource = _servletRoot.getRelativeResource(path);
 49  6
         Resource localized = assetResource.getLocalization(locale);
 50   
 
 51  6
         if (localized == null)
 52  0
             throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, _servletRoot),
 53   
                     location, null);
 54   
 
 55  6
         return new ContextAsset(_contextPath, localized, location);
 56   
     }
 57   
 
 58  5
     public void setContext(WebContext context)
 59   
     {
 60  5
         _context = context;
 61   
     }
 62   
 
 63  5
     public void setContextPath(String contextPath)
 64   
     {
 65  5
         _contextPath = contextPath;
 66   
     }
 67   
 }