KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > LocalStringManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.util;
24
25 /**
26  * A local string manager.
27  * This interface describes the access to i18n messages for classes that need
28  * them.
29  */

30
31 public interface LocalStringManager {
32
33     /**
34      * Get a localized string.
35      * Strings are stored in a single property file per package named
36      * LocalStrings[_locale].properties. Starting from the class of the
37      * caller, we walk up the class hierarchy until we find a package
38      * resource bundle that provides a value for the requested key.
39      *
40      * <p>This simplifies access to resources, at the cost of checking for
41      * the resource bundle of several classes upon each call. However, due
42      * to the caching performed by <tt>ResourceBundle</tt> this seems
43      * reasonable.
44      *
45      * <p>Due to that, sub-classes <strong>must</strong> make sure they don't
46      * have conflicting resource naming.
47      * @param callerClass The object making the call, to allow per-package
48      * resource bundles
49      * @param key The name of the resource to fetch
50      * @param defaultValue The default return value if not found
51      * @return The localized value for the resource
52      */

53     public String JavaDoc getLocalString(
54     Class JavaDoc callerClass,
55     String JavaDoc key,
56     String JavaDoc defaultValue
57     );
58
59     /**
60      * Get a local string for the caller and format the arguments accordingly.
61      * @param callerClass The caller (to walk through its class hierarchy)
62      * @param key The key to the local format string
63      * @param fmt The default format if not found in the resources
64      * @param arguments The set of arguments to provide to the formatter
65      * @return A formatted localized string
66      */

67     public String JavaDoc getLocalString(
68     Class JavaDoc callerClass,
69     String JavaDoc key,
70     String JavaDoc defaultFormat,
71     Object JavaDoc arguments[]
72     );
73 }
74
Popular Tags