Clover coverage report - Code Coverage for tapestry release 4.0-beta-8
Coverage timestamp: Sat Sep 24 2005 11:50:34 EDT
file stats: LOC: 75   Methods: 5
NCLOC: 42   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TranslatedFieldSupportImpl.java 100% 90.9% 80% 90%
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.form;
 16   
 17    import org.apache.hivemind.service.ThreadLocale;
 18    import org.apache.tapestry.IMarkupWriter;
 19    import org.apache.tapestry.IRequestCycle;
 20    import org.apache.tapestry.valid.IValidationDelegate;
 21    import org.apache.tapestry.valid.ValidatorException;
 22   
 23    public class TranslatedFieldSupportImpl implements TranslatedFieldSupport
 24    {
 25    private ThreadLocale _threadLocale;
 26   
 27    /**
 28    * @return Returns the threadLocale.
 29    */
 30  0 public ThreadLocale getThreadLocale()
 31    {
 32  0 return _threadLocale;
 33    }
 34   
 35    /**
 36    * @param threadLocale
 37    * The threadLocale to set.
 38    */
 39  4 public void setThreadLocale(ThreadLocale threadLocale)
 40    {
 41  4 _threadLocale = threadLocale;
 42    }
 43   
 44  2 public String format(TranslatedField field, Object object)
 45    {
 46  2 IValidationDelegate delegate = field.getForm().getDelegate();
 47   
 48  2 return delegate.isInError() ? delegate.getFieldInputValue() : field.getTranslator().format(
 49    field,
 50    _threadLocale.getLocale(),
 51    object);
 52    }
 53   
 54  2 public Object parse(TranslatedField field, String text) throws ValidatorException
 55    {
 56  2 IValidationDelegate delegate = field.getForm().getDelegate();
 57   
 58  2 delegate.recordFieldInputValue(text);
 59   
 60  2 ValidationMessages messages = new ValidationMessagesImpl(field, _threadLocale.getLocale());
 61   
 62  2 return field.getTranslator().parse(field, messages, text);
 63    }
 64   
 65  2 public void renderContributions(TranslatedField field, IMarkupWriter writer, IRequestCycle cycle)
 66    {
 67  2 if (field.getForm().isClientValidationEnabled())
 68    {
 69  1 FormComponentContributorContext context = new FormComponentContributorContextImpl(
 70    _threadLocale.getLocale(), cycle, field);
 71   
 72  1 field.getTranslator().renderContribution(writer, cycle, context, field);
 73    }
 74    }
 75    }