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