Coverage Report - org.apache.tapestry.valid.FieldTracking
 
Classes in this File Line Coverage Branch Coverage Complexity
FieldTracking
100% 
100% 
1
 
 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.valid;
 16  
 
 17  
 import java.io.Serializable;
 18  
 
 19  
 import org.apache.hivemind.util.Defense;
 20  
 import org.apache.tapestry.IRender;
 21  
 import org.apache.tapestry.form.IFormComponent;
 22  
 
 23  
 /**
 24  
  * Default implementation of {@link IFieldTracking}.
 25  
  * 
 26  
  * @author Howard Lewis Ship
 27  
  * @since 1.0.8
 28  
  */
 29  
 
 30  
 public class FieldTracking implements IFieldTracking, Serializable
 31  
 {
 32  
 
 33  
     private static final long serialVersionUID = -5397563163968532716L;
 34  
 
 35  
     private transient IFormComponent _component;
 36  
 
 37  
     private String _input;
 38  
 
 39  
     private IRender _renderer;
 40  
 
 41  
     private String _fieldName;
 42  
 
 43  
     private ValidationConstraint _constraint;
 44  
 
 45  
     /**
 46  
      * Constructor used for unassociated errors; errors that are not about any
 47  
      * particular field within the form.
 48  
      */
 49  
 
 50  
     FieldTracking()
 51  2
     {
 52  2
     }
 53  
 
 54  
     /**
 55  
      * Standard constructor for a field (with the given name), rendered by the
 56  
      * specified component.
 57  
      */
 58  
 
 59  
     FieldTracking(String fieldName, IFormComponent component)
 60  14
     {
 61  14
         Defense.notNull(fieldName, "fieldName");
 62  14
         Defense.notNull(component, "component");
 63  
 
 64  14
         _fieldName = fieldName;
 65  14
         _component = component;
 66  14
     }
 67  
 
 68  
     public IFormComponent getComponent()
 69  
     {
 70  10
         return _component;
 71  
     }
 72  
 
 73  
     public IRender getErrorRenderer()
 74  
     {
 75  19
         return _renderer;
 76  
     }
 77  
 
 78  
     public void setErrorRenderer(IRender value)
 79  
     {
 80  14
         _renderer = value;
 81  14
     }
 82  
 
 83  
     public String getInput()
 84  
     {
 85  6
         return _input;
 86  
     }
 87  
 
 88  
     public void setInput(String value)
 89  
     {
 90  11
         _input = value;
 91  11
     }
 92  
 
 93  
     public String getFieldName()
 94  
     {
 95  10
         return _fieldName;
 96  
     }
 97  
 
 98  
     public ValidationConstraint getConstraint()
 99  
     {
 100  5
         return _constraint;
 101  
     }
 102  
 
 103  
     public void setConstraint(ValidationConstraint constraint)
 104  
     {
 105  13
         _constraint = constraint;
 106  13
     }
 107  
 
 108  
     /** @since 3.0 * */
 109  
 
 110  
     public boolean isInError()
 111  
     {
 112  18
         return _renderer != null;
 113  
     }
 114  
 
 115  
 }