KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > util > CLILocalStringsManager


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.admin.util;
24
25 import java.util.ResourceBundle JavaDoc;
26 import java.util.Locale JavaDoc;
27 import java.text.MessageFormat JavaDoc;
28
29
30 /**
31  * Implementation of a CLI local string manager as CLI-specific wrapper around LocalStringsManager;
32  * Provides access to i18n messages for classes that need them.
33  * This particular implementation presents the following resources organization:
34  *<ul>
35  * <li>1. Resource files share locations with sources (same directories);</li>
36  * <li>2. Base directory is "com.sun.enterprise.admin";</li>
37  * <li>3. Search ONLY in first resource bundle, which found on the way up to basePackage( No additional hiearchical search of value if it is not found in that file)</li>
38  *</ul>
39  */

40
41 public class CLILocalStringsManager extends LocalStringsManager
42 {
43     static final String JavaDoc CLI_BASE_PACKAGE = "com.sun.enterprise.tools.cli";
44     static final String JavaDoc DEFAULT_PROPERTY_FILE_NAME = "bundle";
45
46
47     public CLILocalStringsManager()
48     {
49         super(CLI_BASE_PACKAGE, DEFAULT_PROPERTY_FILE_NAME);
50         setFixedResourceBundle(CLI_BASE_PACKAGE);
51     }
52
53     
54     /**
55      * Get a localized string.
56      * @param key The name of the resource to fetch
57      * @param defaultValue The default return value if not found
58      * @return The localized string
59      */

60     public String JavaDoc getString( String JavaDoc key, String JavaDoc defaultValue)
61     {
62         return super.getString(key, defaultValue);
63     }
64
65     /**
66      * Get a local string and format the arguments accordingly.
67      * @param key The key to the local format string
68      * @param defaultFormat The default format if not found in the resources
69      * @param arguments The set of arguments to provide to the formatter
70      * @return A formatted localized string
71      */

72     public String JavaDoc getString( String JavaDoc key, String JavaDoc defaultFormat, Object JavaDoc[] args)
73     {
74         return super.getString(key, defaultFormat, args);
75     }
76
77     /**
78      * Convenience method - getString() overriding for fixed number of formatting arguments.
79      * @param key The key to the local format string
80      * @param defaultFormat The default format if not found in the resources
81      * @param arg1 The first argument to provide to the formatter
82      * @return A formatted localized string
83      */

84     public String JavaDoc getString( String JavaDoc key, String JavaDoc defaultFormat, Object JavaDoc arg1)
85     {
86         return getString(key, defaultFormat, (new Object JavaDoc[]{arg1}));
87     }
88
89     /**
90      * Convenience method - getString() overriding for fixed number of formatting arguments.
91      * @param key The key to the local format string
92      * @param defaultFormat The default format if not found in the resources
93      * @param arg1 The first argument to provide to the formatter
94      * @param arg1 The second argument to provide to the formatter
95      * @return A formatted localized string
96      */

97     public String JavaDoc getString( String JavaDoc key, String JavaDoc defaultFormat, Object JavaDoc arg1, Object JavaDoc arg2)
98     {
99         return getString(key, defaultFormat, (new Object JavaDoc[]{arg1, arg2}));
100     }
101
102     /**
103      * Convenience method - getString() overriding for fixed number of formatting arguments.
104      * @param key The key to the local format string
105      * @param defaultFormat The default format if not found in the resources
106      * @param arg1 The first argument to provide to the formatter
107      * @param arg2 The second argument to provide to the formatter
108      * @param arg3 The third argument to provide to the formatter
109      * @return A formatted localized string
110      */

111     public String JavaDoc getString( String JavaDoc key, String JavaDoc defaultFormat, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3)
112     {
113         return getString(key, defaultFormat, (new Object JavaDoc[]{arg1, arg2, arg3}));
114     }
115 }
116
117
Popular Tags