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.fukurou.util.LogWriter; 019 import org.opengion.fukurou.util.StringUtil; 020 021 import org.opengion.hayabusa.common.HybsSystem; 022 import org.opengion.hayabusa.resource.CodeData; 023 024 /** 025 * ãƒ??ã‚¿ã®ã‚³ãƒ¼ãƒ‰æƒ…å ±ã‚’å–り扱ã?‚¯ãƒ©ã‚¹ã§ã™ã? 026 * 027 * æ–?—å?㮠「ã‚ー:ラベル ã‚ー:ラベルã€ã?æƒ??ã‹ã‚‰ã€HTMLã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚?ƒªã‚¹ãƒˆã‚’作æ?ã™ã‚‹ãŸã‚ã® 028 * オプションタグを作æ?ã—ãŸã‚Šã?与ãˆã‚‰ã‚ŒãŸã‚ーをもã¨ã«ã€ãƒã‚§ãƒ?‚¯æ¸ˆã¿ã®ã‚ªãƒ—ションタグã‚? 029 * 作æ?ã—ãŸã‚Šã—ã¾ã™ã? 030 * ラベル ã«ã‚¹ãƒšã?スをå«ã¾ã›ã‚‹å ´åˆã?ã€ãƒ€ãƒ–ルクォーãƒ??ションã§å›²ã£ã¦ãã ã•ã„ã€? 031 * 032 * @og.rev 5.6.6.0 (2013/07/05) æ–°è¦è¿½åŠ? 033 * @og.group é¸æŠžãƒ‡ãƒ¼ã‚¿åˆ¶å¾¡ 034 * 035 * @version 4.0 036 * @author Kazuhiko Hasegawa 037 * @since JDK5.0, 038 */ 039 public class Selection_KEYVAL implements Selection { 040 private final String ORG_KEYVAL ; 041 042 private final String CACHE ; 043 044 /** 045 * コンストラクター 046 * 047 * @og.rev 5.6.7.1 (2013/08/09) 「ã‚ー:ラベル ã‚ー:ラベルã€å?è§£ã«ã€ã‚¯ã‚ªãƒ¼ãƒˆå?ç?‚’åŠ?‘³ 048 * 049 * @param strCode コードデータパラメータæ–?—å? 050 */ 051 public Selection_KEYVAL( final String strCode ) { 052 ORG_KEYVAL = strCode ; 053 054 if( strCode != null && strCode.indexOf( ':' ) > 0 ) { 055 // String[] keyvals = strCode.split( " " ); // 「ã‚ー:ラベル ã‚ー:ラベルã€?ã‚’ã?ã‚ー:ラベル ã®é…å?ã«åˆ?§£ã™ã‚‹ã€? 056 String[] keyvals = StringUtil.csv2Array( strCode, ' ' ); // 5.6.7.1 (2013/08/09) クオートå?ç?‚’åŠ?‘³ 057 int size = keyvals.length; 058 059 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 060 for( int i=0; i<size; i++ ) { 061 String keyval = keyvals[i] ; 062 int idx ; 063 if( keyval == null || keyval.length() <= 0 || (idx = keyval.indexOf( ':' )) < 0 ) { continue; } // スペã?スã§åˆ?§£ã—ãŸçµæžœ 064 065 String key = keyval.substring( 0,idx ).trim(); 066 String val = keyval.substring( idx+1 ).trim(); 067 068 // 5.6.7.1 (2013/08/09) クオートå?ç?‚’åŠ?‘³ã€‚csv2Array ã§ã¯ã€ã‚¯ã‚ªãƒ¼ãƒˆã?残ã£ãŸã¾ã¾ã§ã‚ã‚‹ã€? 069 if( val.length() >= 2 && val.charAt(0) == '"' && val.charAt(val.length()-1) == '"' ) { 070 // å‰å¾Œã? クオーãƒ?ã‚’å–り除ãã?ã•らã«ã€ãã®çµæžœã‚?trim ã™ã‚‹ã€? 071 val = val.substring( 1,val.length()-1 ).trim(); 072 } 073 074 buf.append( "<option value=\"" ).append( key ).append( "\"" ); 075 buf.append( ">" ).append( val ).append( "</option>" ); 076 } 077 078 CACHE = buf.toString(); 079 } 080 else { 081 CACHE = ""; 082 } 083 } 084 085 /** 086 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 087 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 088 * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€ãƒ©ãƒ™ãƒ«(çŸ)ãŒè¨å®šã•れã¦ã?‚‹å ´åˆã§ã‚‚ã?ã“れを使用ã›ãšã«å¿?šãƒ©ãƒ™ãƒ«(é•·)を使用ã—ã¾ã™ã? 089 * 090 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 091 * @param seqFlag シーケンスアクセス機è? [true:ON/false:OFF] 092 * 093 * @return オプションタグ 094 * @see #getOption( String, boolean, boolean ) 095 */ 096 public String getOption( final String selectValue,final boolean seqFlag ) { 097 return getOption( selectValue, seqFlag, false ); 098 } 099 100 /** 101 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 102 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 103 * <del>ã“ã?メソãƒ?ƒ‰ã§ã¯ã€å¼•æ•°ã®useShortLabelãŒtrueã«æŒ?®šã•れãŸå ´åˆã«ã€ãƒ©ãƒ™ãƒ«(çŸ)ã‚’ã?ースã¨ã—㟠104 * ãƒ??ルãƒãƒƒãƒ—表示を行ã„ã¾ã™ã?</del> 105 * ã“ã?クラスã§ã¯ã€useShortLabel ã¯ã€ç„¡è¦–ã•れã¾ã™ã?(常ã«ã€false ã§ã? 106 * 107 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 108 * @param seqFlag シーケンスアクセス機è? [true:ON/false:OFF] 109 * @param useShortLabel ラベル(çŸ)ã‚’ã?ースã¨ã—ãŸã‚ªãƒ—ション表示を行ã†ã‹ã©ã?‹(常ã«false)ã€? 110 * 111 * @return オプションタグ 112 * @see #getOption( String, boolean ) 113 */ 114 public String getOption( final String selectValue,final boolean seqFlag, final boolean useShortLabel ) { 115 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã?ã‚ーã®å‰å¾Œã?ãƒ?ƒ–ルクオートをåŠ?‘³ã—ã¦æ¤œç´¢ 116 String selVal = "\"" + selectValue + "\"" ; 117 118 int indx = CACHE.indexOf( selVal ); 119 120 if( indx < 0 ) { 121 // 4.0.0 (2005/01/31) 122 if( selectValue != null && selectValue.length() > 0 ) { 123 String errMsg = "コードã«å˜åœ¨ã—ãªã??ãŒæŒ‡å®šã•れã¾ã—ãŸã€? 124 + " value=[" + selectValue + "]" 125 + HybsSystem.CR + ORG_KEYVAL ; 126 LogWriter.log( errMsg ); 127 } 128 return CACHE; 129 } 130 else { 131 int addIndx = indx + (selVal.length()) ; // selected ã®æŒ¿å…¥ä½ç½® 132 133 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 134 // 3.6.0.6 (2004/10/22) シーケンスアクセス機è?を指定ã™ã‚?seqFlag ã‚’å°Žå? 135 if( seqFlag ) { 136 buf.append( "<option value=\"" ).append( selectValue ).append( "\"" ); 137 } 138 else { 139 buf.append( CACHE.substring( 0,addIndx ) ); 140 } 141 buf.append( " selected=\"selected\"" ); 142 buf.append( CACHE.substring( addIndx ) ); 143 return buf.toString() ; 144 } 145 } 146 147 /** 148 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 149 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 150 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 151 * 152 * @param name ラジオ㮠name 153 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 154 * @param useLabel ãƒ©ãƒ™ãƒ«è¡¨ç¤ºã®æœ‰ç„¡ [true:æœ?false:ç„¡] 155 * 156 * @return オプションタグ 157 */ 158 public String getRadio( final String name,final String selectValue,final boolean useLabel ) { 159 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 160 throw new UnsupportedOperationException( errMsg ); 161 } 162 163 /** 164 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 165 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 166 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 167 * 168 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 169 * 170 * @return オプションタグ 171 */ 172 public String getRadioLabel( final String selectValue ) { 173 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 174 throw new UnsupportedOperationException( errMsg ); 175 } 176 177 /** 178 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 179 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 180 * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã? 181 * 182 * @param selectValue é¸æŠžè‚¢ã®å€¤ 183 * 184 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 185 * @see #getValueLabel( String,boolean ) 186 */ 187 public String getValueLabel( final String selectValue ) { 188 return getValueLabel( selectValue,false ); 189 } 190 191 /** 192 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 193 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 194 * <del>ã“ã?メソãƒ?ƒ‰ã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã‚’è¿”ã™ã‹ã©ã?‹ã‚’指定ã™ã‚‹ãƒ•ラグを指定ã—ã¾ã™ã?</del> 195 * getValueLabel( XX,false ) ã¯ã€getValueLabel( XX ) ã¨åŒã˜ã§ã™ã? 196 * 197 * ※ ã“ã?クラスã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã¯ä½¿ç”¨ã•れã¾ã›ã‚“ã€? 198 * 199 * @param selectValue é¸æŠžè‚¢ã®å€¤ 200 * @param flag çŸç¸®ãƒ©ãƒ™ãƒ«ã‚?[true:使用ã™ã‚‹/false:ã—ãªã„](常㫠false) 201 * 202 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 203 * @see #getValueLabel( String ) 204 */ 205 public String getValueLabel( final String selectValue,final boolean flag ) { 206 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã?ã‚ーã®å‰å¾Œã?ãƒ?ƒ–ルクオートをåŠ?‘³ã—ã¦æ¤œç´¢ 207 String selVal = "\"" + selectValue + "\"" ; 208 209 int indx = CACHE.indexOf( selVal ); 210 211 if( indx < 0 ) { 212 // マッãƒã—ãªã‘れã°ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã™ã€? 213 return selectValue; 214 } 215 else { 216 // マッãƒã™ã‚Œã?ã€ã‚ー以下ã?BODYéƒ¨ã®æ–?—å?ã‚’å?りå?ã—ã¦è¿”ã™ã€? 217 int stIdx = indx + (selVal.length()) + 1 ; // ?‹ï¼?ã¯ã€?>" ã®ä½ç½® 218 int edIdx = CACHE.indexOf( '<',stIdx ); // 終äº?‚¢ãƒ‰ãƒ¬ã‚¹ 219 220 return CACHE.substring( stIdx,edIdx ); 221 } 222 } 223 224 /** 225 * マルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã? 226 * true?šä½¿ç”¨ã™ã‚‹ã€‚false:使用ã—ãªã?ã§ã™ã? 227 * ãŸã ã—ã?実際ã«ä½¿ç”¨ã™ã‚‹ã‹ã©ã?‹ã¯ã€HTMLå‡ºåŠ›æ™‚ã«æ±ºã‚ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã? 228 * ã“ã“ã§ã¯ã€USE_MULTI_KEY_SELECT ã?true ã§ã€USE_SIZE(=20)以上ã?å ´åˆã« 229 * true ã‚’è¿”ã—ã¾ã™ã? 230 * 231 * ※ ã“ã“ã§ã¯ã€å¸¸ã« false ã‚’è¿”ã—ã¾ã™ã? 232 * 233 * @return é¸æŠžãƒªã‚¹ãƒˆã§ã€ã?ルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹) 234 */ 235 public boolean useMultiSelect() { 236 return false; 237 } 238 239 /** 240 * オブジェクトã?ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã? 241 * ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?ã‚?無効)ã§ã‚れã°ã€true ã‚’ã?有効ã§ã‚れã°ã€? 242 * false ã‚’è¿”ã—ã¾ã™ã? 243 * 244 * ※ ã“ã“ã§ã¯ã€å¸¸ã« false ã‚’è¿”ã—ã¾ã™ã? 245 * 246 * @return ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れãªã‚?true 247 */ 248 public boolean isTimeOver() { 249 return false; 250 } 251 }