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: 68   Methods: 2
NCLOC: 35   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
InputSymbolToken.java 100% 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 org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.hivemind.Location;
 19   
 import org.apache.tapestry.Tapestry;
 20   
 
 21   
 /**
 22   
  *  A token that validates that an input symbol exists or is of a
 23   
  *  declared type.
 24   
  *
 25   
  *
 26   
  *  @author Howard Lewis Ship
 27   
  *  @since 2.2
 28   
  * 
 29   
  **/
 30   
 
 31   
 class InputSymbolToken extends AbstractToken
 32   
 {
 33   
     private String _key;
 34   
     private Class _class;
 35   
     private boolean _required;
 36   
 
 37  15
     InputSymbolToken(String key, Class clazz, boolean required, Location location)
 38   
     {
 39  15
         super(location);
 40   
 
 41  15
         _key = key;
 42  15
         _class = clazz;
 43  15
         _required = required;
 44   
     }
 45   
 
 46  24
     public void write(StringBuffer buffer, ScriptSession session)
 47   
     {
 48  24
         Object value = session.getSymbols().get(_key);
 49   
 
 50  24
         if (_required && value == null)
 51  1
             throw new ApplicationRuntimeException(
 52   
                 Tapestry.format("InputSymbolToken.required", _key),
 53   
                 getLocation(),
 54   
                 null);
 55   
 
 56  23
         if (value != null && _class != null && !_class.isAssignableFrom(value.getClass()))
 57  1
             throw new ApplicationRuntimeException(
 58   
                 Tapestry.format(
 59   
                     "InputSymbolToken.wrong-type",
 60   
                     _key,
 61   
                     value.getClass().getName(),
 62   
                     _class.getName()),
 63   
                 getLocation(),
 64   
                 null);
 65   
     }
 66   
 
 67   
 }
 68