|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.nds.dirxml.util.LocalizedMessageSource
public class LocalizedMessageSource
Class implementing the MessageSource
interface for obtaining localized messages
for tracing, status messages, etc.
The class is designed such that class hierarchies can use a hierarchy
of LocalizedMessageSource
instances to obtain localized strings. For
example assume com.company.DerivedClass is derived from com.company.BaseClass.
BaseClass would contain a member variable of class LocalizedMessageSource
that is constructed as follows:
LocalizedMessageSource msgSource = new LocalizedMessageSource("com.company.BaseClass");
DerivedClass would contain a member variable of class LocalizedMessageSource that is
constructed as follows:
LocalizedMessageSource msgSource = new LocalizedMessageSource("com.company.DerivedClass",super.msgSource);
DerivedClass can then use message IDs defined in either DerivedClass or BaseClass.
Messages are located in a resource bundle and formatted using java.text.MessageFormat
.
ResourceBundle
,
MessageFormat
Field Summary | |
---|---|
protected ResourceBundle |
bundle
ResourceBundle from which to obtain message strings. |
protected LocalizedMessageSource |
parent
Parent LocalizedMessageSource . |
Constructor Summary | |
---|---|
LocalizedMessageSource(String resourceBundleName)
Construct a LocalizedMessageSource based on the passed resource name. |
|
LocalizedMessageSource(String resourceBundleName,
Locale locale)
Construct a LocalizedMessageSource based on the passed resource name. |
|
LocalizedMessageSource(String resourceBundleName,
LocalizedMessageSource parent)
Construct a LocalizedMessageSource based on the passed resource name and a parent
class's LocalizedMessageSource instance. |
|
LocalizedMessageSource(String resourceBundleName,
LocalizedMessageSource parent,
Locale locale)
Construct a LocalizedMessageSource based on the passed resource name and a parent
class's LocalizedMessageSource instance. |
Method Summary | |
---|---|
String |
getMessage(String msgID,
Object[] parms)
Get a localized message. |
String |
getMessageString(String msgID)
Get a message string from this instance's ResourceBundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ResourceBundle bundle
ResourceBundle
from which to obtain message strings.
protected LocalizedMessageSource parent
LocalizedMessageSource
. If a message is not found in bundle then
parent.getMessageString()
is called.
Constructor Detail |
---|
public LocalizedMessageSource(String resourceBundleName) throws MissingResourceException
LocalizedMessageSource
based on the passed resource name. The
resource name is typically the name of the class that is constructing the
instance. Uses default locale.
resourceBundleName
- name of resource bundle
MissingResourceException
public LocalizedMessageSource(String resourceBundleName, Locale locale) throws MissingResourceException
LocalizedMessageSource
based on the passed resource name. The
resource name is typically the name of the class that is constructing the
instance.
resourceBundleName
- name of resource bundlelocale
- locale for localized resources.
MissingResourceException
public LocalizedMessageSource(String resourceBundleName, LocalizedMessageSource parent) throws MissingResourceException
LocalizedMessageSource
based on the passed resource name and a parent
class's LocalizedMessageSource
instance.
resourceBundleName
- name of resource bundleparent
- parent class's LocalizedMessageSource instance.
MissingResourceException
public LocalizedMessageSource(String resourceBundleName, LocalizedMessageSource parent, Locale locale) throws MissingResourceException
LocalizedMessageSource
based on the passed resource name and a parent
class's LocalizedMessageSource
instance.
resourceBundleName
- name of resource bundleparent
- parent class's LocalizedMessageSource instance.locale
- locale for localized resources.
MissingResourceException
Method Detail |
---|
public String getMessage(String msgID, Object[] parms)
getMessage
in interface MessageSource
msgID
- message key or IDparms
- array of parameters for message (may be null for
messages that do not require parameters).public String getMessageString(String msgID)
msgID
- id or key of message string in resource bundle.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |