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.hayabusa.db.AbstractEditor; 019import org.opengion.hayabusa.db.CellEditor; 020import org.opengion.hayabusa.db.DBColumn; 021import org.opengion.fukurou.util.XHTMLTag; 022import org.opengion.hayabusa.common.HybsSystem; 023 024/** 025 * 先頭1文字目が、アンダーバー(_) の場合に、書込み禁止属性()を強制的に付与するクラスです。 026 * 027 * ・データベースに書き込むときには、通常のアンダーバー無しの文字列とします。 028 * 029 * このエディタはeventColumnに対応していません。 030 * 031 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 032 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 033 * 034 * @og.rev 3.0.0.4 (2003/02/26) 新規追加 035 * @og.group データ編集 036 * 037 * @version 4.0 038 * @author Kazuhiko Hasegawa 039 * @since JDK5.0, 040 */ 041public class Editor_WRITABLE extends AbstractEditor { 042 //* このプログラムのVERSION文字列を設定します。 {@value} */ 043 private static final String VERSION = "4.0.0.0 (2005/08/31)" ; 044 045 /** 046 * デフォルトコンストラクター。 047 * このコンストラクターで、基本オブジェクトを作成します。 048 * 049 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 050 * 051 */ 052 public Editor_WRITABLE() { 053 // 4.3.4.4 (2009/01/01) 054// super(); 055 } 056 057 /** 058 * コンストラクター。 059 * 060 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 061 * @og.rev 3.5.6.0 (2004/06/18) XHTMLTag の 内部配列 INPUT_KEY を隠蔽します。 062 * 063 * @param clm DBColumnオブジェクト 064 */ 065 private Editor_WRITABLE( final DBColumn clm ) { 066 super( clm ); 067 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 068 } 069 070 /** 071 * 各オブジェクトから自分のインスタンスを返します。 072 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 073 * まかされます。 074 * 075 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 076 * @og.rev 3.1.2.1 (2003/04/10) synchronized を、削除します。 077 * 078 * @param clm DBColumnオブジェクト 079 * 080 * @return CellEditorオブジェクト 081 */ 082 public CellEditor newInstance( final DBColumn clm ) { 083 return new Editor_WRITABLE( clm ); 084 } 085 086 /** 087 * データの編集用文字列を返します。 088 * 089 * @og.rev 3.5.4.2 (2003/12/15) 書込み禁止属性("_")のデータは,hidden で出力しておきます。 090 * @og.rev 3.5.5.5 (2004/04/23) hidden の出力に、XHTMLTag.hidden を使用します。 091 * 092 * @param value 入力値 093 * 094 * @return データの編集用文字列 095 */ 096 @Override 097 public String getValue( final String value ) { 098 099 if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 100 String val = value.substring( 1 ); 101 return val + XHTMLTag.hidden( name,val ); // 3.5.5.5 (2004/04/23) 102 } 103 104 return super.getValue( value ); 105 } 106 107 /** 108 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 109 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 110 * リクエスト情報を1つ毎のフィールドで処理できます。 111 * 112 * @og.rev 2.0.0.3 (2002/09/26) optionAttributes 属性に "$i" を使うとその行数に置き換る機能を追加。 113 * @og.rev 3.5.4.2 (2003/12/15) 書込み禁止属性("_")のデータは,hidden で出力しておきます。 114 * @og.rev 3.5.5.0 (2004/03/12) 名前と行番号の区切り記号("__")を、HybsSystem.JOINT_STRING に変更。 115 * @og.rev 3.5.5.5 (2004/04/23) hidden の出力に、XHTMLTag.hidden を使用します。 116 * 117 * @param row 行番号 118 * @param value 入力値 119 * 120 * @return データ表示/編集用の文字列 121 */ 122 @Override 123 public String getValue( final int row,final String value ) { 124 125 if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 126 String val = value.substring( 1 ); 127 String nm = name + HybsSystem.JOINT_STRING + row; 128 return val + XHTMLTag.hidden( nm,val ); // 3.5.5.5 (2004/04/23) 129 } 130 131 return super.getValue( row,value ); 132 } 133}