KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > ComponentMessages


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 JavaDoc;
18 import java.util.Locale JavaDoc;
19 import java.util.Properties JavaDoc;
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 JavaDoc _properties;
37
38     private final Locale JavaDoc _locale;
39
40     public ComponentMessages(Locale JavaDoc locale, Properties JavaDoc properties)
41     {
42         Defense.notNull(locale, "locale");
43         Defense.notNull(properties, "properties");
44
45         _locale = locale;
46         _properties = properties;
47     }
48
49     protected String JavaDoc findMessage(String JavaDoc key)
50     {
51         return _properties.getProperty(key);
52     }
53
54     protected Locale JavaDoc getLocale()
55     {
56         return _locale;
57     }
58 }
Popular Tags