1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.ca;
34
import java.text.MessageFormat;
35
import java.util.ResourceBundle;
36
import javax.security.auth.login.LoginException;
39
* Helper class for i18n.
44
public static final String BUNDLE = "com.sun.grid.ca.Resources";
47
* Get the resource bundle for this package
48
* @return the resource bundle
50
public static ResourceBundle rb() {
51
return ResourceBundle.getBundle(BUNDLE);
55
* Get a string from the resource bundle
56
* @param key the key for the string
59
public static String getString(String key) {
60
return rb().getString(key);
64
* Get a formatted message from the resource bundle
65
* @param key the key of the message
66
* @param param single parameter for the format
67
* @return the formatted message
69
public static String getString(String key, Object param) {
70
return getString(key, new Object[] { param });
74
* Get a formatted message from the resource bundle
75
* @param key the key of the message
76
* @param param arra with parameters for the format
77
* @return the formatted message
79
public static String getString(String key, Object [] params) {
80
String ret = rb().getString(key);
82
ret = MessageFormat.format(ret, params);
88
* Create a <code>GridCAException</code> with a localized message
89
* @param key the key of the message
90
* @return the <code>GridCAException</code> with a localized message
92
public static GridCAException newGridCAException(String key) {
93
return newGridCAException(key, null);
97
* Create a <code>GridCAException</code> with a localized message
98
* @param key the key of the message
99
* @param params parameters for the message
100
* @return the <code>GridCAException</code> with a localized message
102
public static GridCAException newGridCAException(String key, Object params) {
103
return newGridCAException(key, params == null ? null : new Object [] { params } );
107
* Create a <code>GridCAException</code> with a localized message
108
* @param key the key of the message
109
* @param params parameters for the message
110
* @return the <code>GridCAException</code> with a localized message
112
public static GridCAException newGridCAException(String key, Object [] params) {
113
String message = rb().getString(key);
115
message = MessageFormat.format(message, params);
117
return new GridCAException(message);
121
* Create a <code>GridCAException</code> with a localized message
122
* @param key the key of the message
123
* @param cause cause of the exception
124
* @param params parameters for the message
125
* @return the <code>GridCAException</code> with a localized message
127
public static GridCAException newGridCAException(Throwable cause, String key, Object params) {
128
return newGridCAException(cause, key,
129
params == null ? null : new Object [] { params });
133
* Create a <code>GridCAException</code> with a localized message
134
* @param key the key of the message
135
* @param cause cause of the exception
136
* @param params parameters for the message
137
* @return the <code>GridCAException</code> with a localized message
139
public static GridCAException newGridCAException(Throwable cause, String key, Object [] params) {
140
GridCAException ret = newGridCAException(key, params);
141
ret.initCause(cause);