Clover coverage report - Code Coverage for tapestry release 4.0-beta-8
Coverage timestamp: Sat Sep 24 2005 11:50:34 EDT
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  218 public void initializeService()
 55    {
 56  218 _webInfLocation = _contextRoot.getRelativeResource("WEB-INF/");
 57   
 58  218 _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  5 public ISpecificationResolverDelegate getDelegate()
 68    {
 69  5 return _delegate;
 70    }
 71   
 72    /**
 73    * Returns the location of the servlet, within the servlet context.
 74    */
 75   
 76  214 protected Resource getContextRoot()
 77    {
 78  214 return _contextRoot;
 79    }
 80   
 81  218 public void setContextRoot(Resource contextRoot)
 82    {
 83  218 _contextRoot = contextRoot;
 84    }
 85   
 86    /**
 87    * Invoked in subclasses to identify the resolved namespace.
 88    */
 89   
 90  1664 protected void setNamespace(INamespace namespace)
 91    {
 92  1664 _namespace = namespace;
 93    }
 94   
 95    /**
 96    * Returns the resolve namespace.
 97    */
 98   
 99  1681 public INamespace getNamespace()
 100    {
 101  1681 return _namespace;
 102    }
 103   
 104    /**
 105    * Returns the specification source for the running application.
 106    */
 107   
 108  444 protected ISpecificationSource getSpecificationSource()
 109    {
 110  444 return _specificationSource;
 111    }
 112   
 113    /**
 114    * Returns the location of /WEB-INF/, in the servlet context.
 115    */
 116   
 117  167 protected Resource getWebInfLocation()
 118    {
 119  167 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  169 protected Resource getWebInfAppLocation()
 128    {
 129  169 return _webInfAppLocation;
 130    }
 131   
 132    /**
 133    * Returns the resolved specification.
 134    */
 135   
 136  2956 public IComponentSpecification getSpecification()
 137    {
 138  2956 return _specification;
 139    }
 140   
 141    /**
 142    * Invoked in subclass to set the final specification the initial inputs are resolved to.
 143    */
 144   
 145  1632 protected void setSpecification(IComponentSpecification specification)
 146    {
 147  1632 _specification = specification;
 148    }
 149   
 150    /**
 151    * Clears the namespace and specification properties.
 152    */
 153   
 154  1635 protected void reset()
 155    {
 156  1635 _namespace = null;
 157  1635 _specification = null;
 158    }
 159   
 160    /** @since 4.0 */
 161  207 public void setDelegate(ISpecificationResolverDelegate delegate)
 162    {
 163  207 _delegate = delegate;
 164    }
 165   
 166    /** @since 4.0 */
 167  213 public void setApplicationId(String applicationId)
 168    {
 169  213 _applicationId = applicationId;
 170    }
 171   
 172    /** @since 4.0 */
 173  222 public void setSpecificationSource(ISpecificationSource source)
 174    {
 175  222 _specificationSource = source;
 176    }
 177   
 178    /** @since 4.0 */
 179  1 protected INamespace getApplicationNamespace()
 180    {
 181  1 return _specificationSource.getApplicationNamespace();
 182    }
 183   
 184    /** @since 4.0 */
 185  1 protected INamespace getFrameworkNamespace()
 186    {
 187  1 return _specificationSource.getFrameworkNamespace();
 188    }
 189   
 190    /**
 191    * @since 4.0
 192    */
 193  1496 protected INamespace findNamespaceForId(INamespace containerNamespace, String libraryId)
 194    {
 195  1496 if (libraryId == null)
 196  1331 return containerNamespace;
 197   
 198  165 if (libraryId.equals(INamespace.APPLICATION_NAMESPACE))
 199  1 return getApplicationNamespace();
 200   
 201  164 if (libraryId.equals(INamespace.FRAMEWORK_NAMESPACE))
 202  1 return getFrameworkNamespace();
 203   
 204  163 return containerNamespace.getChildNamespace(libraryId);
 205    }
 206    }