From: tama3 Date: Thu, 3 Jul 2008 02:25:08 +0000 (+0000) Subject: remove. use i18n package X-Git-Url: http://git.osdn.net/view?p=stigmata%2Fstigmata.git;a=commitdiff_plain;h=54a59e63a8a011373c66225f4ebf923ad69adc51 remove. use i18n package git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/stigmata/trunk@284 acee48c3-7b26-0410-bdac-b3d0e5314bbc --- diff --git a/src/main/java/jp/naist/se/stigmata/ui/swing/Messages.java b/src/main/java/jp/naist/se/stigmata/ui/swing/Messages.java deleted file mode 100644 index 731f0ef..0000000 --- a/src/main/java/jp/naist/se/stigmata/ui/swing/Messages.java +++ /dev/null @@ -1,90 +0,0 @@ -package jp.naist.se.stigmata.ui.swing; - -/* - * $Id$ - */ - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * This class manages message for display. - * - * @author Haruaki TAMADA - * @version $Revision$ $Date$ - */ -public class Messages{ - private static final String BUNDLE_NAME = "resources.messages"; - private static final Messages instance = new Messages(); - private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages(){ - } - - public static String getString(String key){ - return instance.get(key); - } - - public static String getString(String key, Object... strings){ - String v = instance.get(key); - - return MessageFormat.format(v, strings); - } - - public static String[] getStringArray(String key){ - return instance.getArray(key); - } - - public static boolean hasString(String key){ - return instance.hasValue(key); - } - - private String get(String key){ - try{ - String value = bundle.getString(key); - int currentIndex = 0; - - // replace "hoge${fugakey}" to "hogefuga" - // when fugakey=fuga was defined. - while((value.indexOf('$', currentIndex) >= 0)){ - int index = value.indexOf('$', currentIndex); - if(value.charAt(index + 1) == '$'){ - currentIndex = index + 2; - } - else if(value.charAt(index + 1) == '{'){ - int last = value.indexOf('}', currentIndex + 1); - String subkey = value.substring(index + 2, last); - if(hasValue(subkey)){ - String subvalue = get(subkey); - StringBuilder builder = new StringBuilder(); - builder.append(value.substring(0, currentIndex)); - builder.append(subvalue); - builder.append(value.substring(last + 1)); - currentIndex += subvalue.length() + 1; - value = new String(builder); - } - } - } - - return value; - }catch(MissingResourceException e){ - e.printStackTrace(); - return "!" + key + "!"; - } - } - - private String[] getArray(String key){ - String value = get(key); - return value.split(", *"); - } - - private boolean hasValue(String key){ - try{ - bundle.getString(key); - return true; - }catch(MissingResourceException e){ - } - return false; - } -}