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: 179   Methods: 15
NCLOC: 78   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
AbstractSpecificationResolver.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.resolver;
 16   
 
 17   
 import org.apache.hivemind.Resource;
 18   
 import org.apache.tapestry.INamespace;
 19   
 import org.apache.tapestry.Tapestry;
 20   
 import org.apache.tapestry.engine.ISpecificationSource;
 21   
 import org.apache.tapestry.spec.IComponentSpecification;
 22   
 
 23   
 /**
 24   
  * Base class for resolving a {@link org.apache.tapestry.spec.IComponentSpecification}for a
 25   
  * particular page or component, within a specified {@link org.apache.tapestry.INamespace}. In some
 26   
  * cases, a search is necessary.
 27   
  * 
 28   
  * @author Howard Lewis Ship
 29   
  * @since 3.0
 30   
  */
 31   
 
 32   
 public class AbstractSpecificationResolver
 33   
 {
 34   
     /** Set by resolve() */
 35   
     private INamespace _namespace;
 36   
 
 37   
     /** Set by resolve() */
 38   
     private IComponentSpecification _specification;
 39   
 
 40   
     /** Set by container */
 41   
     private ISpecificationSource _specificationSource;
 42   
 
 43   
     private ISpecificationResolverDelegate _delegate;
 44   
 
 45   
     private String _applicationId;
 46   
 
 47   
     private Resource _contextRoot;
 48   
 
 49   
     /** Initialized in initializeService() */
 50   
 
 51   
     private Resource _webInfLocation;
 52   
 
 53   
     private Resource _webInfAppLocation;
 54   
 
 55  233
     public void initializeService()
 56   
     {
 57  233
         _webInfLocation = _contextRoot.getRelativeResource("WEB-INF/");
 58   
 
 59  233
         _webInfAppLocation = _webInfLocation.getRelativeResource(_applicationId + "/");
 60   
     }
 61   
 
 62   
     /**
 63   
      * Returns the {@link ISpecificationResolverDelegate}instance registered in the application
 64   
      * specification as extension {@link Tapestry#SPECIFICATION_RESOLVER_DELEGATE_EXTENSION_NAME},
 65   
      * or null if no such extension exists.
 66   
      */
 67   
 
 68  5
     public ISpecificationResolverDelegate getDelegate()
 69   
     {
 70  5
         return _delegate;
 71   
     }
 72   
 
 73   
     /**
 74   
      * Returns the location of the servlet, within the servlet context.
 75   
      */
 76   
 
 77  239
     protected Resource getContextRoot()
 78   
     {
 79  239
         return _contextRoot;
 80   
     }
 81   
 
 82  233
     public void setContextRoot(Resource contextRoot)
 83   
     {
 84  233
         _contextRoot = contextRoot;
 85   
     }
 86   
 
 87   
     /**
 88   
      * Invoked in subclasses to identify the resolved namespace.
 89   
      */
 90   
 
 91  1724
     protected void setNamespace(INamespace namespace)
 92   
     {
 93  1724
         _namespace = namespace;
 94   
     }
 95   
 
 96   
     /**
 97   
      * Returns the resolve namespace.
 98   
      */
 99   
 
 100  1797
     public INamespace getNamespace()
 101   
     {
 102  1797
         return _namespace;
 103   
     }
 104   
 
 105   
     /**
 106   
      * Returns the specification source for the running application.
 107   
      */
 108   
 
 109  488
     protected ISpecificationSource getSpecificationSource()
 110   
     {
 111  488
         return _specificationSource;
 112   
     }
 113   
 
 114   
     /**
 115   
      * Returns the location of /WEB-INF/, in the servlet context.
 116   
      */
 117   
 
 118  190
     protected Resource getWebInfLocation()
 119   
     {
 120  190
         return _webInfLocation;
 121   
     }
 122   
 
 123   
     /**
 124   
      * Returns the location of the application-specific subdirectory, under /WEB-INF/, in the
 125   
      * servlet context.
 126   
      */
 127   
 
 128  192
     protected Resource getWebInfAppLocation()
 129   
     {
 130  192
         return _webInfAppLocation;
 131   
     }
 132   
 
 133   
     /**
 134   
      * Returns the resolved specification.
 135   
      */
 136   
 
 137  3604
     public IComponentSpecification getSpecification()
 138   
     {
 139  3604
         return _specification;
 140   
     }
 141   
 
 142   
     /**
 143   
      * Invoked in subclass to set the final specification the initial inputs are resolved to.
 144   
      */
 145   
 
 146  1694
     protected void setSpecification(IComponentSpecification specification)
 147   
     {
 148  1694
         _specification = specification;
 149   
     }
 150   
 
 151   
     /**
 152   
      * Clears the namespace and specification properties.
 153   
      */
 154   
 
 155  1694
     protected void reset()
 156   
     {
 157  1694
         _namespace = null;
 158  1694
         _specification = null;
 159   
     }
 160   
 
 161   
     /** @since 4.0 */
 162  223
     public void setDelegate(ISpecificationResolverDelegate delegate)
 163   
     {
 164  223
         _delegate = delegate;
 165   
     }
 166   
 
 167   
     /** @since 4.0 */
 168  229
     public void setApplicationId(String applicationId)
 169   
     {
 170  229
         _applicationId = applicationId;
 171   
     }
 172   
 
 173   
     /** @since 4.0 */
 174  237
     public void setSpecificationSource(ISpecificationSource source)
 175   
     {
 176  237
         _specificationSource = source;
 177   
     }
 178   
 
 179   
 }