01: /**
02: * $Id: Catalog.java,v 1.3 2005/02/25 11:50:05 jraj Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wireless.taglibs.util;
14:
15: import java.util.*;
16:
17: /**
18: * Catalog - a message catalog bean
19: *
20: * @author Bryan Hanks
21: * @author Robert O'Brien
22: * @version 1.0
23: */
24: public class Catalog {
25:
26: /**
27: * Message catalog resource bundle
28: */
29: ResourceBundle resource;
30:
31: /**
32: * Catalog constructor
33: *
34: * @param name resource bundle name
35: * @param locale user's locale
36: * @exception MissingResourceException
37: */
38: public Catalog(String name, Locale locale)
39: throws MissingResourceException {
40: resource = ResourceBundle.getBundle(name, locale);
41: }
42:
43: /**
44: * Return the message specified by the key
45: *
46: * @param key the message key
47: * @return the message string
48: * @exception MissingResourceException
49: */
50: public String getMsg(String key) throws MissingResourceException {
51: return resource.getString(key);
52: }
53:
54: /**
55: * Return the message specified by the key.
56: * If no message found for key, return default (NMJ: CR 4972546).
57: *
58: * @param key The message key
59: * @param dFault A default string to return if key not found.
60: * @return
61: */
62: public String getMsg(String key, String dFault) {
63: String rslt = dFault;
64: try {
65: rslt = resource.getString(key);
66: } catch (MissingResourceException e) {
67: }
68: return rslt;
69: }
70:
71: }
|