Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 84   Methods: 2
NCLOC: 32   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
AbstractFormComponent.java 100% 88.9% 50% 86.7%
coverage 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.form;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.tapestry.AbstractComponent;
 19   
 import org.apache.tapestry.IForm;
 20   
 import org.apache.tapestry.IRequestCycle;
 21   
 import org.apache.tapestry.Tapestry;
 22   
 import org.apache.tapestry.valid.IValidationDelegate;
 23   
 
 24   
 /**
 25   
  *  A base class for building components that correspond to HTML form elements.
 26   
  *  All such components must be wrapped (directly or indirectly) by
 27   
  *  a {@link Form} component.
 28   
  *
 29   
  *  @author Howard Lewis Ship
 30   
  *  @since 1.0.3
 31   
  * 
 32   
  **/
 33   
 
 34   
 public abstract class AbstractFormComponent extends AbstractComponent implements IFormComponent
 35   
 {
 36   
     /**
 37   
      *  Returns the {@link Form} wrapping this component.  Invokes
 38   
      *  {@link #setForm(IForm)} (so that the component may know, later, what the
 39   
      *  form is).  Also, if the form has a delegate, 
 40   
      *  then {@link IValidationDelegate#setFormComponent(IFormComponent)} is invoked.
 41   
      *
 42   
      *  @throws ApplicationRuntimeException if the component is not wrapped by a {@link Form}.
 43   
      *
 44   
      **/
 45   
 
 46  151
     public IForm getForm(IRequestCycle cycle)
 47   
     {
 48  151
         IForm result = Form.get(cycle);
 49   
 
 50  151
         if (result == null)
 51  3
             throw new ApplicationRuntimeException(
 52   
                 Tapestry.getMessage("AbstractFormComponent.must-be-contained-by-form"),
 53   
                 this,
 54   
                 null,
 55   
                 null);
 56   
 
 57  148
         setForm(result);
 58   
 
 59  148
         IValidationDelegate delegate = result.getDelegate();
 60   
 
 61  148
         if (delegate != null)
 62  55
             delegate.setFormComponent(this);
 63   
 
 64  148
         return result;
 65   
     }
 66   
 
 67   
     public abstract IForm getForm();
 68   
     public abstract void setForm(IForm form);
 69   
 
 70   
     public abstract String getName();
 71   
     public abstract void setName(String name);
 72   
 
 73   
     /**
 74   
      *  Implemented in some subclasses to provide a display name (suitable
 75   
      *  for presentation to the user as a label or error message).  This implementation
 76   
      *  return null.
 77   
      * 
 78   
      **/
 79   
 
 80  0
     public String getDisplayName()
 81   
     {
 82  0
         return null;
 83   
     }
 84   
 }