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: 76   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  8 public StringTranslator()
 36    {
 37    }
 38   
 39    // Needed until HIVEMIND-134 fix is available
 40   
 41  1 public StringTranslator(String initializer)
 42    {
 43  1 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  2 protected Object parseText(IFormComponent field, ValidationMessages messages, String text)
 51    {
 52    // TODO: Do something with _empty here?
 53   
 54  2 return text;
 55    }
 56   
 57    /**
 58    * @see org.apache.tapestry.form.translator.AbstractTranslator#formatObject(org.apache.tapestry.form.IFormComponent,
 59    * Locale, java.lang.Object)
 60    */
 61  1 protected String formatObject(IFormComponent field, Locale locale, Object object)
 62    {
 63  1 return object.toString();
 64    }
 65   
 66  2 public Object getEmpty()
 67    {
 68  2 return _empty;
 69    }
 70   
 71  1 public void setEmpty(String empty)
 72    {
 73  1 _empty = empty;
 74    }
 75   
 76    }