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: 70   Methods: 3
NCLOC: 39   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
InjectSpecificationWorker.java - 100% 100% 100%
coverage
 1    // Copyright 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.enhance;
 16   
 17    import org.apache.hivemind.ErrorLog;
 18    import org.apache.hivemind.util.Defense;
 19    import org.apache.tapestry.spec.IComponentSpecification;
 20   
 21    /**
 22    * Injects the component's specification as the
 23    * {@link org.apache.tapestry.IComponent#getSpecification() specification}property.
 24    *
 25    * @author Howard M. Lewis Ship
 26    * @since 4.0
 27    */
 28    public class InjectSpecificationWorker implements EnhancementWorker
 29    {
 30    public static final String SPECIFICATION_PROPERTY_NAME = "specification";
 31   
 32    private ErrorLog _errorLog;
 33   
 34  436 public void performEnhancement(EnhancementOperation op, IComponentSpecification spec)
 35    {
 36  436 try
 37    {
 38  436 injectSpecification(op, spec);
 39    }
 40    catch (Exception ex)
 41    {
 42  1 _errorLog.error(EnhanceMessages.errorAddingProperty(SPECIFICATION_PROPERTY_NAME, op
 43    .getBaseClass(), ex), spec.getLocation(), ex);
 44    }
 45    }
 46   
 47  436 public void injectSpecification(EnhancementOperation op, IComponentSpecification spec)
 48    {
 49  436 Defense.notNull(op, "op");
 50  436 Defense.notNull(spec, "spec");
 51   
 52  436 op.claimProperty(SPECIFICATION_PROPERTY_NAME);
 53   
 54  435 String fieldName = op.addInjectedField(
 55    "_$" + SPECIFICATION_PROPERTY_NAME,
 56    IComponentSpecification.class,
 57    spec);
 58   
 59  435 EnhanceUtils.createSimpleAccessor(
 60    op,
 61    fieldName,
 62    SPECIFICATION_PROPERTY_NAME,
 63    IComponentSpecification.class);
 64    }
 65   
 66  42 public void setErrorLog(ErrorLog errorLog)
 67    {
 68  42 _errorLog = errorLog;
 69    }
 70    }