Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 74   Methods: 6
NCLOC: 32   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StringTranslator.java - 100% 100% 100%
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.translator;
 16   
 17    import java.util.Locale;
 18   
 19    import org.apache.hivemind.util.PropertyUtils;
 20    import org.apache.tapestry.form.IFormComponent;
 21    import org.apache.tapestry.form.ValidationMessages;
 22   
 23    /**
 24    * A trivial {@link Translator} implementation. By default, empty text submissions are interpretted
 25    * as null.
 26    *
 27    * @author Paul Ferraro
 28    * @since 4.0
 29    */
 30    public class StringTranslator extends AbstractTranslator
 31    {
 32   
 33    private String _empty = null;
 34   
 35  16 public StringTranslator()
 36    {
 37    }
 38   
 39    // Needed until HIVEMIND-134 fix is available
 40   
 41  2 public StringTranslator(String initializer)
 42    {
 43  2 PropertyUtils.configureProperties(this, initializer);
 44    }
 45   
 46    /**
 47    * @see org.apache.tapestry.form.translator.AbstractTranslator#parseText(org.apache.tapestry.form.IFormComponent,
 48    * ValidationMessages, java.lang.String)
 49    */
 50  4 protected Object parseText(IFormComponent field, ValidationMessages messages, String text)
 51    {
 52  4 return text;
 53    }
 54   
 55    /**
 56    * @see org.apache.tapestry.form.translator.AbstractTranslator#formatObject(org.apache.tapestry.form.IFormComponent,
 57    * Locale, java.lang.Object)
 58    */
 59  2 protected String formatObject(IFormComponent field, Locale locale, Object object)
 60    {
 61  2 return object.toString();
 62    }
 63   
 64  4 public Object getValueForEmptyInput()
 65    {
 66  4 return _empty;
 67    }
 68   
 69  2 public void setEmpty(String empty)
 70    {
 71  2 _empty = empty;
 72    }
 73   
 74    }