Clover coverage report - Code Coverage for tapestry-contrib release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:12:41 EDT
file stats: LOC: 124   Methods: 3
NCLOC: 27   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ValidatingTextField.java 0% 0% 0% 0%
coverage
 1   
 // Copyright 2004, 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.contrib.valid;
 16   
 
 17   
 import org.apache.tapestry.valid.IValidator;
 18   
 import org.apache.tapestry.valid.StringValidator;
 19   
 import org.apache.tapestry.valid.ValidField;
 20   
 
 21   
 /**
 22   
  * Backwards compatible version of the 1.0.7 ValidatingTextField component. <table border=1>
 23   
  * <tr>
 24   
  * <td>Parameter</td>
 25   
  * <td>Type</td>
 26   
  * <td>Read / Write</td>
 27   
  * <td>Required</td>
 28   
  * <td>Default</td>
 29   
  * <td>Description</td>
 30   
  * </tr>
 31   
  * <tr>
 32   
  * <td>text</td>
 33   
  * <td>java.lang.String</td>
 34   
  * <td>R / W</td>
 35   
  * <td>yes</td>
 36   
  * <td>&nbsp;</td>
 37   
  * <td>The text inside the text field.
 38   
  * <p>
 39   
  * When the form is submitted, the binding is only updated if the value is valid.</td>
 40   
  * </tr>
 41   
  * <tr>
 42   
  * <td>minimumLength</td>
 43   
  * <td>int</td>
 44   
  * <td>R</td>
 45   
  * <td>no</td>
 46   
  * <td>0</td>
 47   
  * <td>The minimum length (number of characters read) for the field. The value provided in the
 48   
  * request is trimmed of leading and trailing whitespace.
 49   
  * <p>
 50   
  * If a field is not required and no value is given, then minimumLength is ignored. Minimum length
 51   
  * only applies if <em>some</em> non-null value is given.</td>
 52   
  * </tr>
 53   
  * <tr>
 54   
  * <td>required</td>
 55   
  * <td>boolean</td>
 56   
  * <td>R</td>
 57   
  * <td>no</td>
 58   
  * <td>false</td>
 59   
  * <td>If true, then a non-null value must be provided. A value consisting only of whitespace is
 60   
  * considered null.</td>
 61   
  * </tr>
 62   
  * <tr>
 63   
  * <td>displayName</td>
 64   
  * <td>String</td>
 65   
  * <td>R</td>
 66   
  * <td>yes</td>
 67   
  * <td>&nbsp;</td>
 68   
  * <td>A textual name for the field that is used when formulating error messages.</td>
 69   
  * </tr>
 70   
  * </table>
 71   
  * <p>
 72   
  * May not have a body. May have informal parameters.
 73   
  * 
 74   
  * @author Howard Lewis Ship
 75   
  * @since 1.0.8
 76   
  * @see org.apache.tapestry.valid.ValidField
 77   
  */
 78   
 
 79   
 public abstract class ValidatingTextField extends ValidField
 80   
 {
 81   
     public abstract int getMinimumLength();
 82   
 
 83   
     public abstract boolean isRequired();
 84   
 
 85   
     public abstract String getText();
 86   
 
 87   
     public abstract void setText(String value);
 88   
 
 89   
     /*
 90   
      * (non-Javadoc)
 91   
      * 
 92   
      * @see org.apache.tapestry.valid.ValidField#getValue()
 93   
      */
 94  0
     public Object getValue()
 95   
     {
 96  0
         return getText();
 97   
     }
 98   
 
 99   
     /*
 100   
      * (non-Javadoc)
 101   
      * 
 102   
      * @see org.apache.tapestry.valid.ValidField#setValue(java.lang.Object)
 103   
      */
 104  0
     public void setValue(Object value)
 105   
     {
 106  0
         setText((String) value);
 107   
     }
 108   
 
 109   
     /**
 110   
      * Overrides {@link ValidField#getValidator()}to construct a validator on the fly.
 111   
      */
 112  0
     public IValidator getValidator()
 113   
     {
 114  0
         StringValidator validator = new StringValidator();
 115   
 
 116  0
         if (isParameterBound("required"))
 117  0
             validator.setRequired(isRequired());
 118   
 
 119  0
         if (isParameterBound("minimumLength"))
 120  0
             validator.setMinimumLength(getMinimumLength());
 121   
 
 122  0
         return validator;
 123   
     }
 124   
 }