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.plugin.column; 017 018import org.opengion.fukurou.util.StringUtil; 019// import org.opengion.hayabusa.db.AbstractRenderer; 020import org.opengion.hayabusa.db.CellRenderer; 021import org.opengion.hayabusa.db.DBColumn; 022 023/** 024 * RICHLABEL レンデラは、特殊文字のエスケープを元に戻して表示する場合に 025 * 使用するクラスです。 026 * readonlyのテキストエリアでname属性は付けません。(データは送信されません) 027 * 028 * 属性値に1以上の数値を指定した場合はSLABELと同等の処理を行います。 029 * その際に、有効なタグについては除外して表示します。(一覧表示用) 030 * 031 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 032 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 033 * 034 * @og.rev 5.9.33.0 (2018/06/01) 新規作成 035 * @og.rev 5.10.1.0 (2018/06/29) IGNORE_STRに値を追加。 036 * @og.group データ編集 037 * 038 * @version 5.9.33.0 039 * @author T.OTA 040 * @since JDK7.0, 041 */ 042// public class Renderer_RICHLABEL extends AbstractRenderer { 043public class Renderer_RICHLABEL extends Renderer_SLABEL { 044 /** このプログラムのVERSION文字列を設定します。 {@value} */ 045 private static final String VERSION = "7.0.1.2 (2018/11/04)" ; 046 047 private static final CellRenderer DB_CELL = new Renderer_RICHLABEL(); 048 049 // 2018/06/28 MODIFY pre,img,table,thead,tbody,tr,th,td,ul,li,h[数値]を追加 050// private static final String IGNORE_STR = "strong|font|a|br|p|span|div"; 051 private static final String IGNORE_STR = "strong|font|a|br|p|span|div|pre|img|table|thead|tbody|tr|th|td|ul|li|h\\d"; 052 053 // 7.0.1.2 (2018/11/04) Renderer_RICHLABELか、Renderer_SLABEL の判定用フラグ 054 private final boolean isRichLabel ; 055 056 /** 057 * デフォルトコンストラクター。 058 * このコンストラクターで、基本オブジェクトを作成します。 059 * 060 */ 061 public Renderer_RICHLABEL() { 062 super(); 063 isRichLabel = true; 064 } 065 066 /** 067 * DBColumnオブジェクトを指定したprivateコンストラクター。 068 * 069 * @og.rev 7.0.1.2 (2018/11/04) 出力文字数指定対応 070 * 071 * @param size カットサイズ 072 */ 073 private Renderer_RICHLABEL( final String size ) { 074 super( size ); 075 isRichLabel = false; 076 } 077 078 /** 079 * 各オブジェクトから自分のインスタンスを返します。 080 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 081 * まかされます。 082 * 083 * 属性値に1以上の数値を指定した場合はSLABELと同等の処理を行います。 084 * その際に、有効なタグについては除外して表示します。(一覧表示用) 085 * 086 * @og.rev 5.10.4.2 (2018/10/19) 出力文字数指定対応 087 * 088 * @param clm DBColumnオブジェクト 089 * 090 * @return CellEditorオブジェクト 091 */ 092 @Override 093 public CellRenderer newInstance( final DBColumn clm ) { 094// return DB_CELL; 095 // return dbCell; 096 final String param = clm.getRendererParam(); 097 098 if( param != null && param.length() > 0 && !"0".equals( param ) ) { // 1以上の数値 → 0以外の数値 099 return new Renderer_RICHLABEL( param ); // カットサイズ指定 のインスタンス 100 } 101 else { 102 return DB_CELL; 103 } 104 } 105 106 /** 107 * データの表示用文字列を返します。 108 * 109 * @param value 入力値 110 * 111 * @return データの表示用文字列 112 */ 113 @Override 114 public String getValue( final String value ) { 115// return StringUtil.escapeFilter( value,IGNORE_STR ); 116 117 final String escStr = StringUtil.escapeFilter( value,IGNORE_STR ); 118 119 return isRichLabel ? escStr : super.getValue( escStr ); 120 } 121}