|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ComponentMessages.java | - | 100% | 100% | 100% |
|
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.services.impl; | |
16 | ||
17 | import java.text.MessageFormat; | |
18 | import java.util.Locale; | |
19 | import java.util.Properties; | |
20 | ||
21 | import org.apache.hivemind.Messages; | |
22 | import org.apache.hivemind.impl.AbstractMessages; | |
23 | import org.apache.hivemind.util.Defense; | |
24 | ||
25 | /** | |
26 | * Implementation of {@link org.apache.hivemind.Messages}. This is basically a wrapper around an | |
27 | * instance of {@link Properties}. This ensures that the properties are, in fact, read-only (which | |
28 | * ensures that they don't have to be synchronized). | |
29 | * | |
30 | * @author Howard Lewis Ship | |
31 | * @since 2.0.4 | |
32 | */ | |
33 | ||
34 | public class ComponentMessages extends AbstractMessages | |
35 | { | |
36 | private final Properties _properties; | |
37 | ||
38 | private final Locale _locale; | |
39 | ||
40 | 29 | public ComponentMessages(Locale locale, Properties properties) |
41 | { | |
42 | 29 | Defense.notNull(locale, "locale"); |
43 | 29 | Defense.notNull(properties, "properties"); |
44 | ||
45 | 29 | _locale = locale; |
46 | 29 | _properties = properties; |
47 | } | |
48 | ||
49 | 42 | protected String findMessage(String key) |
50 | { | |
51 | 42 | return _properties.getProperty(key); |
52 | } | |
53 | ||
54 | 2 | protected Locale getLocale() |
55 | { | |
56 | 2 | return _locale; |
57 | } | |
58 | } |
|