001/* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016package org.opengion.fukurou.process; 017 018import org.opengion.fukurou.system.OgRuntimeException ; // 6.4.2.0 (2016/01/29) 019import org.opengion.fukurou.system.OgCharacterException ; // 6.5.0.1 (2016/10/21) 020import org.opengion.fukurou.system.Closer ; 021import org.opengion.fukurou.system.LogWriter; 022import org.opengion.fukurou.util.Argument; 023import org.opengion.fukurou.util.StringUtil; 024import org.opengion.fukurou.util.FileUtil; 025 026import java.util.Map ; 027import java.util.concurrent.ConcurrentMap; // 6.4.3.4 (2016/03/11) 028import java.util.concurrent.ConcurrentHashMap; // 6.4.3.1 (2016/02/12) refactoring 029import java.util.LinkedHashMap ; 030import java.nio.charset.CharacterCodingException; // 6.3.1.0 (2015/06/28) 031 032import java.io.File; 033import java.io.BufferedReader; 034import java.io.IOException; 035 036/** 037 * Process_TableDiffは、ファイルから読み取った内容を、LineModel に設定後、 038 * 下流に渡す、FirstProcess インターフェースの実装クラスです。 039 * 040 * DBTableModel 形式のファイルを読み取って、各行を LineModel にセットして、 041 * 下流(プロセスチェインのデータは上流から下流に渡されます。)に渡します。 042 * 043 * 引数文字列中にスペースを含む場合は、ダブルコーテーション("") で括って下さい。 044 * 引数文字列の 『=』の前後には、スペースは挟めません。必ず、-key=value の様に 045 * 繋げてください。 046 * 047 * @og.formSample 048 * Process_TableDiff -infile1=INFILE -infile2=INFILE2 -action=DIFF1 -encode=UTF-8 -columns=AA,BB,CC 049 * 050 * -infile1=入力ファイル名1 :入力ファイル名1 051 * -infile2=入力ファイル名2 :入力ファイル名2 052 * -action=比較結果の方法 :ONLY,DIFF,INTERSEC 053 * [-sep1=セパレータ文字 ] :区切り文字1(初期値:タブ) 054 * [-sep2=セパレータ文字 ] :区切り文字2(初期値:タブ) 055 * [-encode1=文字エンコード ] :入力ファイルのエンコードタイプ1 056 * [-encode2=文字エンコード ] :入力ファイルのエンコードタイプ2 057 * [-columns=読み取りカラム名 ] :入力カラム名(CSV形式) 058 * [-keyClms=比較するカラム名 ] :比較する列の基準カラム名(CSV形式) 059 * [-diffClms=比較するカラム名] :比較するカラム名(CSV形式) 060 * [-display=[false/true] ] :結果を標準出力に表示する(true)かしない(false)か(初期値:false[表示しない]) 061 * [-debug=[false/true] ] :デバッグ情報を標準出力に表示する(true)かしない(false)か(初期値:false[表示しない]) 062 * 063 * @og.rev 4.2.3.0 (2008/05/26) 新規作成 064 * 065 * @version 4.0 066 * @author Kazuhiko Hasegawa 067 * @since JDK5.0, 068 */ 069public class Process_TableDiff extends AbstractProcess implements FirstProcess { 070 private static final String ENCODE = System.getProperty("file.encoding"); 071 072 private char separator1 = TAB; // 6.0.2.5 (2014/10/31) TAB を char 化 073 private char separator2 = TAB; // 6.0.2.5 (2014/10/31) TAB を char 化 074 private String infile1 ; 075 private String encode1 ; // 6.3.1.0 (2015/06/28) エラー時のメッセージに使う。 076 private String infile2 ; 077 private BufferedReader reader1 ; 078 private LineModel model ; 079 private String line ; 080 private int[] clmNos ; // ファイルのヘッダーのカラム番号 081 private int[] keyClmNos ; // 比較する列の基準カラム名のカラム番号 082 private int[] diffClmNos ; // 比較するカラム名のカラム番号 083 private String actCmnd ; // action から名称変更 084 private boolean display ; // 表示しない 085 private boolean debug ; // 表示しない 086 private boolean nameNull ; // 0件データ時 true 087 088 /** 6.4.3.1 (2016/02/12) PMD refactoring. HashMap → ConcurrentHashMap に置き換え。 */ 089 private final ConcurrentMap<String,String> file2Map = new ConcurrentHashMap<>(); // 4.3.1.1 (2008/08/23) final化 090 091 private int inCount1 ; 092 private int inCount2 ; 093 private int outCount ; 094 095 /** staticイニシャライザ後、読み取り専用にするので、ConcurrentHashMap を使用しません。 */ 096 private static final Map<String,String> MUST_PROPARTY ; // [プロパティ]必須チェック用 Map 097 /** staticイニシャライザ後、読み取り専用にするので、ConcurrentHashMap を使用しません。 */ 098 private static final Map<String,String> USABLE_PROPARTY ; // [プロパティ]整合性チェック Map 099 100 static { 101 MUST_PROPARTY = new LinkedHashMap<>(); 102 MUST_PROPARTY.put( "infile1", "入力ファイル名1 (必須)" ); 103 MUST_PROPARTY.put( "infile2", "入力ファイル名2 (必須)" ); 104 MUST_PROPARTY.put( "action", "(必須)ONLY,DIFF,INTERSEC" ); 105 MUST_PROPARTY.put( "keyClms", "比較する列の基準カラム名(必須)(CSV形式)" ); 106 MUST_PROPARTY.put( "diffClms", "比較するカラム名(必須)(CSV形式)" ); 107 108 USABLE_PROPARTY = new LinkedHashMap<>(); 109 USABLE_PROPARTY.put( "sep1", "区切り文字1 (初期値:タブ)" ); 110 USABLE_PROPARTY.put( "sep2", "区切り文字2 (初期値:タブ)" ); 111 USABLE_PROPARTY.put( "encode1", "入力ファイルのエンコードタイプ1" ); 112 USABLE_PROPARTY.put( "encode2", "入力ファイルのエンコードタイプ2" ); 113 USABLE_PROPARTY.put( "columns", "入力カラム名(CSV形式)" ); 114 USABLE_PROPARTY.put( "display", "結果を標準出力に表示する(true)かしない(false)か" + 115 CR + " (初期値:false:表示しない)" ); 116 USABLE_PROPARTY.put( "debug", "デバッグ情報を標準出力に表示する(true)かしない(false)か" + 117 CR + " (初期値:false:表示しない)" ); 118 } 119 120 /** 121 * デフォルトコンストラクター。 122 * このクラスは、動的作成されます。デフォルトコンストラクターで、 123 * super クラスに対して、必要な初期化を行っておきます。 124 * 125 */ 126 public Process_TableDiff() { 127 super( "org.opengion.fukurou.process.Process_TableDiff",MUST_PROPARTY,USABLE_PROPARTY ); 128 } 129 130 /** 131 * プロセスの初期化を行います。初めに一度だけ、呼び出されます。 132 * 初期処理(ファイルオープン、DBオープン等)に使用します。 133 * 134 * @og.rev 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 135 * 136 * @param paramProcess データベースの接続先情報などを持っているオブジェクト 137 */ 138 public void init( final ParamProcess paramProcess ) { 139 final Argument arg = getArgument(); 140 141 infile1 = arg.getProparty( "infile1" ); 142 encode1 = arg.getProparty( "encode1",ENCODE ); 143 infile2 = arg.getProparty( "infile2" ); 144 actCmnd = arg.getProparty( "action" ); 145 display = arg.getProparty( "display",display ); 146 debug = arg.getProparty( "debug" ,debug ); 147 148 // 6.0.2.5 (2014/10/31) TAB を char 化 149 final String sep1 = arg.getProparty( "sep1",null ); 150 final String sep2 = arg.getProparty( "sep2",null ); 151 if( sep1 != null ) { separator1 = sep1.charAt(0); } 152 if( sep2 != null ) { separator2 = sep2.charAt(0); } 153 154 if( infile1 == null || infile2 == null ) { 155 final String errMsg = "ファイル名が指定されていません。" 156 + "File1=[" + infile1 + "] , File2=[" + infile2 + "]" ; 157 throw new OgRuntimeException( errMsg ); 158 } 159 160 final File file1 = new File( infile1 ); 161 final File file2 = new File( infile2 ); 162 163 if( ! file1.exists() || ! file2.exists() ) { 164 // 4.3.1.1 (2008/08/23) Avoid if(x != y) ..; else ..; 165 final String errMsg = "ファイルが存在しません。" 166 + ( file1.exists() ? "" : "File1=[" + file1 + "] " ) 167 + ( file2.exists() ? "" : "File2=[" + file2 + "]" ); 168 throw new OgRuntimeException( errMsg ); 169 } 170 171 if( ! file1.isFile() || ! file2.isFile() ) { 172 // 4.3.1.1 (2008/08/23) Avoid if(x != y) ..; else ..; 173 final String errMsg = "フォルダは指定できません。ファイル名を指定してください。" 174 + ( file1.isFile() ? "" : "File1=[" + file1 + "] " ) 175 + ( file2.isFile() ? "" : "File2=[" + file2 + "]" ); 176 throw new OgRuntimeException( errMsg ); 177 } 178 179 reader1 = FileUtil.getBufferedReader( file1,encode1 ); 180 181 final String[] names ; 182 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point. 183 final String clms = arg.getProparty( "columns" ); 184 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid if (x != y) ..; else ..; 185 if( clms == null ) { 186 final String[] clmNames = readName( reader1 ); // ファイルのカラム名配列 187 if( clmNames == null || clmNames.length == 0 ) { nameNull = true; return ; } 188 names = clmNames; 189 } 190 else { 191 names = StringUtil.csv2Array( clms ); // 指定のカラム名配列 192 } 193 194 model = new LineModel(); 195 model.init( names ); 196 197 if( display ) { println( model.nameLine() ); } 198 199 // 入力カラム名のカラム番号 200 clmNos = new int[names.length]; 201 for( int i=0; i<names.length; i++ ) { 202 clmNos[i] = i+1; // 行番号分を+1しておく。 203 } 204 205 // 比較する列の基準カラム名 206 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point. 207 final String keyClms = arg.getProparty( "keyClms" ); 208 if( debug ) { println( "DEBUG:\tkeyClms=" + keyClms ); } 209 final String[] keyClmNms = StringUtil.csv2Array( keyClms ); 210 keyClmNos = new int[keyClmNms.length]; 211 for( int i=0; i<keyClmNms.length; i++ ) { 212 keyClmNos[i] = model.getColumnNo( keyClmNms[i] ); 213 // if( debug ) { println( "DEBUG:" + keyClmNms[i] + ":[" + keyClmNos[i] + "]" ); } 214 // int no = model.getColumnNo( keyClmNms[i] ); 215 // if( no >= 0 ) { keyClmNos[no] = i+1; } // 行番号分を+1しておく。 216 } 217 218 // 比較するカラム名 219 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point. 220 final String diffClms = arg.getProparty( "diffClms" ); 221 if( debug ) { println( "DEBUG:\tdiffClms=" + diffClms ); } 222 final String[] diffClmNms = StringUtil.csv2Array( diffClms ); 223 diffClmNos = new int[diffClmNms.length]; 224 for( int i=0; i<diffClmNms.length; i++ ) { 225 diffClmNos[i] = model.getColumnNo( diffClmNms[i] ); 226 // if( debug ) { println( "DEBUG:" + diffClmNms[i] + ":[" + diffClmNos[i] + "]" ); } 227 // int no = model.getColumnNo( diffClmNms[i] ); 228 // if( no >= 0 ) { diffClmNos[no] = i+1; } // 行番号分を+1しておく。 229 } 230 231 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point. 232 final String encode2 = arg.getProparty( "encode2",ENCODE ); 233 readF2Data( file2,encode2 ); 234 } 235 236 /** 237 * プロセスの終了を行います。最後に一度だけ、呼び出されます。 238 * 終了処理(ファイルクローズ、DBクローズ等)に使用します。 239 * 240 * @param isOK トータルで、OKだったかどうか[true:成功/false:失敗] 241 */ 242 public void end( final boolean isOK ) { 243 Closer.ioClose( reader1 ); 244 reader1 = null; 245 } 246 247 /** 248 * このデータの処理において、次の処理が出来るかどうかを問い合わせます。 249 * この呼び出し1回毎に、次のデータを取得する準備を行います。 250 * 251 * @og.rev 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 252 * @og.rev 6.5.0.1 (2016/10/21) CharacterCodingException は、OgCharacterException に変換する。 253 * 254 * @return 処理できる:true / 処理できない:false 255 */ 256 @Override // FirstProcess 257 public boolean next() { 258 if( nameNull ) { return false; } 259 260 boolean flag = false; 261 try { 262 while((line = reader1.readLine()) != null) { 263 inCount1++ ; 264 if( line.isEmpty() || line.charAt(0) == '#' ) { continue; } 265 else { 266 flag = true; 267 break; 268 } 269 } 270 } 271 // 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 272 catch( final CharacterCodingException ex ) { 273 final String errMsg = "文字のエンコード・エラーが発生しました。" + CR 274 + " ファイルのエンコードが指定のエンコードと異なります。" + CR 275 + " [" + infile1 + "] , Encode=[" + encode1 + "]" ; 276 throw new OgCharacterException( errMsg,ex ); // 6.5.0.1 (2016/10/21) 277 } 278 catch( final IOException ex) { 279 final String errMsg = "ファイル読込みエラー[" + infile1 + "]:(" + inCount1 + ")" ; 280 throw new OgRuntimeException( errMsg,ex ); 281 } 282 return flag; 283 } 284 285 /** 286 * 最初に、 行データである LineModel を作成します 287 * FirstProcess は、次々と処理をチェインしていく最初の行データを 288 * 作成して、後続の ChainProcess クラスに処理データを渡します。 289 * 290 * ファイルより読み込んだ1行のデータを テーブルモデルに 291 * セットするように分割します 292 * なお、読込みは,NAME項目分を読み込みます。データ件数が少ない場合は、 293 * "" をセットしておきます。 294 * 295 * @param rowNo 処理中の行番号 296 * 297 * @return 処理変換後のLineModel 298 */ 299 @Override // FirstProcess 300 public LineModel makeLineModel( final int rowNo ) { 301 outCount++ ; 302 final String[] vals = StringUtil.csv2Array( line ,separator1 ); // 6.0.2.5 (2014/10/31) TAB を char 化 303 304 final int len = vals.length; 305 for( int clmNo=0; clmNo<model.size(); clmNo++ ) { 306 final int no = clmNos[clmNo]; 307 if( len > no ) { 308 model.setValue( clmNo,vals[no] ); 309 } 310 else { 311 // EXCEL が、終端TABを削除してしまうため、少ない場合は埋める。 312 model.setValue( clmNo,"" ); 313 } 314 } 315 model.setRowNo( rowNo ) ; 316 317 // if( display ) { println( model.dataLine() ); } // 5.1.2.0 (2010/01/01) display の条件変更 318 319 return action( model ); 320 } 321 322 /** 323 * キーと、DIFF設定値を比較し、action に応じた LineModel を返します。 324 * action には、ONLY,DIFF,INTERSEC が指定できます。 325 * ONLY inFile1 のみに存在する行の場合、inFile1 のレコードを返します。 326 * DIFF inFile1 と inFile2 に存在し、かつ、DIFF値が異なる、inFile1 のレコードを返します。 327 * INTERSEC inFile1 と inFile2 に存在し、かつ、DIFF値も同じ、inFile1 のレコードを返します。 328 * inFile2 側をキャッシュしますので、inFile2 側のデータ量が少ない様に選んでください。 329 * 330 * @og.rev 6.4.3.1 (2016/02/12) PMD refactoring. HashMap → ConcurrentHashMap に置き換え。 331 * 332 * @param model LineModelオブジェクト 333 * 334 * @return 実行後のLineModel 335 */ 336 private LineModel action( final LineModel model ) { 337 LineModel rtn = null; 338 final Object[] obj = model.getValues(); 339 340 // キーのカラムを合成します。 341 final StringBuilder keys = new StringBuilder( BUFFER_MIDDLE ); 342 for( int i=0; i<keyClmNos.length; i++ ) { 343 keys.append( obj[keyClmNos[i]] ).append( ',' ); // 6.0.2.5 (2014/10/31) char を append する。 344 } 345 346 final String data = file2Map.get( keys.toString() ); 347 // if( debug ) { println( "DEBUG:" + keys.toString() + ":" + data ); } 348 349 if( "ONLY".equalsIgnoreCase( actCmnd ) && data == null ) { 350 if( debug ) { println( "DEBUG:ONLY\t" + keys.toString() ); } 351 rtn = model; 352 } 353 else { 354 // DIFF値のカラムを合成します。 355 final StringBuilder vals = new StringBuilder( BUFFER_MIDDLE ); 356 for( int i=0; i<diffClmNos.length; i++ ) { 357 vals.append( obj[diffClmNos[i]] ).append( ',' ); // 6.0.2.5 (2014/10/31) char を append する。 358 } 359 360 final boolean eq = vals.toString().equals( data ); 361 362 if( "DIFF".equalsIgnoreCase( actCmnd ) && ! eq ) { 363 if( debug ) { println( "DEBUG:DIFF\t" + keys.toString() + TAB + data + TAB + vals.toString() ); } 364 rtn = model; 365 } 366 else if( "INTERSEC".equalsIgnoreCase( actCmnd ) && eq ) { 367 if( debug ) { println( "DEBUG:INTERSEC\t" + keys.toString() + TAB + data ); } 368 rtn = model; 369 } 370 } 371 if( display && rtn != null ) { println( rtn.dataLine() ); } 372 return rtn; 373 } 374 375 /** 376 * BufferedReader より、#NAME 行の項目名情報を読み取ります。 377 * データカラムより前に、項目名情報を示す "#Name" が存在する仮定で取り込みます。 378 * この行は、ファイルの形式に無関係に、TAB で区切られています。 379 * 380 * @og.rev 6.0.4.0 (2014/11/28) #NAME 行の区切り文字は、指定の区切り文字を優先して利用する。 381 * @og.rev 6.0.4.0 (2014/11/28) #NAME 判定で、桁数不足のエラーが発生する箇所を修正。 382 * @og.rev 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 383 * @og.rev 6.5.0.1 (2016/10/21) CharacterCodingException は、OgCharacterException に変換する。 384 * 385 * @param reader PrintWriterオブジェクト 386 * 387 * @return カラム名配列(存在しない場合は、サイズ0の配列) 388 * @og.rtnNotNull 389 */ 390 private String[] readName( final BufferedReader reader ) { 391 try { 392 // 4.0.0 (2005/01/31) line 変数名変更 393 String line1; 394 while((line1 = reader.readLine()) != null) { 395 inCount1++ ; 396 if( line1.isEmpty() ) { continue; } 397 if( line1.charAt(0) == '#' ) { 398 // 6.0.4.0 (2014/11/28) #NAME 判定で、桁数不足のエラーが発生する箇所を修正。 399 if( line1.length() >= 5 && "#NAME".equalsIgnoreCase( line1.substring( 0,5 ) ) ) { 400 // 6.0.4.0 (2014/11/28) #NAME 行の区切り文字は、指定の区切り文字を優先して利用する。 401 final char sep ; 402 if( TAB != separator1 && line1.indexOf( separator1 ) >= 0 ) { 403 sep = separator1; 404 } 405 else { 406 sep = TAB; 407 } 408 // 超イレギュラー処理。#NAME をカラム列に入れない(#NAME+区切り文字 の 6文字分、飛ばす)。 409 return StringUtil.csv2Array( line1.substring( 6 ) ,sep ); 410 } 411 else { continue; } 412 } 413 else { 414 final String errMsg = "#NAME が見つかる前にデータが見つかりました。"; 415 throw new OgRuntimeException( errMsg ); 416 } 417 } 418 } 419 // 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 420 catch( final CharacterCodingException ex ) { 421 final String errMsg = "文字のエンコード・エラーが発生しました。" + CR 422 + " ファイルのエンコードが指定のエンコードと異なります。" + CR 423 + " [" + infile1 + "] , Encode=[" + encode1 + "]" ; 424 throw new OgCharacterException( errMsg,ex ); // 6.5.0.1 (2016/10/21) 425 } 426 catch( final IOException ex) { 427 final String errMsg = "ファイル読込みエラー[" + infile1 + "]:(" + inCount1 + ")" ; 428 throw new OgRuntimeException( errMsg,ex ); 429 } 430 return new String[0]; 431 } 432 433 /** 434 * ファイル属性を読取り、キー情報を作成し、内部メモリマップにキャッシュします。 435 * このマップをもとに、inFile1 のデータを逐次読み取って、処理を進めます。 436 * 437 * @og.rev 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 438 * @og.rev 6.5.0.1 (2016/10/21) CharacterCodingException は、OgCharacterException に変換する。 439 * 440 * @param file2 読取り元のファイル 441 * @param encode2 ファイルのエンコード 442 */ 443 private void readF2Data( final File file2, final String encode2 ) { 444 BufferedReader reader2 = null; 445 try { 446 if( debug ) { println( "DEBUG:\tFile2="+ file2 + " 初期処理" ); } 447 reader2 = FileUtil.getBufferedReader( file2,encode2 ); 448 // 4.0.0 (2005/01/31) line 変数名変更 449 String line1; 450 final StringBuilder keys = new StringBuilder( BUFFER_MIDDLE ); // 6.1.0.0 (2014/12/26) refactoring 451 final StringBuilder vals = new StringBuilder( BUFFER_MIDDLE ); // 6.1.0.0 (2014/12/26) refactoring 452 while((line1 = reader2.readLine()) != null) { 453 inCount2++ ; 454 if( line1.isEmpty() || line1.charAt(0) == '#' ) { continue; } 455 else { 456 // 超イレギュラー処理 最初の TAB 以前の文字は無視する。 457 final String line2 = line1.substring( line1.indexOf( separator2 )+1 ); 458 final Object[] obj = StringUtil.csv2Array( line2 , separator2 ); // 6.0.2.5 (2014/10/31) TAB を char 化 459 460 // キーのカラムを合成します。 461 keys.setLength(0); // 6.1.0.0 (2014/12/26) refactoring 462 for( int i=0; i<keyClmNos.length; i++ ) { 463 keys.append( obj[keyClmNos[i]] ).append( ',' ); // 6.0.2.5 (2014/10/31) char を append する。 464 } 465 466 // DIFF値のカラムを合成します。 467 vals.setLength(0); // 6.1.0.0 (2014/12/26) refactoring 468 for( int i=0; i<diffClmNos.length; i++ ) { 469 vals.append( obj[diffClmNos[i]] ).append( ',' ); // 6.0.2.5 (2014/10/31) char を append する。 470 } 471 472 if( debug ) { println( "DEBUG:\t" + keys.toString() + "\t" + vals.toString() ); } 473 474 file2Map.put( keys.toString(), vals.toString() ); 475 } 476 } 477 if( debug ) { println( "DEBUG:\t======初期処理終了======" ); } 478 } 479 // 6.3.1.0 (2015/06/28) nioを使用すると UTF-8とShuft-JISで、エラーになる。 480 catch( final CharacterCodingException ex ) { 481 final String errMsg = "文字のエンコード・エラーが発生しました。" + CR 482 + " ファイルのエンコードが指定のエンコードと異なります。" + CR 483 + " [" + file2.getPath() + "] , Encode=[" + encode2 + "]" ; 484 throw new OgCharacterException( errMsg,ex ); // 6.5.0.1 (2016/10/21) 485 } 486 catch( final IOException ex) { 487 final String errMsg = "ファイル読込みエラー[" + file2.getPath() + "]:(" + inCount2 + ")" ; 488 throw new OgRuntimeException( errMsg,ex ); 489 } 490 finally { 491 Closer.ioClose( reader2 ); 492 } 493 } 494 495 /** 496 * プロセスの処理結果のレポート表現を返します。 497 * 処理プログラム名、入力件数、出力件数などの情報です。 498 * この文字列をそのまま、標準出力に出すことで、結果レポートと出来るような 499 * 形式で出してください。 500 * 501 * @return 処理結果のレポート 502 */ 503 public String report() { 504 // 7.2.9.5 (2020/11/28) PMD:Consider simply returning the value vs storing it in local variable 'XXXX' 505 return "[" + getClass().getName() + "]" + CR 506// final String report = "[" + getClass().getName() + "]" + CR 507 + TAB + "Input File1 : " + infile1 + CR 508 + TAB + "Input File2 : " + infile2 + CR 509 + TAB + "Input Count1 : " + inCount1 + CR 510 + TAB + "Input Count2 : " + inCount2 + CR 511 + TAB + "Output Count : " + outCount ; 512 513// return report ; 514 } 515 516 /** 517 * このクラスの使用方法を返します。 518 * 519 * @return このクラスの使用方法 520 * @og.rtnNotNull 521 */ 522 public String usage() { 523 final StringBuilder buf = new StringBuilder( BUFFER_LARGE ) 524 .append( "Process_TableDiffは、ファイルから読み取った内容を、LineModel に設定後、" ).append( CR ) 525 .append( "下流に渡す、FirstProcess インターフェースの実装クラスです。" ).append( CR ) 526 .append( CR ) 527 .append( "DBTableModel 形式のファイルを読み取って、各行を LineModel にセットして、" ).append( CR ) 528 .append( "下流(プロセスチェインのデータは上流から下流に渡されます。)に渡します。" ).append( CR ) 529 .append( CR ) 530 .append( "引数文字列中に空白を含む場合は、ダブルコーテーション(\"\") で括って下さい。" ).append( CR ) 531 .append( "引数文字列の 『=』の前後には、空白は挟めません。必ず、-key=value の様に" ).append( CR ) 532 .append( "繋げてください。" ).append( CR ) 533 .append( CR ).append( CR ) 534 .append( getArgument().usage() ).append( CR ); 535 536 return buf.toString(); 537 } 538 539 /** 540 * このクラスは、main メソッドから実行できません。 541 * 542 * @param args コマンド引数配列 543 */ 544 public static void main( final String[] args ) { 545 LogWriter.log( new Process_TableDiff().usage() ); 546 } 547}