Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 99   Methods: 6
NCLOC: 42   Classes: 3
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
InsertTextMode.java 100% 90% 83.3% 88.9%
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.html;
 16   
 17    import org.apache.tapestry.IMarkupWriter;
 18   
 19    /**
 20    * Defines a number of ways to format multi-line text for proper renderring.
 21    *
 22    * @author Howard Lewis Ship
 23    */
 24   
 25    public abstract class InsertTextMode
 26    {
 27    /**
 28    * Mode where each line (after the first) is preceded by a <br> tag.
 29    */
 30   
 31    public static final InsertTextMode BREAK = new BreakMode();
 32   
 33    /**
 34    * Mode where each line is wrapped with a <p> element.
 35    */
 36   
 37    public static final InsertTextMode PARAGRAPH = new ParagraphMode();
 38   
 39    private final String _name;
 40   
 41  2 protected InsertTextMode(String name)
 42    {
 43  2 _name = name;
 44    }
 45   
 46  0 public String toString()
 47    {
 48  0 return "InsertTextMode[" + _name + "]";
 49    }
 50   
 51    /**
 52    * Invoked by the {@link InsertText} component to write the next line.
 53    *
 54    * @param lineNumber
 55    * the line number of the line, starting with 0 for the first line.
 56    * @param line
 57    * the String for the current line.
 58    * @param writer
 59    * the {@link IMarkupWriter} to send output to.
 60    * @param raw
 61    * if true, then the output should be unfiltered
 62    */
 63   
 64    public abstract void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw);
 65   
 66    private static class BreakMode extends InsertTextMode
 67    {
 68  1 private BreakMode()
 69    {
 70  1 super("BREAK");
 71    }
 72   
 73  5 public void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw)
 74    {
 75  5 if (lineNumber > 0)
 76  3 writer.beginEmpty("br");
 77   
 78  5 writer.print(line, raw);
 79    }
 80    }
 81   
 82    private static class ParagraphMode extends InsertTextMode
 83    {
 84  1 private ParagraphMode()
 85    {
 86  1 super("PARAGRAPH");
 87    }
 88   
 89  3 public void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw)
 90    {
 91  3 writer.begin("p");
 92   
 93  3 writer.print(line, raw);
 94   
 95  3 writer.end();
 96    }
 97    }
 98   
 99    }