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.hayabusa.html; 017 018import org.opengion.fukurou.system.OgRuntimeException ; // 6.4.2.0 (2016/01/29) 019import static org.opengion.fukurou.system.HybsConst.CR ; // 6.1.0.0 (2014/12/26) 020import org.opengion.fukurou.util.StringUtil; 021import org.opengion.fukurou.model.Formatter; 022import org.opengion.hayabusa.common.HybsSystemException; 023import org.opengion.hayabusa.db.DBTableModel; 024 025import java.util.regex.Pattern; 026import java.util.regex.Matcher; 027import java.util.stream.IntStream; // 6.4.3.4 (2016/03/11) 028 029/** 030 * [PN],[OYA] などの [] で指定されたカラムで表されたフォーマットデータに対して、 031 * DBTableModelオブジェクトを適用して 各カラムに実データを割り当てるオブジェクトです。 032 * 033 * 特に、[XXXX]に対して、[#XXXX]、[$XXXX]、[$XXXX]などの特殊記号が使用できます。 034 * 特殊記号の解釈は、HTMLFormatTextField系とHTMLFormatTable系で異なりますので 035 * ご注意ください。 036 * 037 * @og.rev 3.5.4.0 (2003/11/25) 新規追加 038 * @og.group 画面表示 039 * 040 * @version 4.0 041 * @author Kazuhiko Hasegawa 042 * @since JDK5.0, 043 */ 044public class TableFormatter { 045 046 /** フォーマットタイプの指定の特殊なマーク {@value} */ 047 public static final String HYBS_ITD_MARKER = "h_itd_marker"; 048 // 4.3.2.0 (2008/09/10) </td>前のスペースを取り消す。 049 private static final Pattern PTN_KEY = Pattern.compile( "[ \t]+</td" ); // 6.4.1.1 (2016/01/16) ptnKey → PTN_KEY refactoring 050 051 private FormatterType formatType ; 052 private int[] location ; 053 private String[] format ; 054 private String formatTag ; 055 private String rowspan = " rowspan=\"2\""; 056 private String trTag ; 057 private boolean noClass ; 058 // 3.5.6.0 (2004/06/18) '!' 値のみ 追加 既存の '$' は、レンデラー 059 private char[] type ; // '#':ラベルのみ '$':レンデラー '!':値のみ その他:通常 060 private String usableKey ; // キー情報のカラム文字列 061 private int usableKeyNo = -1; // キー情報のカラム番号 062 private String usableList = "1"; 063 064 private String keyBreakClm ; // 5.7.6.3 (2014/05/23) キーブレイクをチェックするカラムID 065 private int breakClmNo = -1; // 5.7.6.3 (2014/05/23) キーブレイクカラム番号 066 private String breakVal ; // 5.7.6.3 (2014/05/23) キーブレイクをチェックする値 067 068 private String itdBody = ""; // 3.5.6.0 (2004/06/18) 追加 069 private Formatter formatter ; 070 071 /** 072 * デフォルトコンストラクター 073 * 074 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 075 */ 076 public TableFormatter() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 077 078 /** 079 * フォーマットをセットします。 080 * フォーマットに、<table>を含む場合、TextField扱いなので、フォーマット分割 081 * しません。table を含まず、tr を含む場合は、1行分のデータとして扱う為、 082 * trTag を求めます。 083 * trTag と format との間に、行ヘッダーが入ります。 084 * Tomcat6では、JSPのパース時に、tabやspaceはそのままパースされるため、</td>前 085 * のスペース削除処理も行います。 086 * 087 * @og.rev 4.3.2.0 (2008/09/10) </td>前のスペースを取り消します。 088 * @og.rev 5.5.0.3 (2012/03/13) <tr>を取らないフラグ追加 089 * 090 * @param fmt [カラム名] 形式のフォーマットデータ 091 * @param flag falseにすると先頭のtrタグを取る処理を行いません(5.5.0.3) 092 */ 093 public void setFormat( final String fmt , final boolean flag ) { 094 final int tbl = fmt.indexOf( "<table" ); 095 final int str = fmt.indexOf( "<tr" ); 096 097 // tr を含み、かつ、tableを含まないか、含んでも tr の後ろにtableがある場合。 098 if( str >= 0 && ( tbl < 0 || str < tbl ) && flag ) { // 5.5.0.3(2012/03/13) 099 final int end = fmt.indexOf( '>',str ); 100 formatTag = fmt.substring(end+1); 101 trTag = fmt.substring(0,end+1) ; 102 } 103 else { 104 formatTag = fmt; 105 trTag = null; 106 } 107 // 4.3.2.0 (2008/09/10) </td>前のスペースを取り消す。 108 final Matcher matcher = PTN_KEY.matcher( formatTag ); 109 formatTag = matcher.replaceAll( "</td" ); 110 } 111 112 /** 113 * フォーマットをセットします。 114 * フォーマットに、<table>を含む場合、TextField扱いなので、フォーマット分割 115 * しません。table を含まず、tr を含む場合は、1行分のデータとして扱う為、 116 * trTag を求めます。 117 * trTag と format との間に、行ヘッダーが入ります。 118 * Tomcat6では、JSPのパース時に、tabやspaceはそのままパースされるため、</td>前 119 * のスペース削除処理も行います。 120 * 121 * @og.rev 5.5.0.3 (2012/03/13) 引数追加につき。 122 * 123 * @param fmt [カラム名] 形式のフォーマットデータ 124 */ 125 public void setFormat( final String fmt ) { 126 setFormat( fmt , true ); 127 } 128 129 /** 130 * フォーマットを取得します。 131 * 132 * @og.rev 3.5.5.8 (2004/05/20) 新規追加 133 * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻し処理("\\]\\"から"["に戻し)を追加 134 * 135 * @return フォーマットデータ 136 */ 137 public String getFormat() { 138 // 6.4.1.1 (2016/01/16) PMD refactoring. A method should have only one exit point, and that should be the last statement in the method 139 // 反転注意 140 return trTag == null ? decodeSanitizedStr( formatTag ) : decodeSanitizedStr( trTag + formatTag ); 141 } 142 143 /** 144 * DBTableModelを利用して、フォーマットデータを初期化します。 145 * 146 * @og.rev 3.5.5.0 (2004/03/12) [KEY.カラム名] 機能追加 147 * @og.rev 3.5.5.2 (2004/04/02) [I] で、行番号を作成します。 148 * @og.rev 3.5.6.0 (2004/06/18) '!' 値のみ 追加 既存の '$' は、レンデラー 149 * @og.rev 3.6.0.0 (2004/09/17) [ROW.ID] で、行毎のチェックボックスのIDを返します。 150 * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻し処理("\\]\\"から"["に戻し)を追加 151 * @og.rev 5.7.6.3 (2014/05/23) キーブレイクをチェックする keyBreakClm 属性追加 152 * @og.rev 6.4.3.4 (2016/03/11) Formatterに新しいコンストラクターを追加する。 153 * 154 * @param table DBTableModelオブジェクト 155 */ 156 public void makeFormat( final DBTableModel table ) { 157 formatter = new Formatter( table,formatTag ); // 6.4.3.4 (2016/03/11) 158 location = formatter.getClmNos(); 159 format = formatter.getFormat(); 160 161 // 5.1.7.0 (2010/06/01) サニタイズ戻し処理("\\]\\"から"["に戻し)を追加 162 // 6.0.2.5 (2014/10/31) null でないことがわかっている値の冗長な null チェックがあります。 163 for( int i=0; i<format.length; i++ ) { 164 format[i] = decodeSanitizedStr( format[i] ); 165 } 166 167 type = formatter.getType(); 168 169 // このフォーマットを使用するかどうかを指定する判定条件の初期設定です。 170 if( usableKey != null ) { 171 usableKeyNo = table.getColumnNo( usableKey ); 172 } 173 174 // 5.7.6.3 (2014/05/23) キーブレイクをチェックする keyBreakClm 属性追加 175 if( keyBreakClm != null ) { 176 breakClmNo = table.getColumnNo( keyBreakClm ); 177 breakVal = null; // 初期化します。 178 } 179 } 180 181 /** 182 * テーブルフォーマットのタイプを指定します。 183 * enum FormatterType で、指定します。 184 * 185 * @og.rev 4.0.0.0 (2007/05/02) enum 定義に変更 186 * 187 * @param ftype フォーマットのタイプ 188 */ 189 public void setFormatType( final FormatterType ftype ) { 190 formatType = ftype; 191 } 192 193 /** 194 * このフォーマットのタイプを返します。 195 * 196 * このフォーマットのタイプを返します。 197 * 198 * @og.rev 4.0.0.0 (2007/05/02) enum 定義に変更 199 * 200 * @return このフォーマットのタイプを返します。 201 */ 202 public FormatterType getFormatType() { 203 return formatType; 204 } 205 206 /** 207 * テーブルの rowspan 属性をセットします。 208 * rowspan は、ヘッダー部のフォーマットの行数です。初期値は 2行 です。 209 * 設定は、"2" などの、数字部のみをセットします。 210 * 211 * @param rowspan 属性 212 */ 213 public void setRowspan( final String rowspan ) { 214 if( rowspan == null || rowspan.isEmpty() || rowspan.equals( "1" ) ) { 215 this.rowspan = ""; 216 } 217 else { 218 this.rowspan = " rowspan=\"" + rowspan + "\""; 219 } 220 } 221 222 /** 223 * 設定された rowspan を返します。 224 * これは、フォーマットの段組の数を取り出します。 225 * 文字列としては、rowspan="2" という形で取り出します。 226 * 227 * @return フォーマット文字列 228 */ 229 public String getRowspan() { 230 return rowspan; 231 } 232 233 /** 234 * ロケーション番号のサイズを返します。 235 * フォーム位置番号は、0 から getLocationSize()-1 までの数字を指定します。 236 * ロケーションサイズは、aaa[ABC]bbb[DEF]ccc[GHI]ddd となっている場合、 237 * aaa , bbb , ccc , ddd は、フォーマットで、サイズは4。 238 * ABC , DEF , GHI に対応するカラム番号がロケーションで、サイズは3。 239 * このメソッドで返すのは、ロケーション番号(3)の方です。 240 * 241 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 242 * 243 * @return ロケーション番号のサイズ 244 */ 245 public int getLocationSize() { 246 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 247 if( location == null ) { 248 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 249 throw new OgRuntimeException( errMsg ); 250 } 251 252 return location.length; 253 } 254 255 /** 256 * カラムのロケーション番号を返します。 257 * 引数は、0 から、getLocationSize()-1 までの数で指定します。 258 * 指定の位置の、フォーマットのカラム名に対応するロケーション番号 259 * を返します。 260 * 261 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 262 * 263 * @param no フォーム位置番号 264 * 265 * @return ロケーション番号 266 */ 267 public int getLocation( final int no ) { 268 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 269 if( location == null ) { 270 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 271 throw new OgRuntimeException( errMsg ); 272 } 273 274 return location[no]; 275 } 276 277 /** 278 * カラムのロケーション番号をIntStreamで返します。 279 * 280 * 指定の位置の、フォーマットのカラム名に対応するロケーション番号のIntStreamです。 281 * 282 * @og.rev 6.4.3.4 (2016/03/11) 内部のLocation配列を、IntStreamで返します。 283 * 284 * @return 内部のLocation配列を、IntStreamで返します。 285 */ 286 public IntStream getLocationStream() { 287 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 288 if( location == null ) { 289 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 290 throw new OgRuntimeException( errMsg ); 291 } 292 293 return IntStream.of( location ); 294 } 295 296 /** 297 * 指定のロケーション番号の値をクリアします。 298 * ただし、直前のフォーマットに、td タグが存在する場合は、 299 * style="display:none;" を設定することで、td タグそのものが 300 * 無くなります。 301 * その場合、段組みなどのレイアウトを行っていると、フォーマットが 302 * 崩れますので、十分ご確認ください。 303 * また、同一 td 内に複数のカラムを指定した場合は、tdタグ内のすべての 304 * カラムが消えます。 305 * td タグが存在しない場合は、非表示というより、データを空に 306 * するだけになります。 307 * 308 * @og.rev 6.2.0.0 (2015/02/27) フォーマット系の noDisplay 対応 309 * @og.rev 6.2.0.1 (2015/03/06) 非表示のマーカーに、Formatter#NO_DISPLAY を使用する。 310 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 311 * 312 * @param no フォーム位置番号 313 */ 314 protected void setNoDisplay( final int no ) { 315 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 316 if( location == null || format == null ) { 317 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 318 throw new OgRuntimeException( errMsg ); 319 } 320 321 location[no] = Formatter.NO_DISPLAY ; 322 323 int tdIdx = format[no] == null ? -1 : format[no].indexOf( "<td" ) ; // nullチェックも兼ねる 324 325 // 6.2.0.1 (2015/03/06) 非表示のマーカーの td に、style="display:none;" 追加 326 if( tdIdx >= 0 ) { 327 int adrs = format[no].indexOf( "style=\"" ); 328 if( adrs >= 0 ) { // style 属性が既に存在する場合。 329 adrs += "style=\"".length(); // style=" の直後の位置を求める。 330 format[no] = format[no].substring( 0,adrs ) 331 + "display:none;" 332 + format[no].substring( adrs ) ; 333 } 334 else { // style 属性がないので、td の直後に入れる。 335 tdIdx += "<td".length(); // td の直後の位置を求める。 336 format[no] = format[no].substring( 0,tdIdx ) 337 + " style=\"display:none;\"" 338 + format[no].substring( tdIdx ) ; 339 } 340 } 341 } 342 343 /** 344 * フォーマット文字列を返します。 345 * 引数は、0 から、getLocationSize() までの数で指定します。 346 * 指定のフォーマットが、aaa[ABC]bbb[DEF]ccc[GHI]ddd となっている場合、 347 * aaa , bbb , ccc , ddd を引数 0 , 1 , 2 , 3 で返します。 348 * 349 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 350 * 351 * @param no フォーム位置番号 352 * 353 * @return フォーマット文字列 354 */ 355 public String getFormat( final int no ) { 356 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 357 if( format == null ) { 358 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 359 throw new OgRuntimeException( errMsg ); 360 } 361 362 return format[no]; 363 } 364 365 /** 366 * システムフォーマット文字列を返します。 367 * システムフォーマット文字列は、[KEY.カラム名] などの特殊記号で指定された 368 * カラム名の事で、location には、マイナスの値が設定されます。 369 * マイナスの値に応じて、処理を変えることが出来ます。 370 * 371 * [KEY.カラム名] : 行番号付きカラム名 372 * [I] : 行番号 373 * [ROW.ID] : 行毎のチェックボックスのID 374 * [ROW.JSON] : 行毎の全データのJavaScriptオブジェクト形式 375 * 376 * @og.rev 3.5.5.0 (2004/03/12) [KEY.カラム名] 機能追加 377 * @og.rev 3.5.5.2 (2004/04/02) [I] で、行番号を作成します。 378 * @og.rev 3.6.0.0 (2004/09/17) [ROW.ID] で、行毎のチェックボックスのIDを返します。 379 * @og.rev 4.0.0.0 (2007/05/02) Formatter を使用するように変更 380 * @og.rev 6.2.0.1 (2015/03/06) 非表示のマーカーに、Formatter#NO_DISPLAY を使用する。 381 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 382 * 383 * @param row 行番号 384 * @param loc 位置番号 385 * 386 * @return フォーマット文字列 387 * @og.rtnNotNull 388 */ 389 public String getSystemFormat( final int row,final int loc ) { 390 if( loc == Formatter.SYS_ROWNUM ) { 391 return String.valueOf( row ); 392 } 393 else if( loc == Formatter.SYS_JSON ) { 394 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 395 if( formatter == null ) { 396 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 397 throw new OgRuntimeException( errMsg ); 398 } 399 400 return formatter.getJson( row ); 401 } 402 else if( loc == Formatter.NO_DISPLAY ) { // 6.2.0.1 (2015/03/06) 非表示のマーカー 403 return ""; 404 } 405 406 final String errMsg = "システムフォーマットは、下記の形式しか使用できません。[" + loc + "]" + CR 407 + " : [KEY.カラム名] : 行番号付きカラム名" + CR 408 + " : [I] : 行番号" + CR 409 + " : [ROW.ID] : 行毎のチェックボックスのID" + CR 410 + " : [ROW.JSON] : 行毎の全データのJavaScriptオブジェクト形式" ; 411 throw new HybsSystemException( errMsg ); 412 } 413 414 /** 415 * タイプ文字列を返します。 416 * タイプとは、[XXX] の記述で、[#XXX] は、XXXカラムのラベルを、[$XXX]は、XXXカラムの 417 * レンデラーを、[!XXX} は、値のみ取り出す指定を行います。 418 * 主に、TextField系のフォーマットとTable系では、意味合いが異なりますので、 419 * ご注意ください。 420 * 421 * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 422 * 423 * @param no フォーム位置番号 424 * 425 * @return タイプ文字列 '#':ラベルのみ '$':レンデラー '!':値のみ その他:通常 426 */ 427 public char getType( final int no ) { 428 // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs) 429 if( type == null ) { 430 final String errMsg = "#makeFormat(DBTableModel)を先に実行しておいてください。" ; 431 throw new OgRuntimeException( errMsg ); 432 } 433 434 return type[no]; 435 } 436 437 /** 438 * 設定された フォーマットの trタグを返します。 439 * これは、trタグにclass属性他の設定がされていた場合に、変換後の 440 * 文字列にも反映させる為に必要です。 441 * 442 * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻し処理("\\]\\"から"["に戻し)を追加 443 * 444 * @return フォーマットの trタグ 445 * @og.rtnNotNull 446 */ 447 public String getTrTag() { 448 // 6.4.1.1 (2016/01/16) PMD refactoring. A method should have only one exit point, and that should be the last statement in the method 449 return trTag == null ? "" : decodeSanitizedStr( trTag ) ; 450 } 451 452 /** 453 * カラムのクラス名(X,S9 など)のセットを行うかどうか指定します。 454 * 455 * "true" で、クラス属性を設定しません。これは、CSSファイルに書かれている属性を 456 * 使用しないことを意味します。 457 * 初期値は、"false" です。 458 * 459 * @param flag クラス名使用の有無(true:使用しない/false:使用する。) 460 */ 461 public void setNoClass( final String flag ) { 462 noClass = StringUtil.nval( flag,noClass ); 463 } 464 465 /** 466 * カラムのクラス名(X,S9 など)のセットを行うかどうか取得します。 467 * 468 * "true" で、クラス属性を設定しません。これは、CSSファイルに書かれている属性を 469 * 使用しないことを意味します。 470 * 初期値は、"false" です。 471 * 472 * @return クラス名使用の有無(true:使用しない/false:使用する。) 473 */ 474 public boolean isNoClass() { 475 return noClass; 476 } 477 478 /** 479 * フォーマットの使用可否を判断するキーとなるカラム名を指定します。 480 * 481 * キーが、usableList に含まれる場合は、このフォームを使用できます。 482 * キー(カラム名)が指定されない場合は、常に使用されます。 483 * ※ 現時点では、BODYタイプのみ使用しています。 484 * 485 * @param key フォーマットの使用可否を判断するカラム名 486 */ 487 public void setUsableKey( final String key ) { 488 usableKey = key; 489 } 490 491 /** 492 * フォーマットの使用可否を判断する文字列リストを指定します。 493 * 494 * キーが、この文字列リスト中に存在する場合は、このフォームを使用できます。 495 * この文字列リストは、固定な文字列です。{@XXXX}は使用できますが、[XXXX]は 496 * 使用できません。 497 * 初期値は、"1" です。 498 * ※ 現時点では、BODYタイプのみ使用しています。 499 * 500 * @param list フォーマットの使用可否を判断する文字列リスト 501 * @see TableFormatter#isUse( int,DBTableModel ) 502 */ 503 public void setUsableList( final String list ) { 504 if( list != null ) { 505 usableList = list; 506 } 507 } 508 509 /** 510 * ここで指定したカラムの値が、キーブレイクした場合、このタグを使用します。 511 * 512 * キーブレイクで 使用可否を指定する為の機能です。 513 * この設定値は、usableKey,usableList とは、独立しているため、それぞれで 514 * 有効になれば、使用されると判断されます。 515 * キーブレイク判定では、最初の1件目は、必ず使用されると判断されます。 516 * 517 * @og.rev 5.7.6.3 (2014/05/23) 新規追加 518 * 519 * @param kclm キーブレイクをチェックするカラムID 520 */ 521 public void setKeyBreakClm( final String kclm ) { 522 keyBreakClm = kclm; 523 } 524 525 /** 526 * このフォーマットを使用するかどうかの問い合わせを返します。 527 * 528 * "true" で、使用します。setUsableKey( String ) で、指定された 529 * カラム名の値が、setUsableList( String ) で指定された文字列に含まれていれば、 530 * 使用します。カラム名がセットされない場合は、デフォルト値("true")が使用されます。 531 * ※ 現時点では、BODYタイプのみ使用しています。 532 * カラムのデータに、不正なスペースが入る場合を想定して、trim() しています。 533 * よって、usableList の値にスペースは使用できません。 534 * 535 * 5.7.6.3 (2014/05/23) 以降は、keyBreakClm によるキーブレイクチェックも追加されました。 536 * 従来の usableKey,usableList とは、独立しているため、それぞれで有効になれば、 537 * 使用されると判断されます。 538 * 539 * @og.rev 3.5.6.2 (2004/07/05) 判定評価用カラムの値を trim() します。 540 * @og.rev 5.7.6.3 (2014/05/23) キーブレイクをチェックする keyBreakClm 属性追加 541 * 542 * @param row 行番号 543 * @param table DBTableModelオブジェクト 544 * 545 * @return このフォームを使用するかどうか(true:使用する/false:使用しない) 546 * @see TableFormatter#setUsableKey( String ) 547 * @see TableFormatter#setUsableList( String ) 548 */ 549 public boolean isUse( final int row, final DBTableModel table ) { 550 551 // どちらも設定されていなければ、使用される(=true) 552 if( usableKeyNo < 0 && breakClmNo < 0 ) { return true; } 553 554 // 以下、どちらかは設定されているため、true の時点で、使用される(=true)を返す。 555 if( usableKeyNo >= 0 ) { 556 final String val = table.getValue( row,usableKeyNo ).trim(); 557 if( usableList.indexOf( val ) >= 0 ) { return true; } 558 } 559 560 if( breakClmNo >= 0 ) { 561 final String val = table.getValue( row,breakClmNo ).trim(); 562 if( !val.equals( breakVal ) ) { // 同じでない場合は、true 563 breakVal = val; 564 return true; 565 } 566 } 567 568 return false ; // 最後まで残ると、使用されないと判断、false を返す。 569 } 570 571 /** 572 * itdフォーマット文字列を設定します。 573 * 574 * itd ボディ部の文字列を指定します。 575 * itd ボディは、繰り返し処理を行います。これを、上位のボディ文字列の中の 576 * HYBS_ITD_MARKER 文字列 と置き換えます。 577 * 578 * @og.rev 3.5.6.0 (2004/06/18) itdフォーマット文字列の取り込み 579 * 580 * @param itd itdフォーマットの文字列 581 */ 582 public void setItdBody( final String itd ) { 583 if( itd != null ) { 584 itdBody = itd; 585 } 586 } 587 588 /** 589 * itdフォーマット文字列を取得します。 590 * 591 * itd ボディ部の文字列を取得します。 592 * itd ボディは、繰り返し処理を行います。これを、上位のボディ文字列の中の 593 * HYBS_ITD_MARKER 文字列 と置き換えます。 594 * 595 * @og.rev 3.5.6.0 (2004/06/18) itdフォーマット文字列の取り込み 596 * 597 * @return itdフォーマットの文字列 598 */ 599 public String getItdBody() { 600 return itdBody; 601 } 602 603 /** 604 * サニタイズの戻し("\\]\\"から"["に戻し)を行います。 605 * 606 * @og.rev 5.1.7.0 (2010/06/01) 新規作成 607 * 608 * @param str サニタイズされた文字列 609 * 610 * @return サニタイズ戻し処理後の文字列 611 */ 612 private String decodeSanitizedStr( final String str ) { 613 // 6.4.1.1 (2016/01/16) PMD refactoring. A method should have only one exit point, and that should be the last statement in the method 614 return str != null && str.indexOf( "\\]\\" ) >= 0 ? str.replace( "\\]\\", "[" ) : str; 615 } 616}