Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 70   Methods: 3
NCLOC: 33   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ValidatorBindingFactory.java - 83.3% 100% 88.9%
coverage coverage
 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.valid;
 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.BindingFactory;
 23    import org.apache.tapestry.coerce.ValueConverter;
 24   
 25    /**
 26    * Uses the tapestry.valid.ValidatorBeanFactory service to obtain configuration IValidator
 27    * instances.
 28    *
 29    * @author Howard M. Lewis Ship
 30    * @since 4.0
 31    * @see org.apache.tapestry.valid.ValidatorBinding
 32    */
 33    public class ValidatorBindingFactory implements BindingFactory
 34    {
 35    private BeanFactory _validatorBeanFactory;
 36   
 37    private ValueConverter _valueConverter;
 38   
 39  1 public void setValidatorBeanFactory(BeanFactory validatorBeanFactory)
 40    {
 41  1 _validatorBeanFactory = validatorBeanFactory;
 42    }
 43   
 44  1 public void setValueConverter(ValueConverter valueConverter)
 45    {
 46  1 _valueConverter = valueConverter;
 47    }
 48   
 49    /**
 50    * Creates and returns a {@link ValidatorBinding}. Interprets the path as a bean initializer,
 51    * used to locate a particular type of validator and a particular configuration of its
 52    * properties.
 53    */
 54   
 55  1 public IBinding createBinding(IComponent root, String bindingDescription, String path,
 56    Location location)
 57    {
 58  1 try
 59    {
 60  1 IValidator validator = (IValidator) _validatorBeanFactory.get(path);
 61   
 62  1 return new ValidatorBinding(bindingDescription, _valueConverter, location, validator);
 63    }
 64    catch (Exception ex)
 65    {
 66  0 throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
 67    }
 68    }
 69   
 70    }