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
023 /**
024 * ãƒ??ã‚¿ã®ã‚³ãƒ¼ãƒ‰æƒ…å ±ã‚’å–り扱ã?‚¯ãƒ©ã‚¹ã§ã™ã?
025 *
026 * æ–?—å?㮠「ã‚ー:ラベル ã‚ー:ラベルã€ã?æƒ??ã‹ã‚‰ã€HTMLã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚?ƒªã‚¹ãƒˆã‚’作æ?ã™ã‚‹ãŸã‚ã®
027 * オプションタグを作æ?ã—ãŸã‚Šã?与ãˆã‚‰ã‚ŒãŸã‚ーをもã¨ã«ã€ãƒã‚§ãƒ?‚¯æ¸ˆã¿ã®ã‚ªãƒ—ションタグã‚?
028 * 作æ?ã—ãŸã‚Šã—ã¾ã™ã?
029 * ラベル ã«ã‚¹ãƒšã?スをå«ã¾ã›ã‚‹å ´åˆã?ã€ãƒ€ãƒ–ルクォーãƒ??ションã§å›²ã£ã¦ãã ã•ã„ã€?
030 *
031 * @og.rev 5.6.6.0 (2013/07/05) æ–°è¦è¿½åŠ?
032 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?基本実è£?¨ã—ã¾ã™ã?
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 public class Selection_KEYVAL extends Selection_NULL {
041 private final String ORG_KEYVAL ;
042
043 private final String CACHE ;
044
045 /**
046 * コンストラクター
047 *
048 * @og.rev 5.6.7.1 (2013/08/09) 「ã‚ー:ラベル ã‚ー:ラベルã€å?è§£ã«ã€ã‚¯ã‚ªãƒ¼ãƒˆå?ç?‚’åŠ?‘³
049 *
050 * @param strCode コードデータパラメータæ–?—å?
051 */
052 public Selection_KEYVAL( final String strCode ) {
053 ORG_KEYVAL = strCode ;
054
055 if( strCode != null && strCode.indexOf( ':' ) > 0 ) {
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 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
091 *
092 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤
093 * @param seqFlag シーケンスアクセス機è? [true:ON/false:OFF]
094 *
095 * @return オプションタグ
096 * @see #getOption( String, boolean, boolean )
097 */
098 // public String getOption( final String selectValue,final boolean seqFlag ) {
099 // return getOption( selectValue, seqFlag, false );
100 // }
101
102 /**
103 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã?
104 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã?
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 @Override
115 public String getOption( final String selectValue,final boolean seqFlag, final boolean useShortLabel ) {
116 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã?ã‚ーã®å‰å¾Œã?ãƒ?ƒ–ルクオートをåŠ?‘³ã—ã¦æ¤œç´¢
117 String selVal = "\"" + selectValue + "\"" ;
118
119 int indx = CACHE.indexOf( selVal );
120
121 if( indx < 0 ) {
122 // 4.0.0 (2005/01/31)
123 if( selectValue != null && selectValue.length() > 0 ) {
124 String errMsg = "コードã«å˜åœ¨ã—ãªã??ãŒæŒ‡å®šã•れã¾ã—ãŸã€?
125 + " value=[" + selectValue + "]"
126 + HybsSystem.CR + ORG_KEYVAL ;
127 LogWriter.log( errMsg );
128 }
129 return CACHE;
130 }
131 else {
132 int addIndx = indx + selVal.length() ; // selected ã®æŒ¿å…¥ä½ç½®
133
134 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
135 // 3.6.0.6 (2004/10/22) シーケンスアクセス機è?を指定ã™ã‚?seqFlag ã‚’å°Žå?
136 if( seqFlag ) {
137 buf.append( "<option value=\"" ).append( selectValue ).append( "\"" );
138 }
139 else {
140 buf.append( CACHE.substring( 0,addIndx ) );
141 }
142 buf.append( " selected=\"selected\"" );
143 buf.append( CACHE.substring( addIndx ) );
144 return buf.toString() ;
145 }
146 }
147
148 /**
149 * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã?
150 * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã?
151 * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?
152 *
153 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
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 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
172 *
173 * @param selectValue é¸æŠžã•れã¦ã?‚‹å€¤
174 *
175 * @return オプションタグ
176 */
177 // public String getRadioLabel( final String selectValue ) {
178 // String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?;
179 // throw new UnsupportedOperationException( errMsg );
180 // }
181
182 /**
183 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã?
184 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã?
185 * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã?
186 *
187 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
188 *
189 * @param selectValue é¸æŠžè‚¢ã®å€¤
190 *
191 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ«
192 * @see #getValueLabel( String,boolean )
193 */
194 // public String getValueLabel( final String selectValue ) {
195 // return getValueLabel( selectValue,false );
196 // }
197
198 /**
199 * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã?
200 * é¸æŠžè‚¢(value)ãŒã?å˜åœ¨ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã?
201 * getValueLabel( XX,false ) ã¯ã€getValueLabel( XX ) ã¨åŒã˜ã§ã™ã?
202 *
203 * ※ ã“ã?クラスã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã¯ä½¿ç”¨ã•れã¾ã›ã‚“ã€?
204 *
205 * @param selectValue é¸æŠžè‚¢ã®å€¤
206 * @param flag çŸç¸®ãƒ©ãƒ™ãƒ«ã‚?[true:使用ã™ã‚‹/false:ã—ãªã„](常㫠false)
207 *
208 * @return é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ«
209 * @see #getValueLabel( String )
210 */
211 @Override
212 public String getValueLabel( final String selectValue,final boolean flag ) {
213 // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã?ã‚ーã®å‰å¾Œã?ãƒ?ƒ–ルクオートをåŠ?‘³ã—ã¦æ¤œç´¢
214 String selVal = "\"" + selectValue + "\"" ;
215
216 int indx = CACHE.indexOf( selVal );
217
218 if( indx < 0 ) {
219 // マッãƒã—ãªã‘れã°ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã™ã€?
220 return selectValue;
221 }
222 else {
223 // マッãƒã™ã‚Œã?ã€ã‚ー以下ã?BODYéƒ¨ã®æ–?—å?ã‚’å?りå?ã—ã¦è¿”ã™ã€?
224 int stIdx = indx + selVal.length() + 1 ; // ?‹ï¼?ã¯ã€?>" ã®ä½ç½®
225 int edIdx = CACHE.indexOf( '<',stIdx ); // 終äº?‚¢ãƒ‰ãƒ¬ã‚¹
226
227 return CACHE.substring( stIdx,edIdx );
228 }
229 }
230
231 /**
232 * マルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
233 * true?šä½¿ç”¨ã™ã‚‹ã€‚false:使用ã—ãªã?ã§ã™ã?
234 * ãŸã ã—ã?実際ã«ä½¿ç”¨ã™ã‚‹ã‹ã©ã?‹ã¯ã€HTMLå‡ºåŠ›æ™‚ã«æ±ºã‚ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã?
235 * ã“ã“ã§ã¯ã€USE_MULTI_KEY_SELECT ã?true ã§ã€USE_SIZE(=20)以上ã?å ´åˆã«
236 * true ã‚’è¿”ã—ã¾ã™ã?
237 *
238 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
239 *
240 * ※ ã“ã“ã§ã¯ã€å¸¸ã« false ã‚’è¿”ã—ã¾ã™ã?
241 *
242 * @return é¸æŠžãƒªã‚¹ãƒˆã§ã€ã?ルãƒã?ã‚ーセレクトを使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹)
243 */
244 // public boolean useMultiSelect() {
245 // return false;
246 // }
247
248 /**
249 * オブジェクトã?ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
250 * ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?ã‚?無効)ã§ã‚れã°ã€true ã‚’ã?有効ã§ã‚れã°ã€?
251 * false ã‚’è¿”ã—ã¾ã™ã?
252 *
253 * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
254 *
255 * ※ ã“ã“ã§ã¯ã€å¸¸ã« false ã‚’è¿”ã—ã¾ã™ã?
256 *
257 * @return ã‚ャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れãªã‚?true
258 */
259 // public boolean isTimeOver() {
260 // return false;
261 // }
262 }