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