1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppletMessageHandler.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.util
.ResourceBundle
;
34 import java
.util
.MissingResourceException
;
35 import java
.text
.MessageFormat
;
38 * An hanlder of localized messages.
40 * @version 1.8, 03/03/97
43 public class AppletMessageHandler
{
44 private static ResourceBundle rb
;
45 private String baseKey
= null;
49 rb
= ResourceBundle
.getBundle("stardiv.app.MsgAppletViewer");
50 } catch (MissingResourceException e
) {
51 System
.out
.println(e
.getMessage());
55 public AppletMessageHandler(String baseKey
) {
56 this.baseKey
= baseKey
;
59 public String
getMessage(String key
) {
60 return (String
)rb
.getString(getQualifiedKey(key
));
63 public String
getMessage(String key
, Object arg
){
64 String basemsgfmt
= (String
)rb
.getString(getQualifiedKey(key
));
65 MessageFormat msgfmt
= new MessageFormat(basemsgfmt
);
66 Object msgobj
[] = new Object
[1];
68 arg
= "null"; // mimic java.io.PrintStream.print(String)
71 return msgfmt
.format(msgobj
);
74 public String
getMessage(String key
, Object arg1
, Object arg2
) {
75 String basemsgfmt
= (String
)rb
.getString(getQualifiedKey(key
));
76 MessageFormat msgfmt
= new MessageFormat(basemsgfmt
);
77 Object msgobj
[] = new Object
[2];
86 return msgfmt
.format(msgobj
);
89 public String
getMessage(String key
, Object arg1
, Object arg2
, Object arg3
) {
90 String basemsgfmt
= (String
)rb
.getString(getQualifiedKey(key
));
91 MessageFormat msgfmt
= new MessageFormat(basemsgfmt
);
92 Object msgobj
[] = new Object
[3];
105 return msgfmt
.format(msgobj
);
108 public String
getMessage(String key
, Object arg
[]) {
109 String basemsgfmt
= (String
)rb
.getString(getQualifiedKey(key
));
110 MessageFormat msgfmt
= new MessageFormat(basemsgfmt
);
111 return msgfmt
.format(arg
);
114 public String
getQualifiedKey(String subKey
) {
115 return baseKey
+ "." + subKey
;