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: 97   Methods: 1
NCLOC: 53   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
Insert.java 100% 100% 100% 100%
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.components;
 16   
 
 17   
 import java.text.Format;
 18   
 
 19   
 import org.apache.hivemind.ApplicationRuntimeException;
 20   
 import org.apache.tapestry.AbstractComponent;
 21   
 import org.apache.tapestry.IMarkupWriter;
 22   
 import org.apache.tapestry.IRequestCycle;
 23   
 
 24   
 /**
 25   
  * Used to insert some text (from a parameter) into the HTML. [ <a
 26   
  * href="../../../../../ComponentReference/Insert.html">Component Reference </a>]
 27   
  * 
 28   
  * @author Howard Lewis Ship
 29   
  */
 30   
 
 31   
 public abstract class Insert extends AbstractComponent
 32   
 {
 33   
     /**
 34   
      * Prints its value parameter, possibly formatted by its format parameter.
 35   
      */
 36   
 
 37  1894
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 38   
     {
 39  1894
         if (cycle.isRewinding())
 40  5
             return;
 41   
 
 42  1889
         Object value = getValue();
 43   
 
 44  1889
         if (value == null)
 45  10
             return;
 46   
 
 47  1879
         String insert = null;
 48   
 
 49  1879
         Format format = getFormat();
 50   
 
 51  1879
         if (format == null)
 52   
         {
 53  1877
             insert = value.toString();
 54   
         }
 55   
         else
 56   
         {
 57  2
             try
 58   
             {
 59  2
                 insert = format.format(value);
 60   
             }
 61   
             catch (Exception ex)
 62   
             {
 63  1
                 throw new ApplicationRuntimeException(ComponentMessages.unableToFormat(
 64   
                         this,
 65   
                         value,
 66   
                         ex), this, getBinding("format").getLocation(), ex);
 67   
             }
 68   
         }
 69   
 
 70  1878
         String styleClass = getStyleClass();
 71   
 
 72  1878
         if (styleClass != null)
 73   
         {
 74  5
             writer.begin("span");
 75  5
             writer.attribute("class", styleClass);
 76   
 
 77  5
             renderInformalParameters(writer, cycle);
 78   
         }
 79   
 
 80  1878
         if (getRaw())
 81  1
             writer.printRaw(insert);
 82   
         else
 83  1877
             writer.print(insert);
 84   
 
 85  1878
         if (styleClass != null)
 86  5
             writer.end(); // <span>
 87   
     }
 88   
 
 89   
     public abstract Object getValue();
 90   
 
 91   
     public abstract Format getFormat();
 92   
 
 93   
     public abstract String getStyleClass();
 94   
 
 95   
     public abstract boolean getRaw();
 96   
 
 97   
 }