update dev300-m58
[ooovba.git] / sj2 / stardiv / app / AppletMessageHandler.java
blob742d41d91a215756ddb3f5e4518cae5900c1717b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppletMessageHandler.java,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
31 package stardiv.app;
33 import java.util.ResourceBundle;
34 import java.util.MissingResourceException;
35 import java.text.MessageFormat;
37 /**
38 * An hanlder of localized messages.
40 * @version 1.8, 03/03/97
41 * @author Koji Uno
43 public class AppletMessageHandler {
44 private static ResourceBundle rb;
45 private String baseKey = null;
47 static {
48 try {
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];
67 if (arg == null) {
68 arg = "null"; // mimic java.io.PrintStream.print(String)
70 msgobj[0] = arg;
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];
78 if (arg1 == null) {
79 arg1 = "null";
81 if (arg2 == null) {
82 arg2 = "null";
84 msgobj[0] = arg1;
85 msgobj[1] = arg2;
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];
93 if (arg1 == null) {
94 arg1 = "null";
96 if (arg2 == null) {
97 arg2 = "null";
99 if (arg3 == null) {
100 arg3 = "null";
102 msgobj[0] = arg1;
103 msgobj[1] = arg2;
104 msgobj[2] = arg3;
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;