Coverage Report - org.apache.tapestry.form.translator.TranslatorBindingFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
TranslatorBindingFactory
0%
0/7
N/A
2.5
 
 1  
 // Copyright 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.form.translator;
 16  
 
 17  
 import org.apache.hivemind.ApplicationRuntimeException;
 18  
 import org.apache.hivemind.Location;
 19  
 import org.apache.hivemind.lib.BeanFactory;
 20  
 import org.apache.tapestry.IBinding;
 21  
 import org.apache.tapestry.IComponent;
 22  
 import org.apache.tapestry.binding.AbstractBindingFactory;
 23  
 
 24  
 /**
 25  
  * Uses the tapestry.form.translator.TranslatorBeanFactory service to obtain configured
 26  
  * {@link org.apache.tapestry.form.translator.Translator} instances that are then wrapped as
 27  
  * {@link org.apache.tapestry.form.translator.TranslatorBinding}s.
 28  
  * 
 29  
  * @author Howard Lewis Ship
 30  
  * @since 4.0
 31  
  */
 32  0
 public class TranslatorBindingFactory extends AbstractBindingFactory
 33  
 {
 34  
     private BeanFactory _translatorBeanFactory;
 35  
 
 36  
     public IBinding createBinding(IComponent root, String bindingDescription, String expression,
 37  
             Location location)
 38  
     {
 39  
         try
 40  
         {
 41  0
             Translator translator = (Translator) _translatorBeanFactory.get(expression);
 42  
 
 43  0
             return new TranslatorBinding(bindingDescription, getValueConverter(), location,
 44  
                     translator);
 45  
         }
 46  0
         catch (Exception ex)
 47  
         {
 48  0
             throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
 49  
         }
 50  
     }
 51  
 
 52  
     public void setTranslatorBeanFactory(BeanFactory translatorBeanFactory)
 53  
     {
 54  0
         _translatorBeanFactory = translatorBeanFactory;
 55  0
     }
 56  
 }