Clover coverage report - Code Coverage for tapestry release 4.0.2
Coverage timestamp: Thu Apr 13 2006 10:52:06 EDT
file stats: LOC: 121   Methods: 11
NCLOC: 71   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ScriptSessionImpl.java - 90.5% 90.9% 90.6%
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.Resource;
 20    import org.apache.tapestry.IRequestCycle;
 21    import org.apache.tapestry.IScriptProcessor;
 22    import org.apache.tapestry.coerce.ValueConverter;
 23    import org.apache.tapestry.services.ExpressionEvaluator;
 24   
 25    /**
 26    * The result of executing a script, the session is used during the parsing process as well.
 27    * Following
 28    * {@link org.apache.tapestry.IScript#execute(org.apache.tapestry.IRequestCycle, org.apache.tapestry.IScriptProcessor, java.util.Map)},
 29    * the session provides access to output symbols as well as the body and initialization blocks
 30    * created by the script tokens.
 31    *
 32    * @author Howard Lewis Ship
 33    * @since 0.2.9
 34    */
 35   
 36    public class ScriptSessionImpl implements ScriptSession
 37    {
 38    private IRequestCycle _cycle;
 39   
 40    private IScriptProcessor _processor;
 41   
 42    private Resource _scriptTemplateResource;
 43   
 44    private Map _symbols;
 45   
 46    /** @since 4.0 */
 47    private ExpressionEvaluator _evaluator;
 48   
 49    /** @since 4.0 */
 50    private ValueConverter _valueConverter;
 51   
 52  15 public ScriptSessionImpl(Resource scriptTemplateResource, IRequestCycle cycle,
 53    IScriptProcessor processor, ExpressionEvaluator evaluator,
 54    ValueConverter valueConverter, Map symbols)
 55    {
 56  15 _scriptTemplateResource = scriptTemplateResource;
 57  15 _cycle = cycle;
 58  15 _processor = processor;
 59  15 _symbols = symbols;
 60  15 _evaluator = evaluator;
 61  15 _valueConverter = valueConverter;
 62    }
 63   
 64  6 public Object evaluate(String expression)
 65    {
 66  6 return _evaluator.read(_symbols, expression);
 67    }
 68   
 69  0 public Object evaluate(String expression, Class desiredType)
 70    {
 71  0 Object raw = evaluate(expression);
 72   
 73  0 return _valueConverter.coerceValue(raw, desiredType);
 74    }
 75   
 76  3 public Resource getScriptTemplateResource()
 77    {
 78  3 return _scriptTemplateResource;
 79    }
 80   
 81  16 public Map getSymbols()
 82    {
 83  16 return _symbols;
 84    }
 85   
 86  4 public IRequestCycle getRequestCycle()
 87    {
 88  4 return _cycle;
 89    }
 90   
 91  4 public void addBodyScript(String script)
 92    {
 93  4 _processor.addBodyScript(script);
 94    }
 95   
 96  3 public void addExternalScript(Resource resource)
 97    {
 98  3 _processor.addExternalScript(resource);
 99    }
 100   
 101  2 public void addInitializationScript(String script)
 102    {
 103  2 _processor.addInitializationScript(script);
 104    }
 105   
 106  3 public String getUniqueString(String baseValue)
 107    {
 108  3 return _processor.getUniqueString(baseValue);
 109    }
 110   
 111  1 public String toString()
 112    {
 113  1 StringBuffer buffer = new StringBuffer();
 114   
 115  1 buffer.append("ScriptSession[");
 116  1 buffer.append(_scriptTemplateResource);
 117  1 buffer.append(']');
 118   
 119  1 return buffer.toString();
 120    }
 121    }