Coverage Report - org.apache.tapestry5.internal.bindings.AssetBindingFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AssetBindingFactory
100%
6/6
N/A
1
 
 1  
 // Copyright 2007, 2008, 2009 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.tapestry5.internal.bindings;
 16  
 
 17  
 import org.apache.tapestry5.Asset;
 18  
 import org.apache.tapestry5.Binding;
 19  
 import org.apache.tapestry5.ComponentResources;
 20  
 import org.apache.tapestry5.ioc.Location;
 21  
 import org.apache.tapestry5.ioc.Resource;
 22  
 import org.apache.tapestry5.services.AssetSource;
 23  
 import org.apache.tapestry5.services.BindingFactory;
 24  
 
 25  
 /**
 26  
  * Binding factory where the expression is a reference to an asset.
 27  
  *
 28  
  * @see org.apache.tapestry5.services.AssetSource
 29  
  * @see org.apache.tapestry5.internal.bindings.ContextBindingFactory
 30  
  */
 31  
 public class AssetBindingFactory implements BindingFactory
 32  
 {
 33  
     private final AssetSource source;
 34  
 
 35  
     public AssetBindingFactory(AssetSource source)
 36  4
     {
 37  4
         this.source = source;
 38  4
     }
 39  
 
 40  
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
 41  
                               String expression, Location location)
 42  
     {
 43  52
         Resource baseResource = container.getBaseResource();
 44  
 
 45  52
         Asset asset = source.getAsset(baseResource, expression, container.getLocale());
 46  
 
 47  52
         return new AssetBinding(location, description, asset);
 48  
     }
 49  
 }