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.hayabusa.db.Selection; 022// import org.opengion.hayabusa.db.Selection_RADIO; // 5.7.3.0 (2014/02/07) SelectionFactory を使う様に変更 023import org.opengion.hayabusa.db.SelectionFactory; // 5.7.3.0 (2014/02/07) 024 025/** 026 * RADIO レンデラーは、カラムのデータをコードリソースに対応したラジオボタンの 027 * 代替えラベルで表示する場合に使用するクラスです。 028 * 029 * カラムの表示に必要な属性は, DBColumn オブジェクト より取り出します。 030 * このクラスは、DBColumn オブジェクト毎に1つ作成されます。 031 * 032 * @og.rev 3.5.1.0 (2003/10/03) 新規作成 033 * @og.group データ表示 034 * 035 * @version 4.0 036 * @author Kazuhiko Hasegawa 037 * @since JDK5.0, 038 */ 039public class Renderer_RADIO extends AbstractRenderer { 040 //* このプログラムのVERSION文字列を設定します。 {@value} */ 041 private static final String VERSION = "5.7.3.0 (2014/02/07)" ; 042 043 private final Selection selection ; 044 045 /** 046 * デフォルトコンストラクター。 047 * このコンストラクターで、基本オブジェクトを作成します。 048 * 049 */ 050 public Renderer_RADIO() { 051 selection = null; 052 } 053 054 /** 055 * デフォルトコンストラクター。 056 * 057 * @og.rev 3.5.4.2 (2003/12/15) makeCodeSelection メソッドを CodeSelectionクラスに変更。 058 * @og.rev 3.5.5.7 (2004/05/10) SelectionFactory を使用して、オブジェクト作成 059 * @og.rev 4.0.0.0 (2005/01/31) SelectionFactory ではなく、直接 Selection_RADIO を作成。 060 * @og.rev 5.7.3.0 (2014/02/07) SelectionFactory 対応 061 * 062 * @param clm DBColumnオブジェクト 063 */ 064 private Renderer_RADIO( final DBColumn clm ) { 065 // 5.7.3.0 (2014/02/07) SelectionFactory 対応 066// selection = new Selection_RADIO( clm.getCodeData() ); // 4.0.0 (2005/01/31) 067 selection = SelectionFactory.newSelection( "RADIO" , clm.getCodeData() ); 068 } 069 070 /** 071 * 各オブジェクトから自分のインスタンスを返します。 072 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 073 * まかされます。 074 * 075 * @param clm DBColumnオブジェクト 076 * 077 * @return CellRendererオブジェクト 078 */ 079 public CellRenderer newInstance( final DBColumn clm ) { 080 return new Renderer_RADIO( clm ); 081 } 082 083 /** 084 * データの表示用文字列を返します。 085 * 086 * @param value 入力値 087 * 088 * @return データの表示用文字列 089 */ 090 @Override 091 public String getValue( final String value ) { 092 return "<pre class=\"RADIO\">" + 093 selection.getRadioLabel( value ) + 094 "</pre>" ; 095 } 096}