net.argius.stu
クラス Command

java.lang.Object
  拡張net.argius.stu.Command
すべての実装インタフェース:
EventListener, PropertyChangeListener
直系の既知のサブクラス:
Bind, Count, Delete, Export, Find, Insert, Load, Report, Select, Time, Update

public class Command
extends Object
implements PropertyChangeListener

コマンドの基底クラスです。 stu.commandパッケージに含まれるコマンドのサブクラスは、 入力されたコマンドに対応する名称のクラスが実行時にロードされ、実行されます。 (例:Testコマンド = stu.command.Testクラス) これは、実行時に参照可能なクラスであれば、自由に追加ができることを意味します。 クラス名は、先頭が大文字でその他が小文字になるようにします。 入力されたコマンドは、大文字小文字は無視されます。


コンストラクタの概要
protected Command()
          コマンドを生成します。
protected Command(Application app)
          コマンドを生成します。
 
メソッドの概要
protected  void execute(Connection conn, String parameter)
          コマンドを実行します。
protected  Command getCommand(String name)
          コマンドオブジェクトを取得します。
protected  int getLogLevel()
          ログレベルを取得します。
protected  String getMessage(String key)
          メッセージを取得します。
protected  String getMessage(String key, Object args)
          パラメータ埋め込み済みメッセージを取得します。
protected  String getMessage(String key, Object[] args)
          パラメータ埋め込み済みメッセージを取得します。
protected  String getProperty(String key)
          プロパティを取得します。
protected  int getTimeoutSeconds()
          SQL実行待ち時間の設定を取得します。
protected  void initialize(Application app)
          コマンドを初期化します。
 boolean invoke(Connection conn, String parameter)
          コマンドを起動します。
protected  boolean isSelect(String query)
          SQL文がSELECT文かどうか調べます。
protected  void print(String message)
          メッセージを出力します。
protected  void print(String message, int indent)
          メッセージをインデント付きで出力します。
protected  void println(String message)
          メッセージを改行付きで出力します。
 void propertyChange(PropertyChangeEvent evt)
          プロパティが変更されたときの処理を実行します。
protected  File resolvePath(String path)
          指定したパスと作業ディレクトリを結合したFileを生成します。
protected  void setTimeout(Statement stmt)
          SQL実行待ち時間を設定します。
protected  int showResult(ResultSet rs)
          結果を表示します。
protected  StringQueue split(String parameter, int count)
          パラメータを分割します。
protected  void warning(String message)
          警告を表示します。
protected  void writeLog(int level, String message)
          ログを出力します。
protected  void writeLog(int level, String message, Throwable th)
          ログを出力します。
protected  void writeLog(int level, Throwable th)
          ログを出力します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Command

protected Command()
コマンドを生成します。


Command

protected Command(Application app)
コマンドを生成します。

メソッドの詳細

initialize

protected void initialize(Application app)
コマンドを初期化します。


invoke

public final boolean invoke(Connection conn,
                            String parameter)
コマンドを起動します。

パラメータ:
conn - コネクション
parameter - 入力文字列
戻り値:
コマンドが正常終了した場合はtrue、異常終了した場合はfalse

execute

protected void execute(Connection conn,
                       String parameter)
                throws IllegalArgumentException,
                       IOException,
                       SQLException
コマンドを実行します。

パラメータ:
conn - コネクション
parameter - 入力文字列
例外:
IllegalArgumentException - パラメータエラー
IOException - 入出力エラー
SQLException - SQLエラー

getCommand

protected Command getCommand(String name)
コマンドオブジェクトを取得します。 各コマンドオブジェクトは最初の呼び出しの時のみ生成され、 二度目以降は最初のオブジェクトが再利用されます。

パラメータ:
name - コマンド名
戻り値:
コマンドオブジェクト

getMessage

protected final String getMessage(String key)
メッセージを取得します。

パラメータ:
key - メッセージキー
戻り値:
メッセージ

getMessage

protected final String getMessage(String key,
                                  Object args)
パラメータ埋め込み済みメッセージを取得します。

パラメータ:
key - メッセージキー
args - 埋め込むパラメータ
戻り値:
メッセージ

getMessage

protected final String getMessage(String key,
                                  Object[] args)
パラメータ埋め込み済みメッセージを取得します。

パラメータ:
key - メッセージキー
args - 埋め込むパラメータの配列
戻り値:
メッセージ

split

protected final StringQueue split(String parameter,
                                  int count)
パラメータを分割します。 分割されたパラメータは、文字列キューとして返されます。

パラメータ:
parameter - パラメータ
count - 分割回数 ゼロ以下の場合は無制限
戻り値:
文字列キュー

showResult

protected final int showResult(ResultSet rs)
結果を表示します。

パラメータ:
rs - 結果セット
戻り値:
結果件数

getTimeoutSeconds

protected final int getTimeoutSeconds()
SQL実行待ち時間の設定を取得します。

戻り値:
SQL実行待ち時間の秒数

setTimeout

protected final void setTimeout(Statement stmt)
SQL実行待ち時間を設定します。 設定値が0以下の場合は何もしません。 設定エラーの場合もそのまま終了します。

パラメータ:
stmt - ステートメント

isSelect

protected final boolean isSelect(String query)
SQL文がSELECT文かどうか調べます。

パラメータ:
query - SQL文
戻り値:
SELECT文ならtrue、そうでなければfalse

resolvePath

protected final File resolvePath(String path)
指定したパスと作業ディレクトリを結合したFileを生成します。 指定パスが絶対パスの場合は絶対パスのまま返されます。 指定パスがnullの場合の動作は保証されません。

パラメータ:
path - パス文字列
戻り値:
結合したパスのFile

print

protected final void print(String message)
メッセージを出力します。

パラメータ:
message - メッセージ

print

protected final void print(String message,
                           int indent)
メッセージをインデント付きで出力します。

パラメータ:
message - メッセージ
indent - インデント数

println

protected final void println(String message)
メッセージを改行付きで出力します。

パラメータ:
message - メッセージ

warning

protected final void warning(String message)
警告を表示します。

パラメータ:
message - メッセージ

propertyChange

public void propertyChange(PropertyChangeEvent evt)
プロパティが変更されたときの処理を実行します。

定義:
インタフェース PropertyChangeListener 内の propertyChange
パラメータ:
evt - プロパティ変更イベント

writeLog

protected void writeLog(int level,
                        String message)
ログを出力します。

パラメータ:
level - ログレベル
message - ログメッセージ

writeLog

protected void writeLog(int level,
                        Throwable th)
ログを出力します。

パラメータ:
level - ログレベル
th - 例外またはエラー

writeLog

protected void writeLog(int level,
                        String message,
                        Throwable th)
ログを出力します。

パラメータ:
level - ログレベル
message - ログメッセージ
th - 例外またはエラー

getProperty

protected String getProperty(String key)
プロパティを取得します。

パラメータ:
key - プロパティキー
戻り値:
プロパティ

getLogLevel

protected int getLogLevel()
ログレベルを取得します。

戻り値:
ログレベル