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.AbstractRenderer; 019import org.opengion.hayabusa.db.CellRenderer; 020import org.opengion.hayabusa.db.DBColumn; 021import org.opengion.fukurou.util.StringFormat; 022 023/** 024 * FORM レンデラーは、表示パラメータで指定された FORM を表示するクラスで、 025 * 元のValue を、$1 として、使用可能です。 026 * (コロンで区切られた値の表示のコントロールを行うレンデラーです) 027 * 028 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 029 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 030 * 031 * @og.rev 2.1.1.1 (2002/11/15) FORM レンデラーを新規追加しました。 032 * @og.rev 5.4.2.6 (2012/01/19) コメント修正 033 * @og.group データ表示 034 * 035 * @version 4.0 036 * @author Kazuhiko Hasegawa 037 * @since JDK5.0, 038 */ 039public class Renderer_FORM extends AbstractRenderer { 040 //* このプログラムのVERSION文字列を設定します。 {@value} */ 041 private static final String VERSION = "5.4.2.6 (2012/01/19)" ; 042 043 private final String form ; 044 private final String name ; 045 046 /** 047 * デフォルトコンストラクター。 048 * このコンストラクターで、基本オブジェクトを作成します。 049 * 050 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 051 * 052 */ 053 public Renderer_FORM() { 054 form = null; 055 name = null; // 4.3.4.0 (2008/12/01) 056 } 057 058 /** 059 * デフォルトコンストラクター。 060 * 061 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 062 * @og.rev 3.4.0.0 (2003/09/01) 表示パラメータ、編集パラメータ、文字パラメータの追加。 063 * @og.rev 3.8.8.2 (2007/01/26) StringFormat の $0 対応。 064 * 065 * @param clm DBColumnオブジェクト 066 */ 067 private Renderer_FORM( final DBColumn clm ) { 068 String tmp = clm.getRendererParam(); 069 if( tmp == null || tmp.length() == 0 ) { tmp = "$0"; } // 3.8.8.2 (2007/01/26) 070 form = tmp ; 071 name = clm.getName(); // 4.3.4.0 (2008/12/01) 072 } 073 074 /** 075 * 各オブジェクトから自分のインスタンスを返します。 076 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 077 * まかされます。 078 * 079 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 080 * @og.rev 3.1.2.1 (2003/04/10) synchronized を、削除します。 081 * 082 * @param clm DBColumnオブジェクト 083 * 084 * @return CellRendererオブジェクト 085 */ 086 public CellRenderer newInstance( final DBColumn clm ) { 087 return new Renderer_FORM( clm ); 088 } 089 090 /** 091 * データの表示用文字列を返します。 092 * 093 * ここでは、AAA:BBB:CCC:DDD という値を、$1,$2,$3,$4 に割り当てなおして、 094 * QUERYを実行します。また、$1 は、本来の値として、メニューの初期値設定等に 095 * 使用します。上記の例では、AAA が値で、それ以降は、引数になります。 096 * さらに、元の文字列"AAA:BBB:CCC:DDD"は、$0 に割り当てられます。割り当てがない 097 * 変数は、""(ゼロ文字列)として、扱われます。 098 * 099 * @og.rev 3.4.0.2 (2003/09/05) AAA:BBB:CCC:DDD という値を、$1,$2,$3,$4 に割り当てます。 100 * @og.rev 4.3.4.0 (2008/12/01) $Cのカラム名置換えを追加 101 * 102 * @param value 入力値 103 * 104 * @return データの表示用文字列 105 */ 106 @Override 107 public String getValue( final String value ) { 108 // StringFormat format = new StringFormat( form,value ); 109 StringFormat format = new StringFormat( form, value, name ); // 4.3.4.0 (2008/12/01) 110 return format.format(); 111 } 112}