From 2dc4d93ed94f97824dfbbb55e74d127caee83a3c Mon Sep 17 00:00:00 2001 From: hayashi Date: Mon, 31 Oct 2011 11:16:15 +0900 Subject: [PATCH] =?utf8?q?v224=20=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=81?= =?utf8?q?=E4=BF=A1=E5=85=88=E3=82=92=E3=83=97=E3=83=AD=E3=83=91=E3=83=86?= =?utf8?q?=E3=82=A3=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E4=BB=A5=E5=A4=96?= =?utf8?q?=E3=81=8B=E3=82=89=E3=82=82=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D?= =?utf8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?= =?utf8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.xml | 12 +-- src/hayashi/yuu/tools/mail/SiteData.java | 113 ++++++++++++++------------ src/jp/co/areaweb/tools/gui/ClipbordTest.java | 3 +- src/jp/co/areaweb/tools/gui/Command.java | 13 ++- 4 files changed, 75 insertions(+), 66 deletions(-) diff --git a/build.xml b/build.xml index 159de2e..afbfbf1 100644 --- a/build.xml +++ b/build.xml @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + - @@ -50,7 +50,7 @@ packagenames="*" encoding="UTF-8" charset="UTF-8" - sourcepath="${src}" + sourcepath="${src}" destdir="${doc}/api" > @@ -101,7 +101,7 @@ - + diff --git a/src/hayashi/yuu/tools/mail/SiteData.java b/src/hayashi/yuu/tools/mail/SiteData.java index c686428..aa667e1 100644 --- a/src/hayashi/yuu/tools/mail/SiteData.java +++ b/src/hayashi/yuu/tools/mail/SiteData.java @@ -15,32 +15,32 @@ public class SiteData { public String MAIL_TO = ""; public String MAIL_CC = ""; public String MAIL_BCC = ""; - + /** * 'POP before SMTP'認証を行うかどうか */ public boolean POP_before_SMTP = false; - + /** * 'USER_AUTH'認証を行うかどうか */ public boolean USER_AUTH = false; - + /** * 'STARTTLS'認証を行うかどうか */ public boolean STARTTLS = false; - + /** * POPサーバー名('POP before SMTP'認証時のみ) */ public String MAIL_POP = ""; - + /** * POPアカウント('POP before SMTP'認証時のみ) */ public String USER_ID = ""; - + /** * POPアカウントのパスワード('POP before SMTP'認証時のみ) */ @@ -55,54 +55,65 @@ public class SiteData { Properties properties = new Properties(); properties.setPasswordItem("MAIL_PASSWORD"); properties.load(new FileInputStream(propertyFile)); - - String str = ""; - if ((str = properties.getProperty("mail.smtp.host")) != null) { - MAIL_SMTP = str; - } - if ((str = properties.getProperty("mail.smtp.port")) != null) { - MAIL_SMTP_PORT = str; - } - if ((str = properties.getProperty("mail.smtp.from")) != null) { - MAIL_FROM = str; - } - if ((str = properties.getProperty("MAIL_TO")) != null) { - MAIL_TO = str; - } - if ((str = properties.getProperty("MAIL_CC")) != null) { - MAIL_CC = str; - } - if ((str = properties.getProperty("MAIL_BCC")) != null) { - MAIL_BCC = str; - } - - str = properties.getProperty("MAIL_POP_before_SMTP"); - if ((str != null) && str.equals("true")) { - POP_before_SMTP = true; - } - - str = properties.getProperty("mail.smtp.auth"); - if ((str != null) && str.equals("true")) { - USER_AUTH = true; - } - - str = properties.getProperty("mail.smtp.starttls.enable"); - if ((str != null) && str.equals("true")) { - STARTTLS = true; - } - - if ((str = properties.getProperty("MAIL_POP")) != null) { - MAIL_POP = str; - } - if ((str = properties.getProperty("mail.smtp.user")) != null) { - USER_ID = str; - } - if ((str = properties.getProperty("MAIL_PASSWORD")) != null) { - PASSWORD = str; - } + setup(properties); } catch(Exception e) { System.out.println(e); } } + + /** + * 指定されたプロパティファイルに定義された値でインスタンスを生成する。 + * @param properties 設定値を定義したプロパティファイル + */ + public SiteData(Properties properties) { + setup(properties); + } + + public void setup(java.util.Properties properties) { + String str = ""; + if ((str = properties.getProperty("mail.smtp.host")) != null) { + MAIL_SMTP = str; + } + if ((str = properties.getProperty("mail.smtp.port")) != null) { + MAIL_SMTP_PORT = str; + } + if ((str = properties.getProperty("mail.smtp.from")) != null) { + MAIL_FROM = str; + } + if ((str = properties.getProperty("MAIL_TO")) != null) { + MAIL_TO = str; + } + if ((str = properties.getProperty("MAIL_CC")) != null) { + MAIL_CC = str; + } + if ((str = properties.getProperty("MAIL_BCC")) != null) { + MAIL_BCC = str; + } + + str = properties.getProperty("MAIL_POP_before_SMTP"); + if ((str != null) && str.equals("true")) { + POP_before_SMTP = true; + } + + str = properties.getProperty("mail.smtp.auth"); + if ((str != null) && str.equals("true")) { + USER_AUTH = true; + } + + str = properties.getProperty("mail.smtp.starttls.enable"); + if ((str != null) && str.equals("true")) { + STARTTLS = true; + } + + if ((str = properties.getProperty("MAIL_POP")) != null) { + MAIL_POP = str; + } + if ((str = properties.getProperty("mail.smtp.user")) != null) { + USER_ID = str; + } + if ((str = properties.getProperty("MAIL_PASSWORD")) != null) { + PASSWORD = str; + } + } } diff --git a/src/jp/co/areaweb/tools/gui/ClipbordTest.java b/src/jp/co/areaweb/tools/gui/ClipbordTest.java index 1b6ed55..b84bbe9 100644 --- a/src/jp/co/areaweb/tools/gui/ClipbordTest.java +++ b/src/jp/co/areaweb/tools/gui/ClipbordTest.java @@ -9,7 +9,6 @@ import java.awt.datatransfer.Transferable; public class ClipbordTest extends Component implements ClipboardOwner { - @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { // TODO Auto-generated method stub @@ -27,7 +26,7 @@ public class ClipbordTest extends Component implements ClipboardOwner { } ClipbordTest.setClipboardString(str); } - + public static void setClipboardString(String str) { Toolkit kit = Toolkit.getDefaultToolkit(); Clipboard clip = kit.getSystemClipboard(); diff --git a/src/jp/co/areaweb/tools/gui/Command.java b/src/jp/co/areaweb/tools/gui/Command.java index b0aac0a..10d09ba 100644 --- a/src/jp/co/areaweb/tools/gui/Command.java +++ b/src/jp/co/areaweb/tools/gui/Command.java @@ -4,21 +4,20 @@ import java.text.SimpleDateFormat; class Command extends Thread { String[] args; // コマンドパラメータ private String commandName = ""; // コマンド名 - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes" }) private Class cmd; // 実行対象インスタンス - + /** * コンストラクタ:実行対象のインスタンスを得る * @param cmd */ - @SuppressWarnings("unchecked") - public Command(Class cmd) { + public Command(Class cmd) { super(); this.cmd = cmd; this.commandName = cmd.getName(); this.args = new String[0]; } - + /** * コマンドパラメータの設定 * @param folder @@ -26,7 +25,7 @@ class Command extends Thread { public void setArgs(String[] args) { this.args = args; } - + public void setCommandName(String name) { this.commandName = name; } @@ -47,7 +46,7 @@ class Command extends Thread { java.lang.reflect.Method method = this.cmd.getMethod("main", new Class[] {String[].class}); method.setAccessible(true); method.invoke(null, new Object[]{this.args}); - + System.out.println(); System.out.println("[END:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); } -- 2.11.0