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: 72   Methods: 2
NCLOC: 27   Classes: 1
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
LetToken.java 75% 92.3% 100% 89.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.script;
 16   
 17    import java.util.Map;
 18   
 19    import org.apache.hivemind.Location;
 20   
 21    /**
 22    * Allows for the creation of new symbols that can be used in the script
 23    * or returned to the caller.
 24    *
 25    * <p>The &lt;let&gt; tag wraps around static text and &lt;insert&gt;
 26    * elements. The results are trimmed.
 27    *
 28    * @author Howard Lewis Ship
 29    * @since 0.2.9
 30    *
 31    **/
 32   
 33    class LetToken extends AbstractToken
 34    {
 35    private String _key;
 36    private boolean _unique;
 37    private int _bufferLengthHighwater = 20;
 38   
 39  11 public LetToken(String key, boolean unique, Location location)
 40    {
 41  11 super(location);
 42   
 43  11 _key = key;
 44  11 _unique = unique;
 45    }
 46   
 47  11 public void write(StringBuffer buffer, ScriptSession session)
 48    {
 49  11 if (buffer != null)
 50  0 throw new IllegalArgumentException();
 51   
 52  11 buffer = new StringBuffer(_bufferLengthHighwater);
 53   
 54  11 writeChildren(buffer, session);
 55   
 56    // Store the symbol back into the root set of symbols.
 57   
 58  11 Map symbols = session.getSymbols();
 59   
 60  11 String value = buffer.toString().trim();
 61   
 62  11 if (_unique)
 63  3 value = session.getUniqueString(value);
 64   
 65  11 symbols.put(_key, value);
 66   
 67    // Store the buffer length from this run for the next run, since its
 68    // going to be approximately the right size.
 69   
 70  11 _bufferLengthHighwater = Math.max(_bufferLengthHighwater, buffer.length());
 71    }
 72    }