Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AssetSource |
|
| 1.0;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 | * Used to create an {@link org.apache.tapestry.IAsset} instance for a particular asset path. The | |
26 | * path may have a prefix that indicates its type, or it may be relative to some existing resource. | |
27 | * | |
28 | * @author Howard M. Lewis Ship | |
29 | * @since 4.0 | |
30 | */ | |
31 | public interface AssetSource | |
32 | { | |
33 | /** | |
34 | * Finds an asset relative to some existing resource (typically, a page, component or library | |
35 | * specification). | |
36 | * | |
37 | * @param base | |
38 | * The base resource used for resolving the asset | |
39 | * @param path | |
40 | * the path relative to the base resource; alternately, the path may include a prefix | |
41 | * that defines a domain (such as "classpath:" or "context:") in which case the base | |
42 | * resource is ignored and the resource resolved within that domain | |
43 | * @param locale | |
44 | * used to find a localized version of the asset, may be null to indicate no | |
45 | * localization | |
46 | * @param location | |
47 | * used to report errors (such as missing resources) | |
48 | * | |
49 | * @return the asset, possibly localized | |
50 | * | |
51 | * @throws org.apache.hivemind.ApplicationRuntimeException | |
52 | * if the asset does not exist | |
53 | */ | |
54 | IAsset findAsset(Resource base, String path, Locale locale, Location location); | |
55 | ||
56 | /** | |
57 | * Finds an asset relative to the specified <code>base</code> resources OR {@link IComponentSpecification} passed in. | |
58 | * | |
59 | * @param base | |
60 | * The base resource used for resolving the asset | |
61 | * @param spec | |
62 | * The specification the resource may be relative to if not found relative to base. | |
63 | * @param path | |
64 | * the path relative to the base resource; alternately, the path may include a prefix | |
65 | * that defines a domain (such as "classpath:" or "context:") in which case the base | |
66 | * resource is ignored and the resource resolved within that domain | |
67 | * @param locale | |
68 | * used to find a localized version of the asset, may be null to indicate no | |
69 | * localization | |
70 | * @param location | |
71 | * used to report errors (such as missing resources) | |
72 | * | |
73 | * @return the asset, possibly localized | |
74 | */ | |
75 | IAsset findAsset(Resource base, IComponentSpecification spec, String path, Locale locale, Location location); | |
76 | } |