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.StringUtil; 022 023 /** 024 * NBSP レンãƒ?ƒ©ãƒ¼ã¯ã€å?部ã®ã‚¹ãƒšã?スをã?  ã¨ã?†æ–?—å?ã«ç½®ãæ›ãˆã¾ã™ã? 025 * ã“れã¯ã€æ–‡å—å?ã«ã‚¹ãƒšã?スãŒå«ã¾ã‚Œã¦ã?‚‹å ´åˆã?  ã¨è¨?†ã‚³ãƒ¼ãƒ‰ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã™ã‚‹ã“ã¨ã§ã€? 026 * HTML 上ã§ã€??ç¶šã—ãŸã‚¹ãƒšã?スを表示ã—ã¾ã™ã? 027 * 通常ã€PRE レンãƒ?ƒ©ãƒ¼ã§è¡¨ç¤ºã™ã‚‹ãªã©ã®æ–¹æ³•ã‚‚ã‚りã¾ã™ãŒã€NBSP ã§ãªã?¨ã‚¹ãƒšã?ス㫠028 * ãªã‚‰ãªã??å?ãŸã¨ãˆã?ã€ã?ルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®ã‚ªãƒ—ションæ–?—å?ãªã©)ã«å¯¾å¿œã§ãã¾ã™ã? 029 * ã¾ãŸã?レンãƒ?ƒ©ãƒ¼ãƒ‘ラメータã«ã€æ•°å—ã‚’æŒ?®šã™ã‚Œã?ã€ãã®æ–?—æ•°ã§å¼·åˆ¶çš?« Fill埋ã‚ã™ã‚‹ãŸã‚ã€? 030 * 固定長ã®è¡¨ç¤ºã«ã‚‚使用ã§ãã¾ã™ã? 031 * ã“れã«ã‚ˆã‚Šã€??ç¶šã™ã‚‹ã‚¹ãƒšã?スをã?ãã?ã¾ã¾è¡¨ç¤ºã™ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã? 032 * 033 * カラãƒ??表示ã«å¿?¦ãªå±žæ?ã¯, DBColumn オブジェクãƒ?よりå–り出ã—ã¾ã™ã? 034 * ã“ã?クラスã¯ã€DBColumn オブジェクト毎ã«?‘ã¤ä½œæ?ã•れã¾ã™ã? 035 * 036 * @og.rev 3.7.1.0 (2005/04/26) æ–°è¦è¿½åŠ? 037 * @og.group ãƒ??タ表示 038 * 039 * @version 0.9.0 2000/10/17 040 * @author Kazuhiko Hasegawa 041 * @since JDK5.0, 042 */ 043 public class Renderer_NBSP extends AbstractRenderer { 044 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 045 private static final String VERSION = "4.0.0.0 (2005/08/31)" ; 046 047 private final int dataSize ; 048 049 /** 050 * ãƒ?ƒ•ォルトコンストラクターã€? 051 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã? 052 * 053 */ 054 public Renderer_NBSP() { 055 dataSize = 0; 056 } 057 058 /** 059 * ãƒ?ƒ•ォルトコンストラクターã€? 060 * 061 * @param clm DBColumnオブジェクãƒ? 062 */ 063 private Renderer_NBSP( final DBColumn clm ) { 064 String tmp = clm.getRendererParam(); 065 if( tmp == null || tmp.length() == 0 ) { dataSize = 0; } 066 else { 067 dataSize = Integer.parseInt( tmp ) ; 068 } 069 } 070 071 /** 072 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã? 073 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?« 074 * ã¾ã‹ã•れã¾ã™ã? 075 * 076 * @param clm DBColumnオブジェクãƒ? 077 * 078 * @return CellRendererオブジェクãƒ? 079 */ 080 public CellRenderer newInstance( final DBColumn clm ) { 081 return new Renderer_NBSP( clm ); 082 } 083 084 /** 085 * ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã? 086 * 087 * ã“ã“ã§ã¯ã€å?部ã®ã‚¹ãƒšã?スをã?  ã¨ã?†æ–?—å?ã«ç½®ãæ›ãˆã¾ã™ã? 088 * ã“れã«ã‚ˆã‚Šã€HTML 上ã§ã€??ç¶šã—ãŸã‚¹ãƒšã?スを表示ã§ãã¾ã™ã? 089 * ã¾ãŸã?レンãƒ?ƒ©ãƒ¼ãƒ‘ラメータã«ã€æ•°å—ã‚’æŒ?®šã™ã‚Œã?ã€ãã®æ–?—æ•°ã§å¼·åˆ¶çš?« Fill埋ã‚ã™ã‚‹ãŸã‚ã€? 090 * 固定長ã®è¡¨ç¤ºã«ã‚‚使用ã§ãã¾ã™ã? 091 * 092 * @param value 入力å? 093 * 094 * @return ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å? 095 */ 096 @Override 097 public String getValue( final String value ) { 098 String rtn = ( value == null ) ? "" : value ; 099 100 if( dataSize > 0 ) { 101 rtn = StringUtil.stringFill( rtn,dataSize,"Windows-31J" ); 102 } 103 104 return StringUtil.replace( rtn," "," " ); 105 } 106 }