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: 77   Methods: 4
NCLOC: 36   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
ExternalAsset.java - 33.3% 50% 38.5%
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.IRequestCycle;
 23   
 import org.apache.tapestry.Tapestry;
 24   
 
 25   
 /**
 26   
  *  A reference to an external URL.  {@link ExternalAsset}s are not
 27   
  *  localizable.
 28   
  *
 29   
  *  @author Howard Lewis Ship
 30   
  * 
 31   
  **/
 32   
 
 33   
 public class ExternalAsset extends AbstractAsset
 34   
 {
 35   
     private String _URL;
 36   
 
 37  1
     public ExternalAsset(String URL, Location location)
 38   
     {
 39  1
         super(null, location);
 40   
         
 41  1
         _URL = URL;
 42   
     }
 43   
 
 44   
     /**
 45   
      *  Simply returns the URL of the external asset.
 46   
      *
 47   
      **/
 48   
 
 49  1
     public String buildURL(IRequestCycle cycle)
 50   
     {
 51  1
         return _URL;
 52   
     }
 53   
 
 54  0
     public InputStream getResourceAsStream(IRequestCycle cycle)
 55   
     {
 56  0
         URL url;
 57   
 
 58  0
         try
 59   
         {
 60  0
             url = new URL(_URL);
 61   
 
 62  0
             return url.openStream();
 63   
         }
 64   
         catch (Exception ex)
 65   
         {
 66   
             // MalrformedURLException or IOException
 67   
 
 68  0
             throw new ApplicationRuntimeException(Tapestry.format("ExternalAsset.resource-missing", _URL), ex);
 69   
         }
 70   
 
 71   
     }
 72   
 
 73  0
     public String toString()
 74   
     {
 75  0
         return "ExternalAsset[" + _URL + "]";
 76   
     }
 77   
 }