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 */
016 package org.opengion.plugin.column;
017
018 import org.opengion.hayabusa.db.AbstractRenderer;
019 import org.opengion.hayabusa.db.CellRenderer;
020 import org.opengion.hayabusa.db.DBColumn;
021 import org.opengion.fukurou.util.StringFormat;
022
023 /**
024 * FORM レンãƒ?ƒ©ーは、表示パラメータでæŒ?®šされた FORM を表示するクラスでã€?
025 * å…??Value をã?$1 として、使用可能ですã?
026 * (コロンで区åˆ?‚‰れた値の表示のコントロールを行うレンãƒ?ƒ©ーでã�?
027 *
028 * カラãƒ??表示にå¿?¦�な属æ?は, DBColumn オブジェクãƒ?より取り出しますã?
029 * こã?クラスは、DBColumn オブジェクト毎に?‘つ作æ?されますã?
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 */
039 public 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 }