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.fukurou.util.LogWriter; 020 import org.opengion.hayabusa.resource.CodeData; 021 022 /** 023 * ãƒ??ã‚¿ã®ã‚³ãƒ¼ãƒ‰æƒ…å ±ã‚’å–り扱ã?‚¯ãƒ©ã‚¹ã§ã™ã? 024 * 025 * é–‹å§‹ã?終äº??スãƒ?ƒƒãƒ—ã?æƒ??ã‹ã‚‰ã€HTMLã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚?ƒªã‚¹ãƒˆã‚’作æ?ã™ã‚‹ãŸã‚㮠オプション 026 * タグを作æ?ã—ãŸã‚Šã?与ãˆã‚‰ã‚ŒãŸã‚ーをもã¨ã«ã€ãƒã‚§ãƒ?‚¯æ¸ˆã¿ã®ã‚ªãƒ—ションタグを作æ?ã—ãŸã‚Šã—ã¾ã™ã? 027 * 028 * ã“ã“ã§ã¯ã€æ•°å—(é?番?‰ã?自動生æˆã‚’行ã„ã¾ã™ã?パラメータã§ã€?–‹å§‹ã?終äº??スãƒ?ƒƒãƒ—ã‚’æŒ?®šã—ã¾ã™ã? 029 * パラメータã®åˆæœŸå€¤ã¯ã€?–‹å§?1)ã€çµ‚äº?10)ã€ã‚¹ãƒ?ƒƒãƒ?1) ã§ã™ã? 030 * 031 * 例ï¼?,10,1 â†?1,2,3,4,5,6,7,8,9,10 ã®ãƒ—ルãƒ?‚¦ãƒ³ 032 * 例ï¼?0,100,10 â†?10,20,30,40,50,60,70,80,90,100 ã®ãƒ—ルãƒ?‚¦ãƒ³ 033 * 例ï¼?5,5,1 â†?-5,-4,-3,-2,-1,0,1,2,3,4,5 ã®ãƒ—ルãƒ?‚¦ãƒ³ 034 * 例ï¼?,-5,-2 â†?5,3,1,-1,-3,-5 ã®ãƒ—ルãƒ?‚¦ãƒ³ 035 * 036 * @og.group é¸æŠžãƒ‡ãƒ¼ã‚¿åˆ¶å¾¡ 037 * @og.rev 5.6.1.1 (2013/02/08) æ–°è¦è¿½åŠ? 038 * 039 * @version 4.0 040 * @author Kazuhiko Hasegawa 041 * @since JDK5.0, 042 */ 043 public class Selection_NUM implements Selection { 044 private final String CACHE ; 045 private final String ST_ED_STEP ; 046 047 /** 048 * コンストラクター 049 * 050 * 引数ã¯ã€?–‹å§‹ã?終äº??スãƒ?ƒƒãƒ—ã§ã™ã? 051 * パラメータã®åˆæœŸå€¤ã¯ã€?–‹å§?1)ã€çµ‚äº?10)ã€ã‚¹ãƒ?ƒƒãƒ?1) ã§ã™ã? 052 * 053 * @param editPrm é–‹å§‹ã?終äº??[スãƒ?ƒƒãƒ—]を表ã™å¼•æ•°(例ï¼?,10,1) 054 */ 055 public Selection_NUM( final String editPrm ) { 056 // if( param.length < 2 ) { 057 // String errMsg = "引数ã¯ã€?–‹å§‹ã?終äº??[スãƒ?ƒƒãƒ—] ã§ã™ã?æœ?½Žã§ã‚‚ï¼’å?å¿?¦ã§ã™ã?"; 058 // throw new IllegalArgumentException( errMsg ); 059 // } 060 061 String[] param = (editPrm == null) ? new String[0] : editPrm.split( "," ) ; 062 063 int start = (param.length > 0) ? Integer.parseInt( param[0].trim() ) : 1; 064 int end = (param.length > 1) ? Integer.parseInt( param[1].trim() ) : 10 ; 065 int step = (param.length > 2) ? Integer.parseInt( param[2].trim() ) : 1; 066 067 if( step == 0 ) { 068 String errMsg = "スãƒ?ƒƒãƒ?ã« ??ã¯æŒ?®šã§ãã¾ã›ã‚“。無é™ãƒ«ãƒ¼ãƒ—ã—ã¾ã™ã?"; 069 throw new IllegalArgumentException( errMsg ); 070 } 071 072 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 073 074 // スãƒ?ƒƒãƒ—ã?æ£è²?«ã‚ˆã‚‹åˆ¤å®šã?é•ã„。while( Math.signum( end-start ) * step >= 0.0 ) ã§ã€åˆ¤ã‚‹ï¼? 075 // 終äº?¡ä»¶ã¯ã€å«ã‚?val<=end) 076 int val = start; 077 int sign = ( step > 0 ) ? 1 : -1 ; // スãƒ?ƒƒãƒ—ã?符å·ã€? 078 while( (end - val) * sign >= 0 ) { 079 buf.append( "<option value=\"" ).append( val ).append( "\"" ); 080 buf.append( ">" ).append( val ).append( "</option>" ); 081 val += step; 082 } 083 084 CACHE = buf.toString(); 085 ST_ED_STEP = "Start=" + start + " , End=" + end + " , Step=" + step ; 086 } 087 088 /** 089 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 090 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 091 * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€ãƒ©ãƒ™ãƒ«(çŸ)ãŒè¨å®šã•れã¦ã?‚‹å ´åˆã§ã‚‚ã?ã“れを使用ã›ãšã«å¿?šãƒ©ãƒ™ãƒ«(é•·)を使用ã—ã¾ã™ã? 092 * 093 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 094 * @param seqFlag シーケンスアクセス機è? [true:ON/false:OFF] 095 * 096 * @return オプションタグ 097 * @see #getOption( String, boolean, boolean ) 098 */ 099 public String getOption( final String selectValue,final boolean seqFlag ) { 100 return getOption( selectValue, seqFlag, false ); 101 } 102 103 /** 104 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 105 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 106 * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€å¼•æ•°ã®useShortLabelãŒtrueã«æŒ?®šã•れãŸå ´åˆã«ã€ãƒ©ãƒ™ãƒ«(çŸ)ã‚’ã?ースã¨ã—㟠107 * ãƒ??ルãƒãƒƒãƒ—表示を行ã„ã¾ã™ã? 108 * 109 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 110 * @param seqFlag シーケンスアクセス機è? [true:ON/false:OFF] 111 * @param useShortLabel ラベル(çŸ)ã‚’ã?ースã¨ã—ãŸã‚ªãƒ—ション表示を行ã†ã‹ã©ã?‹ã€?未使用) 112 * 113 * @return オプションタグ 114 * @see #getOption( String, boolean ) 115 */ 116 public String getOption( final String selectValue,final boolean seqFlag, final boolean useShortLabel ) { 117 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã? 118 int selected = CACHE.indexOf( "\"" + selectValue + "\"" ); 119 120 if( selected < 0 ) { 121 if( selectValue != null && selectValue.length() > 0 ) { 122 String errMsg = "æ•°å—ç¯?›²ã«å˜åœ¨ã—ãªã??ãŒæŒ‡å®šã•れã¾ã—ãŸã€? 123 + " value=[" + selectValue + "]" 124 + HybsSystem.CR + ST_ED_STEP ; 125 LogWriter.log( errMsg ); 126 } 127 return CACHE; 128 } 129 else { 130 // "値" æ–?—å?ã®ä½ç½®ãŒã?selected ãªã®ã§ã€å?ã®æ–?—æ•°?‹ï¼’ã¾ã§ãŒã?å‰åŠéƒ¨åˆ?«ãªã‚‹ã? 131 int indx = selected + selectValue.length() + 2 ; 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,indx ) ); 140 } 141 buf.append( " selected=\"selected\"" ); 142 buf.append( CACHE.substring( indx ) ); 143 return buf.toString() ; 144 } 145 } 146 147 /** 148 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 149 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 150 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 151 * 152 * @og.rev 2.1.0.1 (2002/10/17) é¸æŠžãƒªã‚¹ãƒˆã‚’ã€æ£æ–¹å‘ã«ã—ã‹é¸ã¹ãªã?‚ˆã?«ã™ã‚‹ sequenceFlag ã‚’å°Žå?ã™ã‚‹ 153 * @og.rev 3.8.6.0 (2006/09/29) useLabel 属æ? 追åŠ? 154 * 155 * @param name ラジオ㮠name 156 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 157 * @param useLabel ãƒ©ãƒ™ãƒ«è¡¨ç¤ºã®æœ‰ç„¡ [true:æœ?false:ç„¡] 158 * 159 * @return オプションタグ 160 */ 161 public String getRadio( final String name,final String selectValue,final boolean useLabel ) { 162 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 163 throw new UnsupportedOperationException( errMsg ); 164 } 165 166 /** 167 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã? 168 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã? 169 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€? 170 * 171 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤ 172 * 173 * @return オプションタグ 174 */ 175 public String getRadioLabel( final String selectValue ) { 176 String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?; 177 throw new UnsupportedOperationException( errMsg ); 178 } 179 180 /** 181 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 182 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 183 * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã? 184 * 185 * @param selectValue é¸æŠžè‚¢ã®å€¤ 186 * 187 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 188 * @see #getValueLabel( String,boolean ) 189 */ 190 public String getValueLabel( final String selectValue ) { 191 return getValueLabel( selectValue,false ); 192 } 193 194 /** 195 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã? 196 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 197 * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã‚’è¿”ã™ã‹ã©ã?‹ã‚’指定ã™ã‚‹ãƒ•ラグを指定ã—ã¾ã™ã? 198 * getValueLabel( XX,false ) ã¯ã€getValueLabel( XX ) ã¨åŒã˜ã§ã™ã? 199 * 200 * @og.rev 4.0.0.0 (2005/11/30) を追åŠ? 201 * 202 * @param selectValue é¸æŠžè‚¢ã®å€¤ 203 * @param flag çŸç¸®ãƒ©ãƒ™ãƒ«ã‚?[true:使用ã™ã‚‹/false:ã—ãªã„] (未使用) 204 * 205 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ« 206 * @see #getValueLabel( String ) 207 */ 208 public String getValueLabel( final String selectValue,final boolean flag ) { 209 // ã‚ã‚ã?Œãªã‹ã‚ã?Œã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã? 210 return selectValue; 211 } 212 213 /** 214 * マルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã?false固å®?ã€? 215 * true?šä½¿ç”¨ã™ã‚‹ã€‚false:使用ã—ãªã?ã§ã™ã? 216 * ãŸã ã—ã?実際ã«ä½¿ç”¨ã™ã‚‹ã‹ã©ã?‹ã¯ã€HTMLå‡ºåŠ›æ™‚ã«æ±ºã‚ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã? 217 * ã“ã“ã§ã¯ã€USE_MULTI_KEY_SELECT ã?true ã§ã€USE_SIZE(=20)以上ã?å ´åˆã« 218 * true ã‚’è¿”ã—ã¾ã™ã? 219 * 220 * @og.rev 3.5.5.7 (2004/05/10) æ–°è¦ä½œæ? 221 * 222 * @return é¸æŠžãƒªã‚¹ãƒˆã§ã€ã?ルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹) (false固å®? 223 */ 224 public boolean useMultiSelect() { 225 return true; 226 } 227 228 /** 229 * オブジェクトã?ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã? 230 * ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?ã‚?無効)ã§ã‚れã°ã€true ã‚’ã?有効ã§ã‚れã°ã€? 231 * false ã‚’è¿”ã—ã¾ã™ã? 232 * 233 * @og.rev 4.0.0.0 (2005/01/31) æ–°è¦ä½œæ? 234 * 235 * @return ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れãªã‚?true 236 */ 237 public boolean isTimeOver() { 238 return false; 239 } 240 }