OSDN Git Service

メッセージを国際化対応しました。
authoruguu <uguu@bdfc86a3-8c30-0410-b963-dc9a622ac1c7>
Wed, 30 May 2007 20:17:54 +0000 (20:17 +0000)
committeruguu <uguu@bdfc86a3-8c30-0410-b963-dc9a622ac1c7>
Wed, 30 May 2007 20:17:54 +0000 (20:17 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/deployer@15 bdfc86a3-8c30-0410-b963-dc9a622ac1c7

13 files changed:
deployer/trunk/src/main/java/jp/sourceforge/deployer/ClassLoaderUnloadFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/ClassLoaderUnloadedException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/Deployer.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/DirectoryCreateFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/DirectoryDeleteFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/FileCreateFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/FileDeleteFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/FileMonitor.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/FileMonitorFailException.java
deployer/trunk/src/main/java/jp/sourceforge/deployer/Message.java [new file with mode: 0644]
deployer/trunk/src/main/resources/jp_sourceforge_deployer_message.properties [new file with mode: 0644]
deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_en.properties [new file with mode: 0644]
deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_ja.properties [new file with mode: 0644]

index 6ec89f3..f10de18 100644 (file)
@@ -47,7 +47,7 @@ public class ClassLoaderUnloadFailException extends RuntimeException {
      * </p>\r
      */\r
     public ClassLoaderUnloadFailException() {\r
-        super("クラスローダーの破棄に失敗しました。");\r
+        super(Message.classLoaderUnloadFail());\r
     }\r
 \r
 }\r
index d3b9a21..6dabf03 100644 (file)
@@ -47,7 +47,7 @@ public class ClassLoaderUnloadedException extends RuntimeException {
      * </p>\r
      */\r
     public ClassLoaderUnloadedException() {\r
-        super("クラスローダーは既に破棄されています。");\r
+        super(Message.classLoaderUnloaded());\r
     }\r
 \r
 }\r
index 03e768a..5ff57a7 100644 (file)
@@ -110,19 +110,19 @@ public final class Deployer {
      */\r
     public Deployer(File deployDirectory, Pattern filePattern, File workDirectory) {\r
         if (deployDirectory == null) {\r
-            throw new IllegalArgumentException("deployDirectory is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("deployDirectory"));\r
         }\r
         if (!deployDirectory.isDirectory()) {\r
-            throw new IllegalArgumentException("deployDirectory is not directory.");\r
+            throw new IllegalArgumentException(Message.argumentIsNotDirectory("deployDirectory"));\r
         }\r
         if (filePattern == null) {\r
-            throw new IllegalArgumentException("filePattern is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("filePattern"));\r
         }\r
         if (workDirectory == null) {\r
-            throw new IllegalArgumentException("workDirectory is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("workDirectory"));\r
         }\r
         if (!workDirectory.isDirectory()) {\r
-            throw new IllegalArgumentException("workDirectory is not directory.");\r
+            throw new IllegalArgumentException(Message.argumentIsNotDirectory("workDirectory"));\r
         }\r
 \r
         this._deployDirectory = deployDirectory;\r
@@ -148,7 +148,7 @@ public final class Deployer {
      */\r
     public void addListener(DeployerListener listener) {\r
         if (listener == null) {\r
-            throw new IllegalArgumentException("listener is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("listener"));\r
         }\r
         synchronized (this._listenerList) {\r
             this._listenerList.add(listener);\r
@@ -367,7 +367,7 @@ public final class Deployer {
         }\r
         File parentDir = dir.getParentFile();\r
         if (!dir.delete()) {\r
-            throw new IOException("ディレクトリ\"" + dir.getAbsolutePath() + "\"の削除に失敗しました。");\r
+            throw new IOException(Message.directoryDeleteFail(dir.getAbsolutePath()));\r
         }\r
         this.deleteWithParent(parentDir);\r
     }\r
index e9ccbf2..5e5145c 100644 (file)
@@ -53,7 +53,7 @@ public class DirectoryCreateFailException extends IOException {
      *            作成に失敗したディレクトリ。\r
      */\r
     public DirectoryCreateFailException(File dir) {\r
-        super("ディレクトリ\"" + dir.getAbsolutePath() + "\"の作成に失敗しました。");\r
+        super(Message.directoryCreateFail(dir.getAbsolutePath()));\r
     }\r
 \r
 }\r
index 9aec705..d2cc857 100644 (file)
@@ -53,7 +53,7 @@ public class DirectoryDeleteFailException extends IOException {
      *            削除に失敗したディレクトリ。\r
      */\r
     public DirectoryDeleteFailException(File dir) {\r
-        super("ディレクトリ\"" + dir.getAbsolutePath() + "\"の削除に失敗しました。");\r
+        super(Message.directoryDeleteFail(dir.getAbsolutePath()));\r
     }\r
 \r
 }\r
index 61bdd28..132ced0 100644 (file)
@@ -53,7 +53,7 @@ public class FileCreateFailException extends IOException {
      *            作成に失敗したファイル。\r
      */\r
     public FileCreateFailException(File file) {\r
-        super("ファイル\"" + file.getAbsolutePath() + "\"の作成に失敗しました。");\r
+        super(Message.fileCreateFail(file.getAbsolutePath()));\r
     }\r
 \r
 }\r
index fb9791d..b90653f 100644 (file)
@@ -53,7 +53,7 @@ public class FileDeleteFailException extends IOException {
      *            削除に失敗したファイル。\r
      */\r
     public FileDeleteFailException(File file) {\r
-        super("ファイル\"" + file.getAbsolutePath() + "\"の削除に失敗しました。");\r
+        super(Message.fileDeleteFail(file.getAbsolutePath()));\r
     }\r
 \r
 }\r
index 59ca9c2..3706f11 100644 (file)
@@ -127,13 +127,13 @@ public final class FileMonitor {
      */\r
     public FileMonitor(File baseDirectory, Pattern filePattern) {\r
         if (baseDirectory == null) {\r
-            throw new IllegalArgumentException("baseDirectory is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("baseDirectory"));\r
         }\r
         if (!baseDirectory.isDirectory()) {\r
-            throw new IllegalArgumentException("baseDirectory is not directory.");\r
+            throw new IllegalArgumentException(Message.argumentIsNotDirectory("baseDirectory"));\r
         }\r
         if (filePattern == null) {\r
-            throw new IllegalArgumentException("filePattern is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("filePattern"));\r
         }\r
         this._baseDirectory = baseDirectory;\r
         this._filePattern = filePattern;\r
@@ -272,7 +272,7 @@ public final class FileMonitor {
      */\r
     public void addListener(FileMonitorListener listener) {\r
         if (listener == null) {\r
-            throw new IllegalArgumentException("listener is null.");\r
+            throw new IllegalArgumentException(Message.argumentIsNull("listener"));\r
         }\r
         synchronized (this._listenerList) {\r
             this._listenerList.add(listener);\r
index d269f10..ccd24c6 100644 (file)
@@ -50,7 +50,7 @@ public class FileMonitorFailException extends Exception {
      *            例外の原因。\r
      */\r
     public FileMonitorFailException(Exception e) {\r
-        super("ファイルの監視に失敗しました。", e);\r
+        super(Message.fileMonitorFail(), e);\r
     }\r
 \r
 }\r
diff --git a/deployer/trunk/src/main/java/jp/sourceforge/deployer/Message.java b/deployer/trunk/src/main/java/jp/sourceforge/deployer/Message.java
new file mode 100644 (file)
index 0000000..b81d6dd
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * Copyright (C) 2007 uguu at users.sourceforge.jp, All Rights Reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ *    1. Redistributions of source code must retain the above copyright\r
+ *       notice, this list of conditions and the following disclaimer.\r
+ *\r
+ *    2. Redistributions in binary form must reproduce the above copyright\r
+ *       notice, this list of conditions and the following disclaimer in the\r
+ *       documentation and/or other materials provided with the distribution.\r
+ *\r
+ *    3. Neither the name of Clarkware Consulting, Inc. nor the names of its\r
+ *       contributors may be used to endorse or promote products derived\r
+ *       from this software without prior written permission. For written\r
+ *       permission, please contact clarkware@clarkware.com.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL\r
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN  ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+package jp.sourceforge.deployer;\r
+\r
+import java.text.MessageFormat;\r
+import java.util.ResourceBundle;\r
+\r
+/**\r
+ * <p>\r
+ * "jp.sourceforge.deployer.message"リソース・ファイルからメッセージを取得します。\r
+ * </p>\r
+ * \r
+ * @author $Author$\r
+ * @version $Rev$\r
+ */\r
+final class Message {\r
+\r
+    /**\r
+     * <p>\r
+     * インスタンス化を禁止します。\r
+     * </p>\r
+     */\r
+    private Message() {\r
+        throw new UnsupportedOperationException();\r
+    }\r
+\r
+    /**\r
+     * <p>\r
+     * リソース・ファイルからメッセージを取得します。\r
+     * </p>\r
+     * \r
+     * @param messageID\r
+     *            メッセージのID(リソースのキー)。\r
+     * @param arguments\r
+     *            メッセージに埋め込む引数。\r
+     * @return メッセージ。\r
+     */\r
+    private static String format(String messageID, String... arguments) {\r
+        ResourceBundle rb = ResourceBundle.getBundle("jp_sourceforge_deployer_message");\r
+        String message = rb.getString(messageID);\r
+        message = MessageFormat.format(message, (Object[]) arguments);\r
+        return message;\r
+    }\r
+\r
+    static String classLoaderUnloaded() {\r
+        return Message.format("classLoaderUnloaded");\r
+    }\r
+\r
+    static String classLoaderUnloadFail() {\r
+        return Message.format("classLoaderUnloadFail");\r
+    }\r
+\r
+    static String directoryCreateFail(String dir) {\r
+        return Message.format("directoryCreateFail", dir);\r
+    }\r
+\r
+    static String directoryDeleteFail(String dir) {\r
+        return Message.format("directoryDeleteFail", dir);\r
+    }\r
+\r
+    static String fileCreateFail(String file) {\r
+        return Message.format("fileCreateFail", file);\r
+    }\r
+\r
+    static String fileDeleteFail(String file) {\r
+        return Message.format("fileDeleteFail", file);\r
+    }\r
+\r
+    static String fileMonitorFail() {\r
+        return Message.format("fileMonitorFail");\r
+    }\r
+\r
+    static String argumentIsNull(String arg) {\r
+        return Message.format("argumentIsNull", arg);\r
+    }\r
+\r
+    static String argumentIsNotDirectory(String arg) {\r
+        return Message.format("argumentIsNotDirectory", arg);\r
+    }\r
+\r
+}\r
diff --git a/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message.properties b/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message.properties
new file mode 100644 (file)
index 0000000..5175b61
--- /dev/null
@@ -0,0 +1,9 @@
+classLoaderUnloaded=\u30af\u30e9\u30b9\u30ed\u30fc\u30c0\u30fc\u306f\u65e2\u306b\u7834\u68c4\u3055\u308c\u3066\u3044\u307e\u3059\u3002\r
+classLoaderUnloadFail=\u30af\u30e9\u30b9\u30ed\u30fc\u30c0\u30fc\u306e\u7834\u68c4\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+directoryCreateFail=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea"{0}"\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+directoryDeleteFail=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea"{0}"\u306e\u524a\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileCreateFail=\u30d5\u30a1\u30a4\u30eb"{0}"\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileDeleteFail=\u30d5\u30a1\u30a4\u30eb"{0}"\u306e\u524a\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileMonitorFail=\u30d5\u30a1\u30a4\u30eb\u306e\u76e3\u8996\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+argumentIsNull="{0}"\u304cnull\u3067\u3059\u3002\r
+argumentIsNotDirectory="{0}"\u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\r
diff --git a/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_en.properties b/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_en.properties
new file mode 100644 (file)
index 0000000..f0aec2d
--- /dev/null
@@ -0,0 +1,9 @@
+classLoaderUnloaded=The class loader has already been unloaded.\r
+classLoaderUnloadFail=It failed in unloading the class loader.\r
+directoryCreateFail=It failed in making directory "{0}".\r
+directoryDeleteFail=It failed in the deletion of the directory "{0}".\r
+fileCreateFail=It failed in making the file "{0}".\r
+fileDeleteFail=It failed in the deletion of the file "{0}".\r
+fileMonitorFail=It failed in the watch of the file.\r
+argumentIsNull="{0}" is null.\r
+argumentIsNotDirectory="{0}" is not directory.\r
diff --git a/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_ja.properties b/deployer/trunk/src/main/resources/jp_sourceforge_deployer_message_ja.properties
new file mode 100644 (file)
index 0000000..5175b61
--- /dev/null
@@ -0,0 +1,9 @@
+classLoaderUnloaded=\u30af\u30e9\u30b9\u30ed\u30fc\u30c0\u30fc\u306f\u65e2\u306b\u7834\u68c4\u3055\u308c\u3066\u3044\u307e\u3059\u3002\r
+classLoaderUnloadFail=\u30af\u30e9\u30b9\u30ed\u30fc\u30c0\u30fc\u306e\u7834\u68c4\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+directoryCreateFail=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea"{0}"\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+directoryDeleteFail=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea"{0}"\u306e\u524a\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileCreateFail=\u30d5\u30a1\u30a4\u30eb"{0}"\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileDeleteFail=\u30d5\u30a1\u30a4\u30eb"{0}"\u306e\u524a\u9664\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+fileMonitorFail=\u30d5\u30a1\u30a4\u30eb\u306e\u76e3\u8996\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\r
+argumentIsNull="{0}"\u304cnull\u3067\u3059\u3002\r
+argumentIsNotDirectory="{0}"\u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\r