Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ComponentPropertySource |
|
| 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.services; | |
16 | ||
17 | import org.apache.tapestry.IComponent; | |
18 | import org.apache.tapestry.INamespace; | |
19 | ||
20 | import java.util.Locale; | |
21 | ||
22 | /** | |
23 | * Encapsulates the logic for searching for component meta-data. Deployed as service | |
24 | * tapestry.props.ComponentPropertySource. | |
25 | * | |
26 | * <p> | |
27 | * TODO: Adjust name, since it now provides access to namespace properties as well as component | |
28 | * properties. | |
29 | * </p> | |
30 | * | |
31 | * @author Howard M. Lewis Ship | |
32 | * @since 4.0 | |
33 | */ | |
34 | public interface ComponentPropertySource | |
35 | { | |
36 | /** | |
37 | * Returns the property value for a particular named meta-data property of the component. The | |
38 | * search order is: | |
39 | * <ul> | |
40 | * <li>The component's specification</li> | |
41 | * <li>The specification of the application (or the library containing the component).</li> | |
42 | * <li>The chain of global property sources.</li> | |
43 | * </ul> | |
44 | * | |
45 | * @param component | |
46 | * The {@link IComponent} to get the property of. | |
47 | * @param propertyName | |
48 | * Key of the property. | |
49 | * | |
50 | * @return the value of the given key, or null if not found. | |
51 | */ | |
52 | ||
53 | String getComponentProperty(IComponent component, String propertyName); | |
54 | ||
55 | /** | |
56 | * Like {@link #getComponentProperty(IComponent, String)}, but the property name will be | |
57 | * localized to the component's current locale (determined from its page). Localizing the | |
58 | * property name means that a suffix may be appended to it. If the fully localized name is not | |
59 | * found, then the locale is generalized (i.e., from "en_UK" to "en" to nothing) until a match | |
60 | * is found. | |
61 | * | |
62 | * @param component | |
63 | * The {@link IComponent} to get the property of. | |
64 | * @param locale | |
65 | * The {@link Locale} to get properties for. | |
66 | * @param propertyName | |
67 | * Key of the property. | |
68 | * | |
69 | * @return the value of the given property name, or null if not found. | |
70 | */ | |
71 | String getLocalizedComponentProperty(IComponent component, Locale locale, String propertyName); | |
72 | ||
73 | /** | |
74 | * Returns the property value for a particular named meta-data property of the namespace. The | |
75 | * search order is: | |
76 | * | |
77 | * <ul> | |
78 | * <li>The library or application specification for the namespace.</li> | |
79 | * <li>The chain of global property sources.</li> | |
80 | * </ul> | |
81 | * | |
82 | * @param namespace | |
83 | * The namespace to get the property from. | |
84 | * @param propertyName | |
85 | * The key of the property to get. | |
86 | * | |
87 | * @return the value of the given key, or null if not found. | |
88 | */ | |
89 | ||
90 | String getNamespaceProperty(INamespace namespace, String propertyName); | |
91 | ||
92 | /** | |
93 | * As with {@link #getLocalizedComponentProperty(IComponent, Locale, String)}, but with a | |
94 | * {@link INamespace}. | |
95 | * | |
96 | * @param namespace | |
97 | * The namespace to get the property from. | |
98 | * @param locale | |
99 | * {@link Locale} to filter the properties for. | |
100 | * @param propertyName | |
101 | * The key of the property to get. | |
102 | * | |
103 | * @return The matching property, or null if not found. | |
104 | */ | |
105 | ||
106 | String getLocalizedNamespaceProperty(INamespace namespace, Locale locale, String propertyName); | |
107 | } |