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.hayabusa.db; 017 018 import org.opengion.hayabusa.common.HybsSystem; 019 import org.opengion.hayabusa.common.HybsSystemException; 020 import org.opengion.hayabusa.resource.CodeData; 021 022 /** 023 * ãƒ??ã‚¿ã®ã‚³ãƒ¼ãƒ‰æƒ…å ±ã‚’å–り扱ã?‚¯ãƒ©ã‚¹ã§ã™ã? 024 * 025 * コードã?ã‚ーã¨ãƒ©ãƒ™ãƒ«ã®æƒ??ã‹ã‚‰ã€HTMLã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚?ƒªã‚¹ãƒˆã‚’作æ?ã™ã‚‹ãŸã‚㮠オプション 026 * タグを作æ?ã—ãŸã‚Šã?与ãˆã‚‰ã‚ŒãŸã‚ーをもã¨ã«ã€ãƒã‚§ãƒ?‚¯æ¸ˆã¿ã®ã‚ªãƒ—ションタグを作æ?ã—ãŸã‚? 027 * ã—ã¾ã™ã? 028 * 029 * @og.group é¸æŠžãƒ‡ãƒ¼ã‚¿åˆ¶å¾¡ 030 * 031 * @version 4.0 032 * @author Kazuhiko Hasegawa 033 * @since JDK5.0, 034 */ 035 public class Selection_RADIO implements Selection { 036 private final CodeData codeData ; 037 038 /** 039 * コンストラクター 040 * 041 * @param cdData コードデータオブジェクãƒ? 042 * 043 */ 044 public Selection_RADIO( final CodeData cdData ) { 045 if( cdData == null ) { 046 String errMsg = "コードリソースãŒå®šç¾©ã•れã¦ã?¾ã›ã‚“ã€? + HybsSystem.CR ; 047 throw new HybsSystemException( errMsg ); 048 } 049 050 codeData = cdData ; 051 } 052 053 /** 054 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 055 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 056 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 057 * 058 * @og.rev 3.6.0.6 (2004/10/22) シーケンスアクセス機è?を指定ã™ã‚?seqFlag ã‚’å°Žå? 059 * 060 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 061 * @param seqFlag シーケンスアクセス機è?ã®æŒ?®? 062 * 063 * @return オプションタグ 064 */ 065 public String getOption( final String selectValue,final boolean seqFlag ) { 066 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 067 throw new UnsupportedOperationException( errMsg ); 068 } 069 070 /** 071 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 072 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 073 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 074 * 075 * @og.rev 5.1.3.0 (2010/02/01) 追åŠ? 076 * 077 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 078 * @param seqFlag シーケンスアクセス機è?ã®æŒ?®? 079 * @param useShortLabel çŸãƒ©ãƒ™ãƒ«ã®æŒ?®? 080 * 081 * @return オプションタグ 082 */ 083 public String getOption( final String selectValue,final boolean seqFlag, final boolean useShortLabel ) { 084 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 085 throw new UnsupportedOperationException( errMsg ); 086 } 087 088 /** 089 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 090 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 091 * 092 * @og.rev 2.1.0.1 (2002/10/17) é¸æŠžãƒªã‚¹ãƒˆã‚’ã€æ£æ–¹å‘ã«ã—ã‹é¸ã¹ãªã?‚ˆã?«ã™ã‚‹ sequenceFlag ã‚’å°Žå?ã™ã‚‹ 093 * @og.rev 3.5.6.3 (2004/07/12) ã‚ャãƒ?‚·ãƒ¥ã‚’利用ã›ãšæ¯Žå›žã‚¿ã‚°ã‚’ä½œæ?ã—ã¾ã™ã? 094 * @og.rev 3.8.6.0 (2006/09/29) useLabel 属æ? 追åŠ? 095 * 096 * @param name ラジオ㮠name 097 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 098 * @param useLabel ãƒ©ãƒ™ãƒ«è¡¨ç¤ºã®æœ‰ç„¡ [true:æœ?false:ç„¡] 099 * 100 * @return オプションタグ 101 */ 102 public String getRadio( final String name,final String selectValue,final boolean useLabel ) { 103 String inputTag = "<input type=\"radio\" name=\"" + name + "\" value=\"" ; 104 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_LARGE ); 105 int size = codeData.getSize(); 106 for( int i=0; i<size; i++ ) { 107 String value = codeData.getCodeKey(i); 108 if( useLabel ) { buf.append( "<label>" ); } 109 buf.append( inputTag ).append( value ).append( "\"" ); 110 if( value.equals( selectValue ) ) { 111 buf.append( " checked=\"checked\"" ); 112 } 113 buf.append( "/>" ); 114 if( useLabel ) { buf.append( codeData.getShortLabel(i) ).append( "</label>" ); } 115 } 116 return buf.toString(); 117 } 118 119 /** 120 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 121 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 122 * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã? 123 * 124 * @param selectValue é¸æŠžè‚¢ã®å€¤ 125 * 126 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 127 * @see #getValueLabel( String,boolean ) 128 */ 129 public String getValueLabel( final String selectValue ) { 130 return getValueLabel( selectValue,false ); 131 } 132 133 /** 134 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 135 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 136 * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã‚’è¿”ã™ã‹ã©ã?‹ã‚’指定ã™ã‚‹ãƒ•ラグを指定ã—ã¾ã™ã? 137 * getValueLabel( XX,false ) ã¯ã€getValueLabel( XX ) ã¨åŒã˜ã§ã™ã? 138 * 139 * @og.rev 4.0.0.0 (2005/11/30) を追åŠ? 140 * 141 * @param selectValue é¸æŠžè‚¢ã®å€¤ 142 * @param flag çŸç¸®ãƒ©ãƒ™ãƒ«ã‚’使用ã™ã‚‹ [true:使用ã™ã‚‹/false:ã—ãªã„] 143 * 144 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 145 * @see #getValueLabel( String ) 146 */ 147 public String getValueLabel( final String selectValue,final boolean flag ) { 148 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã? 149 int selected = codeData.getAddress( selectValue ); 150 151 if( selected < 0 ) { 152 // マッãƒã—ãªã‘れã°ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã™ã€? 153 return selectValue; 154 } 155 else { 156 if( flag ) { 157 return codeData.getShortLabel(selected); 158 } 159 else { 160 return codeData.getLongLabel(selected); 161 } 162 } 163 } 164 165 /** 166 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 167 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 168 * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã? 169 * 170 * @param selectValue é¸æŠžè‚¢ã®å€¤ 171 * 172 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 173 * @see #getValueLabel( String,boolean ) 174 */ 175 public String getRadioLabel( final String selectValue ) { 176 177 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 178 int size = codeData.getSize(); 179 for( int i=0; i<size; i++ ) { 180 String value = codeData.getCodeKey(i); 181 if( value.equals( selectValue ) ) { 182 rtn.append( "â—? ); // (2003/10/08 ä¿®æ£åˆ? 183 } 184 else { 185 rtn.append( "ã€? ); // (2003/10/08 ä¿®æ£åˆ? 186 } 187 } 188 189 return rtn.toString(); 190 } 191 192 /** 193 * マルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã? 194 * true?šä½¿ç”¨ã™ã‚‹ã€‚false:使用ã—ãªã?ã§ã™ã? 195 * ãŸã ã—ã?実際ã«ä½¿ç”¨ã™ã‚‹ã‹ã©ã?‹ã¯ã€HTMLå‡ºåŠ›æ™‚ã«æ±ºã‚ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã? 196 * ã“ã“ã§ã¯ã€USE_MULTI_KEY_SELECT ã?true ã§ã€USE_SIZE(=20)以上ã?å ´åˆã« 197 * true ã‚’è¿”ã—ã¾ã™ã? 198 * 199 * @og.rev 3.5.5.7 (2004/05/10) æ–°è¦ä½œæ? 200 * 201 * @return é¸æŠžãƒªã‚¹ãƒˆã§ã€ã?ルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹) 202 */ 203 public boolean useMultiSelect() { 204 return false; 205 } 206 207 /** 208 * オブジェクトã?ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã? 209 * ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?ã‚?無効)ã§ã‚れã°ã€true ã‚’ã?有効ã§ã‚れã°ã€? 210 * false ã‚’è¿”ã—ã¾ã™ã? 211 * 212 * @og.rev 4.0.0.0 (2005/01/31) æ–°è¦ä½œæ? 213 * 214 * @return ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れãªã‚?true 215 */ 216 public boolean isTimeOver() { 217 return false; 218 } 219 }