Coverage Report - org.apache.tapestry.asset.AssetFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AssetFactory
N/A
N/A
1
 
 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.asset;
 16  
 
 17  
 import org.apache.hivemind.Location;
 18  
 import org.apache.hivemind.Resource;
 19  
 import org.apache.tapestry.IAsset;
 20  
 import org.apache.tapestry.spec.IComponentSpecification;
 21  
 
 22  
 import java.util.Locale;
 23  
 
 24  
 /**
 25  
  * A service which creates an asset. In some cases, the asset is selected based on the Resource
 26  
  * (typically of the component or page specification).
 27  
  * 
 28  
  * @author Howard M. Lewis Ship
 29  
  * @since 4.0
 30  
  */
 31  
 public interface AssetFactory
 32  
 {
 33  
 
 34  
     /**
 35  
      * Invoked to check if the factory instance can find a matching asset using the appropriate
 36  
      * strategy specific to its implementation.
 37  
      *
 38  
      * @param spec The optional component specification to check the path against.
 39  
      * @param baseResource The resource that the path may be relative to.
 40  
      * @param path The asset path, relative to baseResource. 
 41  
      * @param locale Optional parameter when a localized version is desired. (may be null)
 42  
      * @return True if the requested asset can be found, false otherwise.
 43  
      */
 44  
     boolean assetExists(IComponentSpecification spec, Resource baseResource, String path, Locale locale);
 45  
 
 46  
     /**
 47  
      * Creates a new asset relative to an existing asset.
 48  
      *
 49  
      * @param spec The optional component specification to check the path against.
 50  
      * 
 51  
      * @param baseResource
 52  
      *            the base resource from which an asset path may be calculated. Each type of asset
 53  
      *            is linked to a particular implemenation of {@link Resource}, and generates a
 54  
      *            corresponding implementation of {@link org.apache.tapestry.IAsset}.
 55  
      * @param path
 56  
      *            the path relative to the resource (if no leading slash), or an absolute path
 57  
      *            within the domain of the asset type (i.e, within the classpath, or within the web
 58  
      *            application).
 59  
      * @param locale
 60  
      *            the desired locale of the asset; the closest match will be used.
 61  
      * @param location
 62  
      *            the location to be associated with the returned asset, or null to not attempt to
 63  
      *            localize the asset
 64  
      * 
 65  
      * @return The created asset.
 66  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 67  
      *             if no matching asset may be found.
 68  
      */
 69  
     IAsset createAsset(Resource baseResource, IComponentSpecification spec, String path, Locale locale, Location location);
 70  
 
 71  
     /**
 72  
      * Creates a new asset relative to the root of the domain defined by the type of asset.
 73  
      * 
 74  
      * @param path
 75  
      *            the absolute path for the resource
 76  
      * @param locale
 77  
      *            the locale to localize the asset to, or null for no localization
 78  
      * @param location
 79  
      *            the location used to report any errors
 80  
      * @return an {@link IAsset}
 81  
      */
 82  
     IAsset createAbsoluteAsset(String path, Locale locale, Location location);
 83  
 
 84  
     /**
 85  
      * Creates a new asset based on a known resource.
 86  
      *
 87  
      * @param resource
 88  
      *          The resource the asset will represent.
 89  
      * @param location
 90  
      *          Location of the resource. (used for error reporting mostly)
 91  
      *
 92  
      * @return The created asset.
 93  
      */
 94  
 
 95  
     IAsset createAsset(Resource resource, Location location);
 96  
 }