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 054 /** 055 * コンストラクター。 056 * 057 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 058 * @og.rev 3.5.6.0 (2004/06/18) XHTMLTag の 内部配列 INPUT_KEY を隠蔽します。 059 * 060 * @param clm DBColumnオブジェクト 061 */ 062 private Editor_WRITABLE( final DBColumn clm ) { 063 super( clm ); 064 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 065 } 066 067 /** 068 * 各オブジェクトから自分のインスタンスを返します。 069 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 070 * まかされます。 071 * 072 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 073 * @og.rev 3.1.2.1 (2003/04/10) synchronized を、削除します。 074 * 075 * @param clm DBColumnオブジェクト 076 * 077 * @return CellEditorオブジェクト 078 */ 079 public CellEditor newInstance( final DBColumn clm ) { 080 return new Editor_WRITABLE( clm ); 081 } 082 083 /** 084 * データの編集用文字列を返します。 085 * 086 * @og.rev 3.5.4.2 (2003/12/15) 書込み禁止属性("_")のデータは,hidden で出力しておきます。 087 * @og.rev 3.5.5.5 (2004/04/23) hidden の出力に、XHTMLTag.hidden を使用します。 088 * 089 * @param value 入力値 090 * 091 * @return データの編集用文字列 092 */ 093 @Override 094 public String getValue( final String value ) { 095 096 if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 097 String val = value.substring( 1 ); 098 return val + XHTMLTag.hidden( name,val ); // 3.5.5.5 (2004/04/23) 099 } 100 101 return super.getValue( value ); 102 } 103 104 /** 105 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 106 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 107 * リクエスト情報を1つ毎のフィールドで処理できます。 108 * 109 * @og.rev 2.0.0.3 (2002/09/26) optionAttributes 属性に "$i" を使うとその行数に置き換る機能を追加。 110 * @og.rev 3.5.4.2 (2003/12/15) 書込み禁止属性("_")のデータは,hidden で出力しておきます。 111 * @og.rev 3.5.5.0 (2004/03/12) 名前と行番号の区切り記号("__")を、HybsSystem.JOINT_STRING に変更。 112 * @og.rev 3.5.5.5 (2004/04/23) hidden の出力に、XHTMLTag.hidden を使用します。 113 * 114 * @param row 行番号 115 * @param value 入力値 116 * 117 * @return データ表示/編集用の文字列 118 */ 119 @Override 120 public String getValue( final int row,final String value ) { 121 122 if( value != null && value.length() >= 1 && value.charAt(0) == '_' ) { 123 String val = value.substring( 1 ); 124 String nm = name + HybsSystem.JOINT_STRING + row; 125 return val + XHTMLTag.hidden( nm,val ); // 3.5.5.5 (2004/04/23) 126 } 127 128 return super.getValue( row,value ); 129 } 130}