Clover coverage report - Code Coverage for tapestry release 4.0.2
Coverage timestamp: Thu Apr 13 2006 10:52:06 EDT
file stats: LOC: 91   Methods: 4
NCLOC: 43   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PrivateAsset.java - 83.3% 75% 81.2%
coverage coverage
 1    // Copyright 2004, 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.io.InputStream;
 18    import java.net.URL;
 19   
 20    import org.apache.hivemind.ApplicationRuntimeException;
 21    import org.apache.hivemind.Location;
 22    import org.apache.hivemind.Resource;
 23    import org.apache.hivemind.util.ClasspathResource;
 24    import org.apache.hivemind.util.Defense;
 25    import org.apache.tapestry.engine.IEngineService;
 26    import org.apache.tapestry.engine.ILink;
 27   
 28    /**
 29    * An implementation of {@link org.apache.tapestry.IAsset}for localizable assets within the JVM's
 30    * classpath.
 31    * <p>
 32    * The localization code here is largely cut-and-paste from {@link ContextAsset}.
 33    *
 34    * @author Howard Ship
 35    */
 36   
 37    public class PrivateAsset extends AbstractAsset
 38    {
 39    private IEngineService _assetService;
 40   
 41    /**
 42    * @deprecated To be removed (someday). Use
 43    * {@link #PrivateAsset(ClasspathResource, IEngineService, Location)}&nbsp;instead.
 44    */
 45  0 public PrivateAsset(ClasspathResource resourceLocation, Location location)
 46    {
 47  0 this(resourceLocation, null, location);
 48    }
 49   
 50  415 public PrivateAsset(ClasspathResource resourceLocation, IEngineService assetService,
 51    Location location)
 52    {
 53  415 super(resourceLocation, location);
 54   
 55  415 Defense.notNull(assetService, "assetService");
 56   
 57  415 _assetService = assetService;
 58    }
 59   
 60    /**
 61    * Gets the localized version of the resource. Build the URL for the resource. If possible, the
 62    * application's {@link AssetExternalizerImpl}is located, to copy the resource to a directory
 63    * visible to the web server.
 64    */
 65   
 66  73 public String buildURL()
 67    {
 68  73 String path = getResourceLocation().getPath();
 69   
 70  73 ILink link = _assetService.getLink(false, path);
 71   
 72  73 return link.getURL();
 73    }
 74   
 75  1 public InputStream getResourceAsStream()
 76    {
 77  1 Resource location = getResourceLocation();
 78   
 79  1 try
 80    {
 81  1 URL url = location.getResourceURL();
 82   
 83  1 return url.openStream();
 84    }
 85    catch (Exception ex)
 86    {
 87  0 throw new ApplicationRuntimeException(AssetMessages.noSuchResource(location.getPath()));
 88    }
 89    }
 90   
 91    }