1 package osm.jp.gpx.matchtime.gui;
2 import java.lang.reflect.InvocationTargetException;
3 import java.text.SimpleDateFormat;
5 class Command extends Thread {
6 String[] args; // コマンドパラメータ
7 private String commandName = ""; // コマンド名
8 @SuppressWarnings({ "rawtypes" })
9 private Class cmd; // 実行対象インスタンス
12 * コンストラクタ:実行対象のインスタンスを得る
15 public Command(Class<?> cmd) {
18 this.commandName = cmd.getName();
19 this.args = new String[0];
26 public void setArgs(String[] args) {
30 public void setCommandName(String name) {
31 this.commandName = name;
33 public String getCommandName() {
34 return this.commandName;
37 @SuppressWarnings("unchecked")
39 System.out.println("[START:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName);
40 for (int i=0; i < args.length; i++) {
41 System.out.println(" args["+ i +"]: "+ this.args[i]);
47 java.lang.reflect.Method method = this.cmd.getMethod("main", new Class[] {String[].class});
48 method.setAccessible(true);
49 method.invoke(null, new Object[]{this.args});
52 System.out.println("[END:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName);
54 catch (InvocationTargetException e) {
55 System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName);
56 e.getCause().printStackTrace();
60 System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName);