1 using com.andoutomo.kybernetes.view;
\r
2 using com.andoutomo.kybernetes.control;
\r
4 namespace com.andoutomo.kybernetes.command
\r
6 public abstract class AbCommand
\r
8 protected abstract bool execute();
\r
11 protected abstract string turnMessage();
\r
12 protected abstract string turnErrorMessage();
\r
13 protected abstract string turnSplitErrorMessage();
\r
15 protected BaseForm form;
\r
16 protected CommandArg argument;
\r
21 /// 各継承先クラスで指定された、splitArguments及び
\r
24 /// <param name="_args">呼び出す前に指定された引数(コマンドラインからなので、それを受け取る)</param>
\r
25 /// <param name="_form">フォーム情報。ここからフォームを操作できるようにします。</param>
\r
26 /// <returns></returns>
\r
27 public bool run(CommandArg _args, BaseForm _form)
\r
29 KybernetesLogger.Log.debug("run start on " + this.GetType().ToString());
\r
30 if (_args.getSplitResult() == false)
\r
32 KybernetesLogger.Log.debug("split failed at " + _args.GetType().ToString());
\r
33 message = turnSplitErrorMessage();
\r
37 this.argument = _args;
\r
42 message = turnMessage();
\r
43 KybernetesLogger.Log.debug("run success on " + this.GetType().ToString());
\r
44 KybernetesLogger.Log.debug("message:" + message);
\r
48 chainCommand.run(chainCommandArg, _form);
\r
55 message = turnErrorMessage();
\r
56 KybernetesLogger.Log.debug("run failure on " + this.GetType().ToString());
\r
57 KybernetesLogger.Log.debug("message:" + message);
\r
63 private string message;
\r
67 /// 処理完了後のメッセージを呼び出し元に返す。
\r
69 /// <returns>メッセージ</returns>
\r
70 public string getMessage()
\r
75 protected ErrorType errorType
\r
81 protected string DefaultErrorMessage
\r
85 string errorMessage;
\r
87 case ErrorType.DataNotFound:
\r
88 errorMessage = "対象データが見つかりません。";
\r
90 case ErrorType.Unexpected:
\r
92 errorMessage = "予期せぬエラーが発生いたしました。";
\r
96 return errorMessage;
\r
100 protected string DefaultSplitErrorMessage
\r
102 get { return "無効なパラメータです。"; }
\r
104 protected string DefaultNormalMessage
\r
106 get { return "> ";}
\r
108 private CommandArg chainCommandArg;
\r
109 private AbCommand chainCommand;
\r
110 private bool chain;
\r
111 //このコマンド実行後に実施する追加コマンドを設定します。
\r
112 protected void setChainCommand(CommandArg arg, AbCommand cmd)
\r
114 if (arg != null && cmd != null)
\r
116 this.chainCommandArg = arg;
\r
117 this.chainCommand = cmd;
\r
127 public enum ErrorType
\r