Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 76   Methods: 4
NCLOC: 35   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ExternalAsset.java - 44.4% 75% 53.8%
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.tapestry.Tapestry;
 23   
 24    /**
 25    * A reference to an external URL. {@link ExternalAsset}s are not
 26    * localizable.
 27    *
 28    * @author Howard Lewis Ship
 29    *
 30    **/
 31   
 32    public class ExternalAsset extends AbstractAsset
 33    {
 34    private String _URL;
 35   
 36  6 public ExternalAsset(String URL, Location location)
 37    {
 38  6 super(null, location);
 39   
 40  6 _URL = URL;
 41    }
 42   
 43    /**
 44    * Simply returns the URL of the external asset.
 45    *
 46    **/
 47   
 48  2 public String buildURL()
 49    {
 50  2 return _URL;
 51    }
 52   
 53  0 public InputStream getResourceAsStream()
 54    {
 55  0 URL url;
 56   
 57  0 try
 58    {
 59  0 url = new URL(_URL);
 60   
 61  0 return url.openStream();
 62    }
 63    catch (Exception ex)
 64    {
 65    // MalrformedURLException or IOException
 66   
 67  0 throw new ApplicationRuntimeException(Tapestry.format("ExternalAsset.resource-missing", _URL), ex);
 68    }
 69   
 70    }
 71   
 72  4 public String toString()
 73    {
 74  4 return "ExternalAsset[" + _URL + "]";
 75    }
 76    }