Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/util/text
In directory sc8-pr-cvs1:/tmp/cvs-serv2507/src/java/core/org/krysalis/ruper/util/text
Modified Files:
Messages.java MessageConstants.java
Added Files:
rupermsg_en_US.properties
Log Message:
Message format - loading a resource bundle as per the default locale
- need to add all the message constants
--- NEW FILE: rupermsg_en_US.properties ---
RUPER_MSG_UNABLE_TO_LOAD_CONFIG_FILE=Unable to load the config file {0}
Index: Messages.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/util/text/Messages.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Messages.java 8 Sep 2003 23:21:40 -0000 1.3
--- Messages.java 22 Sep 2003 19:18:31 -0000 1.4
***************
*** 5,10 ****
import java.text.MessageFormat;
! import java.util.HashMap;
! import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
--- 5,9 ----
import java.text.MessageFormat;
! import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
***************
*** 16,22 ****
*/
public class Messages {
! /** Map from message code to MessageFormat object for the message. */
! private static Map l_messages = new HashMap();
! private static ResourceBundle l_resources;
private Messages() {
--- 15,25 ----
*/
public class Messages {
! //Name of the resource Bundle
! private static final String BUNDLE_NAME =
! "org.krysalis.ruper.util.text.rupermsg";
!
! //Intialized the ResourceBundle.
! private static final ResourceBundle RESOURCE_BUNDLE =
! ResourceBundle.getBundle(BUNDLE_NAME,Locale.getDefault());
private Messages() {
***************
*** 85,115 ****
* Locates a message by its code.
*/
! private static synchronized MessageFormat findMessage(final String code)
throws MissingResourceException {
- // Check if the message is cached
- MessageFormat msg = (MessageFormat) l_messages.get(code);
- if (msg != null)
- return msg;
! // Locate the message resources
! if (l_resources == null) {
! try {
! l_resources =
! ResourceBundle.getBundle("org.krysalis.ruper.Resources");
! }
! catch (Exception e) {
! l_resources = null;
! }
! }
! // Locate the message format
! if (null != l_resources) {
! final String msgText = l_resources.getString(code);
msg = new MessageFormat(msgText);
- l_messages.put(code, msg);
- return msg;
}
!
! return null;
}
}
--- 88,103 ----
* Locates a message by its code.
*/
! private static MessageFormat findMessage(final String code)
throws MissingResourceException {
! MessageFormat msg = null;
! // Locate the message resources
! String msgText = RESOURCE_BUNDLE.getString(code);
! // get the message format
! if (msgText != null) {
msg = new MessageFormat(msgText);
}
! return msg;
}
}
Index: MessageConstants.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/util/text/MessageConstants.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MessageConstants.java 12 Sep 2003 20:23:44 -0000 1.7
--- MessageConstants.java 22 Sep 2003 19:18:31 -0000 1.8
***************
*** 20,23 ****
--- 20,24 ----
public static final String WRONG_TYPE = "WRONG_TYPE";
public static final String CONFIG_ERROR = "CONFIG_ERROR";
+ public static final String UNABLE_TO_LOAD_CONFIG_FILE = "RUPER_MSG_UNABLE_TO_LOAD_CONFIG_FILE";
public static final String NO_SUCH_REFERENCE = "NO_SUCH_REFERENCE";
public static final String CREATE_OBJECT_ERROR = "CREATE_OBJECT_ERROR";
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.