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: 92   Methods: 6
NCLOC: 43   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
RenderString.java 50% 35.7% 50% 41.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.valid;
 16   
 
 17   
 import org.apache.commons.lang.builder.ToStringBuilder;
 18   
 import org.apache.tapestry.IMarkupWriter;
 19   
 import org.apache.tapestry.IRender;
 20   
 import org.apache.tapestry.IRequestCycle;
 21   
 
 22   
 /**
 23   
  *  A wrapper around {@link String} that allows the String to
 24   
  *  be renderred.  This is primarily used to present
 25   
  *  error messages.
 26   
  *
 27   
  *  @author Howard Lewis Ship
 28   
  *
 29   
  **/
 30   
 
 31   
 public class RenderString implements IRender
 32   
 {
 33   
     private String _string;
 34   
     private boolean _raw = false;
 35   
 
 36  10
     public RenderString(String string)
 37   
     {
 38  10
         _string = string;
 39   
     }
 40   
 
 41   
     /**
 42   
      *  @param string the string to render
 43   
      *  @param raw if true, the String is rendered as-is, with no filtering.
 44   
      *  If false (the default), the String is filtered.
 45   
      *
 46   
      **/
 47   
 
 48  0
     public RenderString(String string, boolean raw)
 49   
     {
 50  0
         _string = string;
 51  0
         _raw = raw;
 52   
     }
 53   
 
 54   
     /**
 55   
      *  Renders the String to the writer.  Does nothing if the string is null.
 56   
      *  If raw is true, uses {@link IMarkupWriter#printRaw(String)}, otherwise
 57   
      *  {@link IMarkupWriter#print(String)}.
 58   
      * 
 59   
      *
 60   
      **/
 61   
 
 62  1
     public void render(IMarkupWriter writer, IRequestCycle cycle)
 63   
     {
 64  1
         if (_string == null)
 65  0
             return;
 66   
 
 67  1
         if (_raw)
 68  0
             writer.printRaw(_string);
 69   
         else
 70  1
             writer.print(_string);
 71   
     }
 72   
 
 73  7
     public String getString()
 74   
     {
 75  7
         return _string;
 76   
     }
 77   
 
 78  0
     public boolean isRaw()
 79   
     {
 80  0
         return _raw;
 81   
     }
 82   
 
 83  0
     public String toString()
 84   
     {
 85  0
         ToStringBuilder builder = new ToStringBuilder(this);
 86  0
         builder.append("string", _string);
 87  0
         builder.append("raw", _raw);
 88   
 
 89  0
         return builder.toString();
 90   
     }
 91   
 }
 92