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.db; 017 018import org.opengion.fukurou.util.StringUtil ; // 6.2.0.0 (2015/02/27) 019import org.opengion.fukurou.system.HybsConst ; // 6.1.0.0 (2014/12/26) 020 021/** 022 * DBCell の具象クラスで、カラムのデータを表示する場合に使用するクラスです。 023 * 024 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 025 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 026 * 027 * @og.group データ表示 028 * 029 * @version 4.0 030 * @author Kazuhiko Hasegawa 031 * @since JDK5.0, 032 */ 033public abstract class AbstractRenderer implements CellRenderer { 034 /** システムの改行コードを設定します。*/ 035 protected static final String CR = HybsConst.CR; // 6.1.0.0 (2014/12/26) refactoring 036 /** StringBilderなどの初期値を設定します。 {@value} */ 037 protected static final int BUFFER_MIDDLE = HybsConst.BUFFER_MIDDLE; // 6.1.0.0 (2014/12/26) refactoring 038 039 /** 040 * デフォルトコンストラクター 041 * 042 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 043 */ 044 protected AbstractRenderer() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 045 046 /** 047 * データの表示用文字列を返します。 048 * 049 * @og.rev 6.0.4.0 (2014/11/28) ロジックの共通化 050 * 051 * @param value 入力値 052 * 053 * @return データの表示用文字列 054 * @og.rtnNotNull 055 */ 056 public String getValue( final String value ) { 057 return value==null ? "" : value ; // 6.0.4.0 (2014/11/28) ロジックの共通化 058 } 059 060 /** 061 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 062 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 063 * リクエスト情報を1つ毎のフィールドで処理できます。 064 * 065 * @param row 行番号 066 * @param value 入力値 067 * 068 * @return データ表示/編集用の文字列 069 * @og.rtnNotNull 070 * @see #getValue( String ) 071 */ 072 public String getValue( final int row,final String value ) { 073 return getValue( value ); 074 } 075 076 /** 077 * name属性を変えた、データ表示用のHTML文字列を作成します。 078 * レンデラーのため、row(行番号)は使いません。 079 * 第3引数に、パラメータを渡すことが出来ます。これは、viewMarker で 080 * [$XXXX param] 形式を渡すことで、行単位に表示形式を変更できます。 081 * AbstractRenderer では、#getValue( String ) を呼び出しています。 082 * 083 * @og.rev 6.8.3.1 (2017/12/01) パラメータを渡せるようにします。 084 * 085 * @param row 行番号 086 * @param value 値 087 * @param param パラメータ 088 * 089 * @return データ表示/編集用の文字列 090 */ 091 public String getValue( final int row,final String value,final String param ) { 092 return getValue( value ); 093 } 094 095 /** 096 * データ出力用の文字列を作成します。 097 * ファイル等に出力する形式を想定しますので、HTMLタグを含まない 098 * データを返します。 099 * 基本は、#getValue( String ) をそのまま返します。 100 * 101 * @og.rev 6.0.4.0 (2014/11/28) データ出力用のレンデラー 102 * @og.rev 6.2.0.0 (2015/02/27) StringUtil#spanCut(String) を入れます。 103 * @og.rev 6.2.4.2 (2015/05/29) StringUtil#spanCut(String) → StringUtil#tagCut(String) に変更します。 104 * 105 * @param value 入力値 106 * 107 * @return データ出力用の文字列 108 * @og.rtnNotNull 109 * @see #getValue( String ) 110 */ 111 public String getWriteValue( final String value ) { 112 return StringUtil.tagCut( getValue( value ) ); // 6.2.4.2 (2015/05/29) 113 } 114}