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: 91   Methods: 6
NCLOC: 47   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
TextToken.java 50% 64.3% 66.7% 62.5%
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.parse;
 16   
 
 17   
 import org.apache.commons.lang.builder.ToStringBuilder;
 18   
 import org.apache.hivemind.ApplicationRuntimeException;
 19   
 import org.apache.hivemind.Location;
 20   
 import org.apache.tapestry.IMarkupWriter;
 21   
 import org.apache.tapestry.IRender;
 22   
 import org.apache.tapestry.IRequestCycle;
 23   
 
 24   
 /**
 25   
  * Represents static text in the template that may be passed through to the client unchanged
 26   
  * (except, perhaps, for the removal of some whitespace).
 27   
  * 
 28   
  * @see TokenType#TEXT
 29   
  * @author Howard Lewis Ship
 30   
  * @since 3.0
 31   
  */
 32   
 
 33   
 public class TextToken extends TemplateToken implements IRender
 34   
 {
 35   
     private char[] _templateData;
 36   
 
 37   
     private int _offset;
 38   
 
 39   
     private int _length;
 40   
 
 41  1338
     public TextToken(char[] templateData, int startIndex, int endIndex, Location location)
 42   
     {
 43  1338
         super(TokenType.TEXT, location);
 44   
 
 45  1338
         if (startIndex < 0 || endIndex < 0 || startIndex > templateData.length
 46   
                 || endIndex > templateData.length)
 47  0
             throw new ApplicationRuntimeException(ParseMessages.rangeError(
 48   
                     this,
 49   
                     templateData.length), this, getLocation(), null);
 50   
 
 51  1338
         _templateData = templateData;
 52   
 
 53  1338
         _offset = startIndex;
 54  1338
         _length = endIndex - startIndex + 1;
 55   
     }
 56   
 
 57  3442
     public void render(IMarkupWriter writer, IRequestCycle cycle)
 58   
     {
 59  3442
         if (_length == 0)
 60  0
             return;
 61   
 
 62   
         // At one time, we would check to see if the cycle was rewinding and
 63   
         // only invoke printRaw() if it was. However, that slows down
 64   
         // normal rendering (microscopically) and, with the new
 65   
         // NullResponseWriter class, the "cost" of invoking cycle.isRewinding()
 66   
         // is approximately the same as the "cost" of invoking writer.printRaw().
 67   
 
 68  3442
         writer.printRaw(_templateData, _offset, _length);
 69   
     }
 70   
 
 71  0
     protected void extendDescription(ToStringBuilder builder)
 72   
     {
 73  0
         builder.append("offset", _offset);
 74  0
         builder.append("length", _length);
 75   
     }
 76   
 
 77  0
     public String getTemplateDataAsString()
 78   
     {
 79  0
         return new String(_templateData, _offset, _length);
 80   
     }
 81   
 
 82  16
     public int getLength()
 83   
     {
 84  16
         return _length;
 85   
     }
 86   
 
 87  16
     public int getOffset()
 88   
     {
 89  16
         return _offset;
 90   
     }
 91   
 }