Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 206   Methods: 18
NCLOC: 95   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractSpecificationResolver.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.resolver;
 16   
 17    import org.apache.hivemind.Resource;
 18    import org.apache.tapestry.INamespace;
 19    import org.apache.tapestry.engine.ISpecificationSource;
 20    import org.apache.tapestry.spec.IComponentSpecification;
 21   
 22    /**
 23    * Base class for resolving a {@link org.apache.tapestry.spec.IComponentSpecification}for a
 24    * particular page or component, within a specified {@link org.apache.tapestry.INamespace}. In some
 25    * cases, a search is necessary.
 26    *
 27    * @author Howard Lewis Ship
 28    * @since 3.0
 29    */
 30   
 31    public class AbstractSpecificationResolver
 32    {
 33    /** Set by resolve() */
 34    private INamespace _namespace;
 35   
 36    /** Set by resolve() */
 37    private IComponentSpecification _specification;
 38   
 39    /** Set by container */
 40    private ISpecificationSource _specificationSource;
 41   
 42    private ISpecificationResolverDelegate _delegate;
 43   
 44    private String _applicationId;
 45   
 46    private Resource _contextRoot;
 47   
 48    /** Initialized in initializeService() */
 49   
 50    private Resource _webInfLocation;
 51   
 52    private Resource _webInfAppLocation;
 53   
 54  410 public void initializeService()
 55    {
 56  410 _webInfLocation = _contextRoot.getRelativeResource("WEB-INF/");
 57   
 58  410 _webInfAppLocation = _webInfLocation.getRelativeResource(_applicationId + "/");
 59    }
 60   
 61    /**
 62    * Returns the {@link ISpecificationResolverDelegate}instance registered in the application
 63    * specification as extension {@link Tapestry#SPECIFICATION_RESOLVER_DELEGATE_EXTENSION_NAME},
 64    * or null if no such extension exists.
 65    */
 66   
 67  10 public ISpecificationResolverDelegate getDelegate()
 68    {
 69  10 return _delegate;
 70    }
 71   
 72    /**
 73    * Returns the location of the servlet, within the servlet context.
 74    */
 75   
 76  390 protected Resource getContextRoot()
 77    {
 78  390 return _contextRoot;
 79    }
 80   
 81  410 public void setContextRoot(Resource contextRoot)
 82    {
 83  410 _contextRoot = contextRoot;
 84    }
 85   
 86    /**
 87    * Invoked in subclasses to identify the resolved namespace.
 88    */
 89   
 90  3058 protected void setNamespace(INamespace namespace)
 91    {
 92  3058 _namespace = namespace;
 93    }
 94   
 95    /**
 96    * Returns the resolve namespace.
 97    */
 98   
 99  3090 public INamespace getNamespace()
 100    {
 101  3090 return _namespace;
 102    }
 103   
 104    /**
 105    * Returns the specification source for the running application.
 106    */
 107   
 108  838 protected ISpecificationSource getSpecificationSource()
 109    {
 110  838 return _specificationSource;
 111    }
 112   
 113    /**
 114    * Returns the location of /WEB-INF/, in the servlet context.
 115    */
 116   
 117  306 protected Resource getWebInfLocation()
 118    {
 119  306 return _webInfLocation;
 120    }
 121   
 122    /**
 123    * Returns the location of the application-specific subdirectory, under /WEB-INF/, in the
 124    * servlet context.
 125    */
 126   
 127  310 protected Resource getWebInfAppLocation()
 128    {
 129  310 return _webInfAppLocation;
 130    }
 131   
 132    /**
 133    * Returns the resolved specification.
 134    */
 135   
 136  5416 public IComponentSpecification getSpecification()
 137    {
 138  5416 return _specification;
 139    }
 140   
 141    /**
 142    * Invoked in subclass to set the final specification the initial inputs are resolved to.
 143    */
 144   
 145  2998 protected void setSpecification(IComponentSpecification specification)
 146    {
 147  2998 _specification = specification;
 148    }
 149   
 150    /**
 151    * Clears the namespace and specification properties.
 152    */
 153   
 154  3008 protected void reset()
 155    {
 156  3008 _namespace = null;
 157  3008 _specification = null;
 158    }
 159   
 160    /** @since 4.0 */
 161  386 public void setDelegate(ISpecificationResolverDelegate delegate)
 162    {
 163  386 _delegate = delegate;
 164    }
 165   
 166    /** @since 4.0 */
 167  398 public void setApplicationId(String applicationId)
 168    {
 169  398 _applicationId = applicationId;
 170    }
 171   
 172    /** @since 4.0 */
 173  418 public void setSpecificationSource(ISpecificationSource source)
 174    {
 175  418 _specificationSource = source;
 176    }
 177   
 178    /** @since 4.0 */
 179  2 protected INamespace getApplicationNamespace()
 180    {
 181  2 return _specificationSource.getApplicationNamespace();
 182    }
 183   
 184    /** @since 4.0 */
 185  2 protected INamespace getFrameworkNamespace()
 186    {
 187  2 return _specificationSource.getFrameworkNamespace();
 188    }
 189   
 190    /**
 191    * @since 4.0
 192    */
 193  2744 protected INamespace findNamespaceForId(INamespace containerNamespace, String libraryId)
 194    {
 195  2744 if (libraryId == null)
 196  2414 return containerNamespace;
 197   
 198  330 if (libraryId.equals(INamespace.APPLICATION_NAMESPACE))
 199  2 return getApplicationNamespace();
 200   
 201  328 if (libraryId.equals(INamespace.FRAMEWORK_NAMESPACE))
 202  2 return getFrameworkNamespace();
 203   
 204  326 return containerNamespace.getChildNamespace(libraryId);
 205    }
 206    }