Coverage Report - org.apache.tapestry5.internal.bindings.PropBindingFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
PropBindingFactory
100%
9/9
N/A
1
 
 1  
 // Copyright 2006, 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.Binding;
 18  
 import org.apache.tapestry5.ComponentResources;
 19  
 import org.apache.tapestry5.PropertyConduit;
 20  
 import org.apache.tapestry5.internal.services.StringInterner;
 21  
 import org.apache.tapestry5.ioc.Location;
 22  
 import org.apache.tapestry5.services.BindingFactory;
 23  
 import org.apache.tapestry5.services.PropertyConduitSource;
 24  
 
 25  
 /**
 26  
  * Binding factory for reading and updating JavaBean properties.
 27  
  * <p/>
 28  
  * Expression are evaluated via a {@link PropertyConduit}, which is generated by {@link PropertyConduitSource} (which
 29  
  * therefore defines the expression language).
 30  
  */
 31  
 public class PropBindingFactory implements BindingFactory
 32  
 {
 33  
     private final PropertyConduitSource source;
 34  
 
 35  
     private final StringInterner interner;
 36  
 
 37  
     public PropBindingFactory(PropertyConduitSource propertyConduitSource, StringInterner interner)
 38  46
     {
 39  46
         source = propertyConduitSource;
 40  46
         this.interner = interner;
 41  46
     }
 42  
 
 43  
     public Binding newBinding(String description, ComponentResources container,
 44  
                               ComponentResources component, String expression, Location location)
 45  
     {
 46  7091
         Object target = container.getComponent();
 47  7091
         Class targetClass = target.getClass();
 48  
 
 49  7091
         PropertyConduit conduit = source.create(targetClass, expression);
 50  
 
 51  7077
         String toString = interner.format("PropBinding[%s %s(%s)]", description, container
 52  
                 .getCompleteId(), expression);
 53  
 
 54  7077
         return new PropBinding(location, target, conduit, toString);
 55  
     }
 56  
 }