com.levigo.util.swing.messaging
Class DefaultMessageFactory

java.lang.Object
  extended by com.levigo.util.swing.messaging.DefaultMessageFactory
All Implemented Interfaces:
MessageFactory

public class DefaultMessageFactory
extends Object
implements MessageFactory

A factory that makes Message Objects availiable.

You can register/deregister to this class several MessageResources.
So its possible to register at startup of application some default resources and only if its necessary add/remove other resources. Resources will added only once, trying to add a resource a second time will do nothing.

The factory expects the following key/value pairs for each message:

Author:
Carolin Koehler

Field Summary
static String[] OK_ACTION_TEXTS
          The default text for a pure confirmation action.
static String[] OK_CANCEL_ACTION_TEXTS
          The default text pair for the OK/CANCEL action.
static String[] YES_NO_ACTION_TEXTS
          An alternative text pair for the OK/CANCEL action, representing YES/NO.
static String[] YES_NO_CANCEL_ACTION_TEXTS
          An alternative text pair for the OK/NO/CANCEL action, representing YES/NO.
 
Constructor Summary
DefaultMessageFactory(String bundleName)
          Constructor for MessageFactory.
 
Method Summary
 boolean containsKey(String key)
          Returns whether given key has a value in one of the registered resources.
 Message createMessage(String messageKey)
          Create a Message specified by given key.
 Message createMessage(String messageKey, Object[] parameters, Throwable e)
          Create a Message specified by given key and additionally parameters.
 Collection getSuppressableMessages()
          Returns a Collection of Message identifiers of messages that are allowed to be suppressed by the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK_CANCEL_ACTION_TEXTS

public static final String[] OK_CANCEL_ACTION_TEXTS
The default text pair for the OK/CANCEL action.


OK_ACTION_TEXTS

public static final String[] OK_ACTION_TEXTS
The default text for a pure confirmation action. The CANCEL text is omitted here since it doesn't provide any additional functionality.


YES_NO_ACTION_TEXTS

public static final String[] YES_NO_ACTION_TEXTS
An alternative text pair for the OK/CANCEL action, representing YES/NO.


YES_NO_CANCEL_ACTION_TEXTS

public static final String[] YES_NO_CANCEL_ACTION_TEXTS
An alternative text pair for the OK/NO/CANCEL action, representing YES/NO.

Constructor Detail

DefaultMessageFactory

public DefaultMessageFactory(String bundleName)
Constructor for MessageFactory.

Method Detail

createMessage

public Message createMessage(String messageKey)
Description copied from interface: MessageFactory
Create a Message specified by given key.

Specified by:
createMessage in interface MessageFactory
Returns:
Message

createMessage

public Message createMessage(String messageKey,
                             Object[] parameters,
                             Throwable e)
Description copied from interface: MessageFactory
Create a Message specified by given key and additionally parameters.

Specified by:
createMessage in interface MessageFactory
Parameters:
messageKey - identifier key
parameters - replacing the placeholders {0}, {1}... in the body text.
e - an Exception belonging to the message
Returns:
Message

containsKey

public boolean containsKey(String key)
Description copied from interface: MessageFactory
Returns whether given key has a value in one of the registered resources.

Specified by:
containsKey in interface MessageFactory
Parameters:
key - the key to look up in the resource bundle
Returns:
true if key has a valid value in one or more resources, false otherwise

getSuppressableMessages

public Collection getSuppressableMessages()
Returns a Collection of Message identifiers of messages that are allowed to be suppressed by the user. Those messages are marked as "isSuppressableMessage" in the properties file. Moreover, they have to be set to "isSuppressedMessage=NO" (as an alternative, "isSuppressedMessage" can be omitted).

Specified by:
getSuppressableMessages in interface MessageFactory


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.