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: 113   Methods: 5
NCLOC: 55   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
AbstractPostfield.java 87.5% 95.5% 80% 91.4%
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.wml;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.tapestry.IForm;
 19   
 import org.apache.tapestry.IMarkupWriter;
 20   
 import org.apache.tapestry.IRequestCycle;
 21   
 import org.apache.tapestry.Tapestry;
 22   
 import org.apache.tapestry.form.AbstractFormComponent;
 23   
 
 24   
 /**
 25   
  * A base class for building components that correspond to WML postfield elements. All such
 26   
  * components must be wrapped (directly or indirectly) by a {@link Go}component.
 27   
  * 
 28   
  * @author David Solis
 29   
  * @since 3.0
 30   
  */
 31   
 
 32   
 public abstract class AbstractPostfield extends AbstractFormComponent
 33   
 {
 34   
 
 35   
     /**
 36   
      * Returns the {@link org.apache.tapestry.wml.Go}wrapping this component.
 37   
      * 
 38   
      * @throws ApplicationRuntimeException
 39   
      *             if the component is not wrapped by a {@link org.apache.tapestry.wml.Go}.
 40   
      */
 41   
 
 42  16
     public IForm getForm(IRequestCycle cycle)
 43   
     {
 44  16
         IForm result = Go.get(cycle);
 45   
 
 46  16
         if (result == null)
 47  1
             throw new ApplicationRuntimeException(Tapestry
 48   
                     .getMessage("Postfield.must-be-contained-by-go"), this, null, null);
 49   
 
 50  15
         setForm(result);
 51   
 
 52  15
         return result;
 53   
     }
 54   
 
 55   
     /**
 56   
      * @see org.apache.tapestry.AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle)
 57   
      */
 58   
 
 59  16
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 60   
     {
 61  16
         IForm form = getForm(cycle);
 62   
 
 63  15
         boolean rewinding = form.isRewinding();
 64   
 
 65  15
         if (!rewinding && cycle.isRewinding())
 66  1
             return;
 67   
 
 68  14
         String name = form.getElementId(this);
 69   
 
 70  13
         if (rewinding)
 71   
         {
 72  6
             rewind(cycle);
 73  6
             return;
 74   
         }
 75   
 
 76  7
         writer.beginEmpty("postfield");
 77   
 
 78  7
         writer.attribute("name", name);
 79  7
         String varName = getVarName();
 80  7
         writer.attributeRaw("value", varName != null ? getEncodedVarName(varName) : "");
 81   
 
 82  7
         renderInformalParameters(writer, cycle);
 83   
 
 84  7
         writer.closeTag();
 85   
     }
 86   
 
 87   
     protected abstract void rewind(IRequestCycle cycle);
 88   
 
 89  7
     private String getEncodedVarName(String varName)
 90   
     {
 91  7
         return "$(" + varName + ")";
 92   
     }
 93   
 
 94  0
     public boolean isDisabled()
 95   
     {
 96  0
         return false;
 97   
     }
 98   
 
 99   
     public abstract String getVarName();
 100   
 
 101  6
     public void updateValue(Object value)
 102   
     {
 103  6
         getBinding("value").setObject(value);
 104   
     }
 105   
 
 106   
     public abstract IForm getForm();
 107   
 
 108   
     public abstract void setForm(IForm form);
 109   
 
 110   
     public abstract String getName();
 111   
 
 112   
     public abstract void setName(String name);
 113   
 }