2 * Copyright (c) 2009 The openGion Project.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
16 package org.opengion.fukurou.process;
18 import org.opengion.fukurou.util.Argument;
19 import org.opengion.fukurou.system.HybsConst; // 6.1.0.0 (2014/12/26) refactoring
24 * AbstractProcess は、ChainProcess インターフェースを実装した、Abstract クラスです。
25 * ChainProcess を用いて、順次、バッチプロセスを実行することができます。
28 * @author Kazuhiko Hasegawa
31 public abstract class AbstractProcess implements HybsProcess {
33 /** システムの改行コードを設定します。*/
34 protected static final String CR = HybsConst.CR; // 6.1.0.0 (2014/12/26) refactoring
35 /** StringBilderなどの初期値を設定します。 {@value} */
36 protected static final int BUFFER_MIDDLE = HybsConst.BUFFER_MIDDLE; // 6.1.0.0 (2014/12/26) refactoring
37 /** StringBilderなどの初期値を設定します。 {@value} */
38 protected static final int BUFFER_LARGE = HybsConst.BUFFER_LARGE; // 6.1.0.0 (2014/12/26) refactoring
40 /** データ検索時のフェッチサイズを設定します。 {@value} */
41 protected static final int DB_BATCH_SIZE = HybsConst.DB_BATCH_SIZE; // 6.9.4.1 (2018/04/09)
44 public static final char TAB = '\t'; // 6.0.2.5 (2014/10/31) タブ区切り文字を char 化します。
46 private final Argument argments ;
47 private LoggerProcess logger ;
52 * @param name このクラス(サブクラス)のクラス名称
53 * @param MUST_PROPARTY 必須チェックMap
54 * @param USABLE_PROPARTY 整合性チェックMap
56 public AbstractProcess( final String name , final Map<String,String> MUST_PROPARTY ,final Map<String,String> USABLE_PROPARTY ) {
57 argments = new Argument( name ) ;
58 argments.setMustProparty( MUST_PROPARTY );
59 argments.setUsableProparty( USABLE_PROPARTY );
63 * 引数形式を解析する 引数オブジェクトに、引数を設定します。
64 * Argument の文字列から、引数かプロパティをセットします。
65 * [プロパティ]のキー部の大文字・小文字は、厳格に判定しています。
66 * Argument の文字列には、タイプがあります。
68 * [コメント] : # で始まる引数で、使用されません。(登録もされません。)
69 * [引数] : #,-,= 以外で始まる通常の文字列。登録の順番が指定されます。
70 * [プロパティ]: - で始まり、キーと値を=で区切っているパラメータです。順序は無関係。
74 @Override // HybsProcess
75 public void putArgument( final String arg ) {
76 argments.putArgument( arg ) ;
80 * Argument の文字列から、プロパティをセットします。
81 * [プロパティ]のキー部の大文字・小文字は、厳格に判定しています。
82 * このメソッドは、引数 や コメントの判断を行いません。プロパティ のみ
84 * プロパティの key=val が初めから分割されている場合の簡易メソッドです。
89 @Override // HybsProcess
90 public void putArgument( final String key,final String val ) {
91 argments.putArgument( key,val ) ;
95 * 引数形式を解析する 引数オブジェクトを返します。
99 public Argument getArgument() {
104 * ディスプレイにメッセージを表示します。
106 * @param msg 表示するメッセージ
108 @Override // HybsProcess
109 public void println( final String msg ) {
110 if( logger != null ) {
111 logger.println( msg ) ;
116 * ディスプレイにメッセージを表示します。
118 * @param msg 表示するメッセージ
120 @Override // HybsProcess
121 public void logging( final String msg ) {
122 if( logger != null ) {
123 logger.logging( msg ) ;
128 * ディスプレイ出力する LoggerProcess オブジェクトをセットします。
130 * @param logger LoggerProcessオブジェクト
132 @Override // HybsProcess
133 public final void setLoggerProcess( final LoggerProcess logger ) {
134 this.logger = logger ;
138 * エラー発生時に、RuntimeException を throw するか、ログ出力します。
139 * 引数に、エラーメッセージを指定します。
140 * isAbend引数は、RuntimeException を throw するか、ログ出力するかを指定する
141 * 引数です。true で、RuntimeException を throw し、false で、ログ出力
142 * のみとします。(つまり、継続処理されます。)
144 * @og.rev 6.3.1.1 (2015/07/10) RuntimeException を throwする機能を追加
146 * @param errMsg エラーメッセージ
147 * @param isAbend 異常発生時に、処理を中断(true)するか、継続(false)するか
149 public void throwException( final String errMsg , final boolean isAbend ) {
150 throwException( errMsg,null,isAbend );
154 * エラー発生時に、RuntimeException を throw するか、ログ出力します。
155 * 引数に、エラーメッセージと、発生元 Throwable を指定します。
156 * 発生元 Throwable が null の場合は、エラーメッセージのみで throw します。
157 * isAbend引数は、RuntimeException を throw するか、ログ出力するかを指定する
158 * 引数です。true で、RuntimeException を throw し、false で、ログ出力
159 * のみとします。(つまり、継続処理されます。)
161 * @og.rev 6.3.1.1 (2015/07/10) RuntimeException を throwする機能を追加
163 * @param errMsg エラーメッセージ
164 * @param th 発生元 Throwable
165 * @param isAbend 異常発生時に、処理を中断(true)するか、継続(false)するか
167 public void throwException( final String errMsg,final Throwable th,final boolean isAbend ) {
169 throw th == null ? new RuntimeException( errMsg ) : new RuntimeException( errMsg,th );
172 logging( "=================================================================" );
173 if( errMsg != null ) { logging( errMsg ); }
174 if( th != null ) { logging( th.getMessage() ); }
180 * Argument#toString() を呼び出しています。
185 public String toString() {
186 return argments.toString();