Coverage Report - org.apache.tapestry5.internal.bindings.TranslateBindingFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
TranslateBindingFactory
100%
6/6
N/A
1
TranslateBindingFactory$1
100%
2/2
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.Binding;
 18  
 import org.apache.tapestry5.ComponentResources;
 19  
 import org.apache.tapestry5.FieldTranslator;
 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.FieldTranslatorSource;
 24  
 
 25  
 /**
 26  
  * Interprets the binding expression as the name of a {@link org.apache.tapestry5.Translator} provided by the {@link
 27  
  * org.apache.tapestry5.services.TranslatorSource}.
 28  
  */
 29  2
 public class TranslateBindingFactory implements BindingFactory
 30  
 {
 31  
     private final FieldTranslatorSource source;
 32  
 
 33  
     private final StringInterner interner;
 34  
 
 35  
     public TranslateBindingFactory(FieldTranslatorSource source, StringInterner interner)
 36  2
     {
 37  2
         this.source = source;
 38  2
         this.interner = interner;
 39  2
     }
 40  
 
 41  
     public Binding newBinding(String description, ComponentResources container,
 42  
                               final ComponentResources component, final String expression, Location location)
 43  
     {
 44  2
         return new InvariantBinding(location, FieldTranslator.class, interner.intern(description + ": " + expression))
 45  
         {
 46  2
             public Object get()
 47  
             {
 48  2
                 return source.createTranslator(component, expression);
 49  
             }
 50  
         };
 51  
     }
 52  
 }