1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*******************************************************************************
* Copyright (c) 2001, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.wsdl.validation.internal.util;
import java.util.ResourceBundle;
import java.text.MessageFormat;
/**
* A convenience class for working with resources in a resource bundle.
*/
public class MessageGenerator
{
protected ResourceBundle resourcebundle;
/**
* Constructor.
*
* @param rb The resource bundle to work with.
*/
public MessageGenerator(ResourceBundle rb)
{
resourcebundle = rb;
}
/**
* Set the resourcebundle to the one specified.
*
* @param rb The resource bundle to set.
*/
protected void setResourceBundle(ResourceBundle rb)
{
resourcebundle = rb;
}
/**
* Gets the string resource for the given key.
*
* @param key The key for the resource.
* @return The string from the resource bundle.
*/
public String getString(String key)
{
return resourcebundle.getString(key);
}
/**
* Gets the string resource for the given key and does one substitution.
*
* @param key The key for the resource.
* @param s1 The substitution to perform.
* @return The string from the resource bundle.
*/
public String getString(String key, Object s1)
{
return MessageFormat.format(getString(key), new Object[] { s1 });
}
/**
* Gets the string resource for the given key and does two substitutions.
*
* @param key The key for the resource.
* @param s1 The first substitution to perform.
* @param s2 The second substitution to perform.
* @return The string from the resource bundle.
*/
public String getString(String key, Object s1, Object s2)
{
return MessageFormat.format(getString(key), new Object[] { s1, s2 });
}
/**
* Gets the string resource for the given key and does three substitutions.
*
* @param key The key for the resource.
* @param s1 The first substitution to perform.
* @param s2 The second substitution to perform.
* @param s3 The third substitution to perform.
* @return The string from the resource bundle.
*/
public String getString(String key, Object s1, Object s2, Object s3)
{
return MessageFormat.format(getString(key), new Object[] { s1, s2, s3 });
}
}
|