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
94
95
96
97
98
99
|
/*******************************************************************************
* Copyright (c) 2006, 2008 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.pagedesigner.editors.pagedesigner;
import java.text.MessageFormat;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.pagedesigner.PDPlugin;
/**
* @A tool class for message format
*/
public final class MessageFormater {
private static Logger _log = PDPlugin.getLogger(MessageFormater.class);
/**
*
* @param message
* the parts for filling is {number}
* @param o1
* @return the formatted string
*/
public static String format(String message, Object o1) {
try {
Object[] args = new Object[] { o1 };
MessageFormat formatter = new MessageFormat(message);
return formatter.format(args);
} catch (Exception e) {
_log.error("Log.Error.MessageFormater.Format0", e); //$NON-NLS-1$
return ""; //$NON-NLS-1$
}
}
/**
* @param message
* @param o1
* @param o2
* @return the formatted string
*/
public static String format(String message, Object o1, Object o2) {
try {
Object[] args = new Object[] { o1, o2 };
MessageFormat formatter = new MessageFormat(message);
return formatter.format(args);
} catch (Exception e) {
_log.error("Log.Error.MessageFormater.Format0", e); //$NON-NLS-1$
return ""; //$NON-NLS-1$
}
}
/**
* @param message
* @param o1
* @param o2
* @param o3
* @return the formatted string
*/
public static String format(String message, Object o1, Object o2, Object o3) {
try {
Object[] args = new Object[] { o1, o2, o3 };
MessageFormat formatter = new MessageFormat(message);
return formatter.format(args);
} catch (Exception e) {
_log.error("Log.Error.MessageFormater.Format0", e); //$NON-NLS-1$
return ""; //$NON-NLS-1$
}
}
/**
* @param message
* @param o
* @return the formatted string
*/
public static String format(String message, Object o[]) {
try {
MessageFormat formater = new MessageFormat(message);
return formater.format(o);
} catch (Exception e) {
_log.error("Log.Error.MessageFormater.Format0", e); //$NON-NLS-1$
return ""; //$NON-NLS-1$
}
}
private MessageFormater()
{
// util class, no instantiation
}
}
|