Clover coverage report - Code Coverage for tapestry release 4.0-alpha-2
Coverage timestamp: Thu May 5 2005 09:57:44 EDT
file stats: LOC: 86   Methods: 6
NCLOC: 35   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% 44.4% 50% 47.1%
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.tapestry.IMarkupWriter;
 18   
 import org.apache.tapestry.IRender;
 19   
 import org.apache.tapestry.IRequestCycle;
 20   
 
 21   
 /**
 22   
  * A wrapper around {@link String} that allows the String to be renderred. This is primarily
 23   
  * used to present error messages.
 24   
  * 
 25   
  * @author Howard Lewis Ship
 26   
  */
 27   
 
 28   
 public class RenderString implements IRender
 29   
 {
 30   
     private String _string;
 31   
 
 32   
     private boolean _raw = false;
 33   
 
 34  10
     public RenderString(String string)
 35   
     {
 36  10
         _string = string;
 37   
     }
 38   
 
 39   
     /**
 40   
      * @param string
 41   
      *            the string to render
 42   
      * @param raw
 43   
      *            if true, the String is rendered as-is, with no filtering. If false (the default),
 44   
      *            the String is filtered.
 45   
      */
 46   
 
 47  0
     public RenderString(String string, boolean raw)
 48   
     {
 49  0
         _string = string;
 50  0
         _raw = raw;
 51   
     }
 52   
 
 53   
     /**
 54   
      * Renders the String to the writer. Does nothing if the string is null. If raw is true, uses
 55   
      * {@link IMarkupWriter#printRaw(String)}, otherwise {@link IMarkupWriter#print(String)}.
 56   
      */
 57   
 
 58  1
     public void render(IMarkupWriter writer, IRequestCycle cycle)
 59   
     {
 60  1
         if (_string == null)
 61  0
             return;
 62   
 
 63  1
         writer.print(_string, _raw);
 64   
     }
 65   
 
 66  7
     public String getString()
 67   
     {
 68  7
         return _string;
 69   
     }
 70   
 
 71  0
     public boolean isRaw()
 72   
     {
 73  0
         return _raw;
 74   
     }
 75   
 
 76   
     /**
 77   
      * Returns the string that would be rendered. This is part of the contract for error renderers
 78   
      * used with validation ... must provide a user-presentable toString() that does not include any
 79   
      * markup.
 80   
      */
 81   
 
 82  0
     public String toString()
 83   
     {
 84  0
         return _string;
 85   
     }
 86   
 }