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    
021    /**
022     * ãƒ??ã‚¿ã®ã‚³ãƒ¼ãƒ‰æƒ…報をå–り扱ã?‚¯ãƒ©ã‚¹ã§ã™ã?
023     *
024     * é–‹å§‹ã?終äº??スãƒ?ƒƒãƒ—ã?æƒ??ã‹ã‚‰ã€HTMLã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚?ƒªã‚¹ãƒˆã‚’作æ?ã™ã‚‹ãŸã‚㮠オプション
025     * タグを作æ?ã—ãŸã‚Šã?与ãˆã‚‰ã‚ŒãŸã‚­ãƒ¼ã‚’ã‚‚ã¨ã«ã€ãƒã‚§ãƒ?‚¯æ¸ˆã¿ã®ã‚ªãƒ—ションタグを作æ?ã—ãŸã‚Šã—ã¾ã™ã?
026     * 
027     * ã“ã“ã§ã¯ã€æ•°å­—(é?番?‰ã?自動生æˆã‚’行ã„ã¾ã™ã?パラメータã§ã€?–‹å§‹ã?終äº??スãƒ?ƒƒãƒ—ã‚’æŒ?®šã—ã¾ã™ã?
028     * パラメータã®åˆæœŸå€¤ã¯ã€?–‹å§?1)ã€çµ‚äº?10)ã€ã‚¹ãƒ?ƒƒãƒ?1) ã§ã™ã?
029     * 
030     * 例ï¼?,10,1    â†?1,2,3,4,5,6,7,8,9,10 ã®ãƒ—ルãƒ?‚¦ãƒ³
031     * 例ï¼?0,100,10 â†?10,20,30,40,50,60,70,80,90,100 ã®ãƒ—ルãƒ?‚¦ãƒ³
032     * 例ï¼?5,5,1    â†?-5,-4,-3,-2,-1,0,1,2,3,4,5 ã®ãƒ—ルãƒ?‚¦ãƒ³
033     * 例ï¼?,-5,-2   â†?5,3,1,-1,-3,-5 ã®ãƒ—ルãƒ?‚¦ãƒ³
034     *
035     * @og.group é¸æŠžãƒ‡ãƒ¼ã‚¿åˆ¶å¾¡
036     * @og.rev 5.6.1.1 (2013/02/08) æ–°è¦è¿½åŠ?
037     *
038     * @version  4.0
039     * @author   Kazuhiko Hasegawa
040     * @since    JDK5.0,
041     */
042    // public class Selection_NUM implements Selection {
043    public class Selection_NUM extends Selection_NULL {
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             * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
094             *
095             * @param   selectValue  é¸æŠžã•れã¦ã?‚‹å€¤
096             * @param   seqFlag  シーケンスアクセス機è? [true:ON/false:OFF]
097             *
098             * @return  オプションタグ
099             * @see     #getOption( String, boolean, boolean )
100             */
101    //      public String getOption( final String selectValue,final boolean seqFlag ) {
102    //              return getOption( selectValue, seqFlag, false );
103    //      }
104    
105            /**
106             * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã?
107             * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã?
108             * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€å¼•æ•°ã®useShortLabelãŒtrueã«æŒ?®šã•れãŸå ´åˆã«ã€ãƒ©ãƒ™ãƒ«(短)ã‚’ã?ースã¨ã—ãŸ
109             * ãƒ??ルãƒãƒƒãƒ—表示を行ã„ã¾ã™ã?
110             *
111             * @param   selectValue  é¸æŠžã•れã¦ã?‚‹å€¤
112             * @param   seqFlag  シーケンスアクセス機è? [true:ON/false:OFF]
113             * @param   useShortLabel ラベル(短)ã‚’ã?ースã¨ã—ãŸã‚ªãƒ—ション表示を行ã†ã‹ã©ã?‹ã€?未使用)
114             *
115             * @return  オプションタグ
116             * @see     #getOption( String, boolean )
117             */
118            @Override
119            public String getOption( final String selectValue,final boolean seqFlag, final boolean useShortLabel ) {
120                    // マッãƒã™ã‚‹ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’探ã™ã?
121                    int selected = CACHE.indexOf( "\"" + selectValue + "\"" );
122    
123                    if( selected < 0 ) {
124                            if( selectValue != null && selectValue.length() > 0 ) {
125                                    String errMsg = "æ•°å­—ç¯?›²ã«å­˜åœ¨ã—ãªã??ãŒæŒ‡å®šã•れã¾ã—ãŸã€?
126                                                            + " value=[" + selectValue + "]"
127                                                            + HybsSystem.CR + ST_ED_STEP ;
128                                    LogWriter.log( errMsg );
129                            }
130                            return CACHE;
131                    }
132                    else {
133                            // "値" æ–?­—å?ã®ä½ç½®ãŒã?selected ãªã®ã§ã€å?ã®æ–?­—æ•°?‹ï¼’ã¾ã§ãŒã?å‰åŠéƒ¨åˆ?«ãªã‚‹ã?
134                            int indx = selected + selectValue.length() + 2 ;
135    
136                            StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
137                            // 3.6.0.6 (2004/10/22) シーケンスアクセス機è?を指定ã™ã‚?seqFlag ã‚’å°Žå?
138                            if( seqFlag ) {
139                                    buf.append( "<option value=\"" ).append( selectValue ).append( "\"" );
140                            }
141                            else {
142                                    buf.append( CACHE.substring( 0,indx ) );
143                            }
144                            buf.append( " selected=\"selected\"" );
145                            buf.append( CACHE.substring( indx ) );
146                            return buf.toString() ;
147                    }
148            }
149    
150            /**
151             * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã?
152             * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã?
153             * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?
154             *
155             * @og.rev 2.1.0.1 (2002/10/17) é¸æŠžãƒªã‚¹ãƒˆã‚’ã€æ­£æ–¹å‘ã«ã—ã‹é¸ã¹ãªã?‚ˆã?«ã™ã‚‹ sequenceFlag ã‚’å°Žå?ã™ã‚‹
156             * @og.rev 3.8.6.0 (2006/09/29) useLabel 属æ? 追åŠ?
157             * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
158             *
159             * @param   name         ラジオ㮠name
160             * @param   selectValue  é¸æŠžã•れã¦ã?‚‹å€¤
161             * @param   useLabel     ãƒ©ãƒ™ãƒ«è¡¨ç¤ºã®æœ‰ç„¡ [true:æœ?false:ç„¡]
162             *
163             * @return  オプションタグ
164             */
165    //      public String getRadio( final String name,final String selectValue,final boolean useLabel ) {
166    //              String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?;
167    //              throw new UnsupportedOperationException( errMsg );
168    //      }
169    
170            /**
171             * åˆæœŸå€¤ãŒé¸æŠžæ¸ˆã¿ã® é¸æŠžè‚¢(オプション)ã‚’è¿”ã—ã¾ã™ã?
172             * ã“ã?オプションã¯ã€å¼•æ•°ã®å€¤ã‚’å?期å?ã¨ã™ã‚‹ã‚ªãƒ—ションタグを返ã—ã¾ã™ã?
173             * ※ ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?
174             *
175             * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
176             *
177             * @param   selectValue  é¸æŠžã•れã¦ã?‚‹å€¤
178             *
179             * @return  オプションタグ
180             */
181    //      public String getRadioLabel( final String selectValue ) {
182    //              String errMsg = "ã“ã?クラスã§ã¯å®Ÿè£?•れã¦ã?¾ã›ã‚“ã€?;
183    //              throw new UnsupportedOperationException( errMsg );
184    //      }
185    
186            /**
187             * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã?
188             * é¸æŠžè‚¢(value)ãŒã?存在ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã?
189             * getValueLabel( XX ) ã¯ã€getValueLabel( XX,false ) ã¨åŒã˜ã§ã™ã?
190             *
191             * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
192             *
193             * @param   selectValue é¸æŠžè‚¢ã®å€¤
194             *
195             * @return  é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ«
196             * @see     #getValueLabel( String,boolean )
197             */
198    //      public String getValueLabel( final String selectValue ) {
199    //              return getValueLabel( selectValue,false );
200    //      }
201    
202            /**
203             * é¸æŠžè‚¢(value)ã«å¯¾ã™ã‚‹ãƒ©ãƒ™ãƒ«ã‚’è¿”ã—ã¾ã™ã?
204             * é¸æŠžè‚¢(value)ãŒã?存在ã—ãªã‹ã£ãŸå?åˆã?ã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã?
205             * ã“ã?メソãƒ?ƒ‰ã§ã¯ã€çŸ­ç¸®ãƒ©ãƒ™ãƒ«ã‚’è¿”ã™ã‹ã©ã?‹ã‚’指定ã™ã‚‹ãƒ•ラグを指定ã—ã¾ã™ã?
206             * getValueLabel( XX,false ) ã¯ã€getValueLabel( XX ) ã¨åŒã˜ã§ã™ã?
207             *
208             * @og.rev 4.0.0.0 (2005/11/30) を追�
209             *
210             * @param       selectValue     é¸æŠžè‚¢ã®å€¤
211             * @param       flag    短縮ラベルã‚?[true:使用ã™ã‚‹/false:ã—ãªã„] (未使用)
212             *
213             * @return  é¸æŠžè‚¢ã®ãƒ©ãƒ™ãƒ«
214             * @see     #getValueLabel( String )
215             */
216            @Override
217            public String getValueLabel( final String selectValue,final boolean flag ) {
218                    // ã‚ã‚ã?Œãªã‹ã‚ã?Œã€?¸æŠžè‚¢ãã?ã‚‚ã?ã‚’è¿”ã—ã¾ã™ã?
219                    return selectValue;
220            }
221    
222            /**
223             * マルãƒã?キーセレクトを使用ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã?false固å®?ã€?
224             * true?šä½¿ç”¨ã™ã‚‹ã€‚false:使用ã—ãªã?ã§ã™ã?
225             * ãŸã ã—ã?実際ã«ä½¿ç”¨ã™ã‚‹ã‹ã©ã?‹ã¯ã€HTMLå‡ºåŠ›æ™‚ã«æ±ºã‚ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã?
226             * ã“ã“ã§ã¯ã€USE_MULTI_KEY_SELECT ã?true ã§ã€USE_SIZE(=20)以上ã?å ´åˆã«
227             * true ã‚’è¿”ã—ã¾ã™ã?
228             *
229             * @og.rev 3.5.5.7 (2004/05/10) æ–°è¦ä½œæ?
230             *
231             * @return  é¸æŠžãƒªã‚¹ãƒˆã§ã€ã?ルãƒã?キーセレクトを使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹) (false固å®?
232             */
233            @Override
234            public boolean useMultiSelect() {
235                    return true;
236            }
237    
238            /**
239             * オブジェクトã?キャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
240             * キャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?ã‚?無効)ã§ã‚れã°ã€true ã‚’ã?有効ã§ã‚れã°ã€?
241             * false ã‚’è¿”ã—ã¾ã™ã?
242             *
243             * @og.rev 4.0.0.0 (2005/01/31) æ–°è¦ä½œæ?
244             * @og.rev 5.7.7.1 (2014/06/13) Selection_NULL ã‚?継承ã™ã‚‹ãŸã‚ã€å‰Šé™¤
245             *
246             * @return  キャãƒ?‚·ãƒ¥ãŒæ™‚é–“å?れãªã‚?true
247             */
248    //      public boolean isTimeOver() {
249    //              return false;
250    //      }
251    }