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: 121   Methods: 11
NCLOC: 71   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
ScriptSessionImpl.java - 100% 100% 100%
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  19
     public ScriptSessionImpl(Resource scriptTemplateResource, IRequestCycle cycle,
 53   
             IScriptProcessor processor, ExpressionEvaluator evaluator,
 54   
             ValueConverter valueConverter, Map symbols)
 55   
     {
 56  19
         _scriptTemplateResource = scriptTemplateResource;
 57  19
         _cycle = cycle;
 58  19
         _processor = processor;
 59  19
         _symbols = symbols;
 60  19
         _evaluator = evaluator;
 61  19
         _valueConverter = valueConverter;
 62   
     }
 63   
 
 64  46
     public Object evaluate(String expression)
 65   
     {
 66  46
         return _evaluator.read(_symbols, expression);
 67   
     }
 68   
 
 69  12
     public Object evaluate(String expression, Class desiredType)
 70   
     {
 71  12
         Object raw = evaluate(expression);
 72   
 
 73  12
         return _valueConverter.coerceValue(raw, desiredType);
 74   
     }
 75   
 
 76  3
     public Resource getScriptTemplateResource()
 77   
     {
 78  3
         return _scriptTemplateResource;
 79   
     }
 80   
 
 81  40
     public Map getSymbols()
 82   
     {
 83  40
         return _symbols;
 84   
     }
 85   
 
 86  8
     public IRequestCycle getRequestCycle()
 87   
     {
 88  8
         return _cycle;
 89   
     }
 90   
 
 91  8
     public void addBodyScript(String script)
 92   
     {
 93  8
         _processor.addBodyScript(script);
 94   
     }
 95   
 
 96  7
     public void addExternalScript(Resource resource)
 97   
     {
 98  7
         _processor.addExternalScript(resource);
 99   
     }
 100   
 
 101  2
     public void addInitializationScript(String script)
 102   
     {
 103  2
         _processor.addInitializationScript(script);
 104   
     }
 105   
 
 106  7
     public String getUniqueString(String baseValue)
 107   
     {
 108  7
         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   
 }