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 java.util.HashMap;
019    import java.util.HashSet;
020    import java.util.Map;
021    import java.util.Set;
022    
023    import org.opengion.fukurou.util.StringUtil;
024    
025    /**
026     * エãƒ?‚£ãƒ?ƒˆè¨­å®šæƒ…報を管ç?™ã‚‹ãŸã‚ã?ãƒ??タ管ç?‚¯ãƒ©ã‚¹ã§ã™ã?
027     * ã“ã“ã§ç®¡ç?•れるå?ƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ãƒ¼ã®æ„味ã¯ä»¥ä¸‹ã?通りã§ã™ã?
028     * (å?‚¤ãƒ³ãƒ?ƒƒã‚¯ã‚¹ç•ªå·ã¯ã€å?部çš?«ç®¡ç?•れã¦ã?‚‹ã‚¤ãƒ³ãƒ?ƒƒã‚¯ã‚¹ç•ªå·ã‚’æ„味ã—ã¾ã?
029     *
030     * ・0:エãƒ?‚£ãƒ?ƒˆå?
031     *       ã“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã?åç§°ã§ã™ã?
032     * ・1:表示カラ�
033     *       表示対象ã¨ãªã‚‹ã‚«ãƒ©ãƒ?¸?¦§ã§ã™ã?カンマ区åˆ?‚Šã§æŒ?®šã—ã¾ã™ã?
034     *       ã“ã?ä¸?¦§ã«ã¯ã€?žè¡¨ç¤ºã®ã‚«ãƒ©ãƒ?‚‚åˆã‚ã›ã¦ç®¡ç?•れã?éžè¡¨ç¤ºã‚«ãƒ©ãƒ?«ã¤ã?¦ã¯ã€?
035     *       カラãƒ?ã®å…ˆé?ã«"!"ã‚’ã¤ã‘ã¾ã™ã?
036     *       ä¾? AAA,!BBB,CCC â‡?AAA,CCCã®é ?«è¡¨ç¤º(BBBã¯éžè¡¨ç¤º)
037     * ・2:é›?¨ˆã‚«ãƒ©ãƒ?
038     *       å??ã‚’SUMã™ã‚‹å¯¾è±¡ã¨ãªã‚‹ã‚«ãƒ©ãƒ?§ã™ã?(カンマ区åˆ?‚Šã§è¤?•°æŒ?®šãŒå¯èƒ½)
039     *       ã“ã“ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ??数値型ã§ã‚ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
040     *       SQLæ§‹æ–‡ã«ãŠã‘ã‚‹ã?SUM関数ã®å¼•æ•°ã¨ã—ã¦æŒ?®šã™ã‚‹ã‚«ãƒ©ãƒ?«ç›¸å½“ã—ã¾ã™ã?
041     * ・3:グループカラ�
042     *       é›?¨ˆã‚«ãƒ©ãƒ??å??をグルーピングã™ã‚‹ãŸã‚ã®ã‚«ãƒ©ãƒ?§ã™ã?(カンマ区åˆ?‚Šã§è¤?•°æŒ?®šãŒå¯èƒ½)
043     *       SQLæ§‹æ–‡ã«ãŠã‘ã‚‹ã?GROUP BYã«æŒ?®šã™ã‚‹ã‚«ãƒ©ãƒ?«ç›¸å½“ã—ã¾ã™ã?
044     * ・4:å°è¨ˆã‚«ãƒ©ãƒ?
045     *       é›?¨ˆã‚«ãƒ©ãƒ??å??ã«å¯¾ã—ã?å°è¨ˆè¡Œã‚’付加ã™ã‚‹ãŸã‚ã®ãƒ–レイクキーを指定ã—ã¾ã™ã?(カンマ区åˆ?‚Šã§è¤?•°æŒ?®šãŒå¯èƒ½)
046     * ・5:åˆè¨ˆã‚«ãƒ©ãƒ?
047     *       é›?¨ˆã‚«ãƒ©ãƒ??å??ã«å¯¾ã—ã?åˆè¨ˆè¡Œã‚’付加ã™ã‚‹ãŸã‚ã®ãƒ–レイクキーを指定ã—ã¾ã™ã?(カンマ区åˆ?‚Šã§è¤?•°æŒ?®šãŒå¯èƒ½)
048     * ・6:ç·åˆè¨ˆãƒ•ラグ
049     *       é›?¨ˆã‚«ãƒ©ãƒ??å??ã«å¯¾ã—ã?ç·åˆè¨ˆè¡Œã‚’付加ã™ã‚‹ã‹ã©ã?‹ã‚’指定ã—ã¾ã™ã?(0以å¤?追åŠ?™ã‚?0:追åŠ?—ãªã?
050     * ・7:表示é ?‚«ãƒ©ãƒ?
051     *       ãƒ??ã‚¿ã®è¡¨ç¤ºé ?‚’ãã?é ?•ªã«ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã§æŒ?®šã—ã¾ã™ã?
052     *       カラãƒ?ã®å…ˆé?ã«"!"ã‚’ã¤ã‘ãŸå ´åˆã?ã€ãã®ã‚«ãƒ©ãƒ??é™é?ã§è¡¨ç¤ºã•れã¾ã™ã?
053     *       SQLæ§‹æ–‡ã«ãŠã‘ã‚‹ã?orderbyå¥ã«ç›¸å½“ã—ã¾ã™ã?
054     * ・8:共通フラグ
055     *       ã“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトãŒã€å?é€?全ユーザー公é–?エãƒ?‚£ãƒ?ƒˆã‹ã©ã?‹ã‚?
056     *       æŒ?®šã—ã¾ã™ã?(0以å¤?å…±é€?0:個人ã®ã¿)
057     *
058     * @og.rev 5.3.6.0 (2011/06/01) æ–°è¦è¿½åŠ?
059     *
060     * @version  5.0
061     * @author   Hiroki Nakamura
062     * @since    JDK6.0,
063     */
064    public class DBEditConfig {
065    
066            private static final int EDIT_KEY_NAME          = 0;
067            private static final int EDIT_KEY_VIEW          = 1;
068            private static final int EDIT_KEY_SUM           = 2;
069            private static final int EDIT_KEY_GROUP         = 3;
070            private static final int EDIT_KEY_SUBTOTAL      = 4;
071            private static final int EDIT_KEY_TOTAL         = 5;
072            private static final int EDIT_KEY_GRANDTOTAL= 6;
073            private static final int EDIT_KEY_ORDERBY       = 7;
074            private static final int EDIT_KEY_COMMON        = 8;
075    
076            private static final String[] EDIT_KEYS
077                    = { "NAME", "VIEW", "SUM", "GROUP", "SUBTOTAL", "TOTAL", "GRANDTOTAL", "ORDERBY", "COMMON" };
078    
079            private static final int EDIT_KEYS_LENGTH       = EDIT_KEYS.length;
080    
081            private final String[] editVals = new String[EDIT_KEYS_LENGTH];
082    
083            private int sumClmCount;
084            private int groupClmCount;
085            private int subTotalClmCount;
086            private int totalClmCount;
087            private final Map<String,String> orderMap = new HashMap<String,String>();
088            private String orderByDescClms;
089    
090            /**
091             * コンストラクタ
092             *
093             * 空ã®ã‚¨ãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトを構築ã—ã¾ã™ã?
094             */
095            public DBEditConfig() {
096            }
097    
098            /**
099             * コンストラクタ
100             *
101             * å?¨®ãƒ‘ラメーターを指定ã—ã¦ã‚¨ãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトを構築ã—ã¾ã™ã?
102             *
103             * @param editName エãƒ?‚£ãƒ?ƒˆåç§°
104             * @param viewClms ç”»é¢è¡¨ç¤ºã‚«ãƒ©ãƒ?
105             * @param sumClms é›?¨ˆã‚«ãƒ©ãƒ?
106             * @param groupClms グループカラ�
107             * @param subTotalClms å°è¨ˆã‚«ãƒ©ãƒ?
108             * @param totalClms åˆè¨ˆã‚«ãƒ©ãƒ?
109             * @param useGrandTotal ç·åˆè¨ˆè¡Œã‚’追åŠ?™ã‚‹ã‹(1:追åŠ?™ã‚?1以å¤?追åŠ?—ãªã?
110             * @param orderByClms 表示�
111             * @param isCommon 共通エãƒ?‚£ãƒ?ƒˆã‹ã©ã?‹(1:å…±é€?1以å¤?個人ã®ã¿)
112             */
113            public DBEditConfig( final String editName, final String viewClms
114                                                    , final String sumClms, final String groupClms
115                                                    , final String subTotalClms, final String totalClms
116                                                    , final String useGrandTotal, final String orderByClms
117                                                    , final String isCommon ) {
118    
119                    editVals[EDIT_KEY_NAME]                 = editName;
120                    editVals[EDIT_KEY_VIEW]                 = viewClms;
121                    editVals[EDIT_KEY_SUM]                  = sumClms;
122                    editVals[EDIT_KEY_GROUP]                = groupClms;
123                    editVals[EDIT_KEY_SUBTOTAL]             = subTotalClms;
124                    editVals[EDIT_KEY_TOTAL]                = totalClms;
125                    editVals[EDIT_KEY_GRANDTOTAL]   = useGrandTotal;
126                    editVals[EDIT_KEY_ORDERBY]              = orderByClms;
127                    editVals[EDIT_KEY_COMMON]               = isCommon;
128    
129                    init();
130            }
131    
132            /**
133             * コンストラクタ
134             *
135             * å?¨®ãƒ‘ラメーターをé?åˆ—ã§æŒ?®šã—ã¦ã‚¨ãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトを構築ã—ã¾ã™ã?
136             * å?ƒ‘ラメータã®é…å?インãƒ?ƒƒã‚¯ã‚¹ã¯ã€{@link #getEditKeys(String,String)}ã§è¿”ã•れる
137             * キーä¸?¦§ã®é…å?インãƒ?ƒƒã‚¯ã‚¹ã¨ä¸??ã—ã¾ã™ã?
138             * å?ƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ãƒ¼ã®æ„味ã«ã¤ã?¦ã¯ã€ã‚¯ãƒ©ã‚¹ã®Javadoc{@link DBEditConfig}ã‚’å‚ç…§ã—ã¦ä¸‹ã•ã??
139             *
140             * @param editVals 設定å?(é…å?)
141             * @see DBEditConfig
142             * @see #getEditKeys(String,String)
143             **/
144            public DBEditConfig( final String[] editVals ) {
145                    System.arraycopy( editVals, 0, this.editVals, 0, editVals.length );
146                    init();
147            }
148    
149            /**
150             * エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクト作æ?時ã?åˆæœŸåŒ–å?ç?§ã™ã?
151             * コンストラクタã®å¼•æ•°ã«åŸºã¥ãå?部変数ã®åˆæœŸè¨­å®šã‚’行ã„ã¾ã™ã?
152             */
153            private void init() {
154                    sumClmCount = StringUtil.csv2Array( editVals[EDIT_KEY_SUM] ).length;
155                    groupClmCount = StringUtil.csv2Array( editVals[EDIT_KEY_GROUP] ).length;
156                    subTotalClmCount = StringUtil.csv2Array( editVals[EDIT_KEY_SUBTOTAL] ).length;
157                    totalClmCount = StringUtil.csv2Array( editVals[EDIT_KEY_TOTAL] ).length;
158    
159                    if( editVals[EDIT_KEY_ORDERBY] != null ) {
160                            StringBuilder buf = new StringBuilder();
161                            String[] ary = StringUtil.csv2Array( editVals[EDIT_KEY_ORDERBY] );
162                            for( int i=0; i<ary.length ;i++ ) {
163                                    String str = ary[i];
164                                    if( str.startsWith( "!" ) ) {
165                                            str = str.substring( 1 );
166                                            if( buf.length() > 0 ) { buf.append( "," ); }
167                                            buf.append( str );
168                                    }
169                                    orderMap.put( str, String.valueOf( i+1 ) );
170                            }
171                            orderByDescClms = buf.toString();
172                    }
173                    else {
174                            orderByDescClms = null;
175                    }
176            }
177    
178            /**
179             * キーé…å?ã‹ã‚‰ç”»é¢IDã¨ã‚¨ãƒ?‚£ãƒ?ƒˆåç§°ã®ãƒšã‚¢ã®ä¸?¦§ã‚’å–りå?ã—ã¾ã™ã?
180             *
181             * キーé…å?ã‹ã‚‰"EDIT_NAME_"ã§å§‹ã¾ã‚‹ã‚­ãƒ¼ã‚’検索ã—ã?"EDIT_NAME_(ç”»é¢ID)_(エãƒ?‚£ãƒ?ƒˆå?"
182             * ã¨è¨?†å½¢å¼ã«åŸºã¥ãã?ç”»é¢IDã¨ã‚¨ãƒ?‚£ãƒ?ƒˆåç§°ã®ãƒšã‚¢ã‚’å–りå?ã—ã¾ã™ã?
183             *
184             * ç”»é¢IDã¨ã‚¨ãƒ?‚£ãƒ?ƒˆåç§°ã¯é…å?ã¨ã—ã¦ä¿å­˜ã•ã‚?インãƒ?ƒƒã‚¯ã‚¹ç•ªå·ã¯ 0:ç”»é¢IDã€?:エãƒ?‚£ãƒ?ƒˆå?
185             * ãã?ä¸?¦§ãŒã•れらã«é…å?ã«æ ¼ç´ã•れã¦è¿”ã•れã¾ã™ã?
186             *
187             * @param keys キーé…å?
188             *
189             * @return ç”»é¢IDã¨ã‚¨ãƒ?‚£ãƒ?ƒˆåç§°ã®ãƒšã‚¢ã®ä¸?¦§
190             */
191            public static String[][] getKeySet( final String[] keys ) {
192                    if( keys == null || keys.length == 0 ) { return null; }
193    
194                    Set<String[]> keySet = new HashSet<String[]>();
195                    for( String key : keys ) {
196                            if ( key != null && key.startsWith( "EDIT_NAME_" ) ) {
197                                    String guikeyEditName = key.substring( ( "EDIT_NAME_" ).length() );
198                                    if( guikeyEditName.indexOf( '_' ) >= 0 ) {
199                                            String guikey = guikeyEditName.substring( 0, guikeyEditName.indexOf( '_' ) );
200                                            String editName = guikeyEditName.substring( ( guikey + "_" ).length() );
201                                            if( guikey != null && guikey.length() > 0 && editName != null && editName.length() > 0 ) {
202                                                    String[] set = { guikey, editName };
203                                                    keySet.add( set );
204                                            }
205                                    }
206                            }
207                    }
208    //              return keySet.toArray( new String[0][] );
209                    return keySet.toArray( new String[keySet.size()][] );
210            }
211    
212            /**
213             * ç”»é¢IDã€ã‚¨ãƒ?‚£ãƒ?ƒˆåをキーã«ã€ã‚¨ãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã?å?¨­å®šå?ã®
214             * 管ç?‚­ãƒ¼ã‚’指定ã—ã¾ã™ã?
215             *
216             * エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã§ç®¡ç?•れるå?‚­ãƒ¼ã«å¯¾ã—ã¦ã€?
217             * "EDIT_[KEY]_(ç”»é¢ID)_(エãƒ?‚£ãƒ?ƒˆå?"ã¨ã?†ã‚­ãƒ¼ã‚’生æˆã—ã€ã“れをé…å?ã«ã—ã¦è¿”ã—ã¾ã™ã?
218             *
219             * @param guikey ç”»é¢ID
220             * @param editName エãƒ?‚£ãƒ?ƒˆå?
221             *
222             * @return エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚’管ç?™ã‚‹ãŸã‚ã?キーä¸?¦§
223             */
224            public static String[] getEditKeys( final String guikey, final String editName ) {
225                    String[] rtn = new String[EDIT_KEYS_LENGTH];
226                    for( int i=0; i<EDIT_KEYS_LENGTH; i++ ) {
227                            rtn[i] = "EDIT_" + EDIT_KEYS[i] + "_" + guikey + "_" + editName;
228                    }
229                    return rtn;
230            }
231    
232            /**
233             * エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã?å?¨­å®šå?ã‚’é?列ã«ã—ã¦è¿”ã—ã¾ã™ã?
234             *
235             * é…å?ã®ã‚¤ãƒ³ãƒ?ƒƒã‚¯ã‚¹ç•ªå·ã¯ã€{@link #getEditKeys(String,String)}ã§ç”Ÿæ?ã•れるキーã®
236             * インãƒ?ƒƒã‚¯ã‚¹ç•ªå·ã¨ä¸??ã—ã¾ã™ã?
237             *
238             * @return エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã?設定å?ä¸?¦§(é…å?)
239             * @see #getEditKeys(String,String)
240             */
241            public String[] getEditVals() {
242                    String[] rtn = new String[editVals.length];
243                    System.arraycopy( editVals, 0, rtn, 0, editVals.length );
244                    return rtn;
245            }
246    
247            /**
248             * エãƒ?‚£ãƒ?ƒˆåã‚’è¿”ã—ã¾ã™ã?
249             *
250             * @return エãƒ?‚£ãƒ?ƒˆå?
251             */
252            public String getEditName() {
253                    return editVals[EDIT_KEY_NAME];
254            }
255    
256            /**
257             * 表示カラãƒ?ã®ä¸?¦§ã‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
258             * éžè¡¨ç¤ºã‚«ãƒ©ãƒ?«ã¤ã?¦ã¯ã€ã‚«ãƒ©ãƒ?ã®å…ˆé?ã«"!"ã‚’ã¤ã‘ã¦è¿”ã•れã¾ã™ã?
259             * ä¾? AAA,!BBB,CCC â‡?AAA,CCCã®é ?«è¡¨ç¤º(BBBã¯éžè¡¨ç¤º)
260             *
261             * @return 表示カラãƒ?ä¸?¦§(カンマ区åˆ?‚Š)
262             */
263            public String getViewClms() {
264                    return editVals[EDIT_KEY_VIEW];
265            }
266            
267            /**
268             * 表示カラãƒ?CSVå½¢å¼?ã‚’ãƒã‚§ãƒ?‚¯ã—ã?変更ãŒã‚れã?ã€åæ˜?—ãŸã‚«ãƒ©ãƒ?‚’作æ?ã—ã¾ã™ã?
269             *
270             * 表示カラãƒ??ã€ä¸¦ã³é ?‚„éžè¡¨ç¤ºãƒžã?カー(!)ãªã©ãŒåР味ã•れã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ã€ç”»é¢ã”ã¨ã«
271             * ãƒ??タベã?スã«è¨˜éŒ²ã•れã¦ã?¾ã™ã?JSPソースを修正ã—ãŸå ´åˆã?ãƒ??タベã?スã«
272             * 書ãè¾¼ã¾ã‚ŒãŸè¡¨ç¤ºã‚«ãƒ©ãƒ??ã€åæ˜?•れãªã?Ÿã‚ã?カラãƒ?¸æŠžç”»é¢ç­‰ã«è¡¨ç¤ºã•れã¾ã›ã‚“ã€?
273             * ãã“ã§ã€ã‚ªãƒªã‚¸ãƒŠãƒ«ã®ã‚«ãƒ©ãƒ?«è¿½åŠ?•れãŸå ´åˆã?ã€ã‚«ãƒ©ãƒ?‚’比è¼?™ã‚‹ã“ã¨ã§ã€?
274             * 追åŠ??ã®ã‚«ãƒ©ãƒ?‚’ã€?žè¡¨ç¤ºã‚«ãƒ©ãƒ?¨ã—ã¦ã€å¾Œã‚ã«è¿½è¨˜ã—ã¾ã™ã?
275             * 削除ã•れãŸå?åˆã?ã€ViewForm ã§è­¦å‘Šè¡¨ç¤ºã™ã‚‹ã“ã¨ã§ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼ã«å¤‰æ›´ã‚’ä¿?—ã¾ã™ã?
276             *
277             * @og.rev 5.8.2.0 (2014/12/05) JSP修正時ã?追åŠ?‚«ãƒ©ãƒ?¯¾å¿?
278             *
279             * @param       orgClms         オリジナルã®ã‚«ãƒ©ãƒ?CSVå½¢å¼?
280             *
281             * @return      変更後ã?表示カラãƒ?CSVå½¢å¼?
282             */
283            public String getViewClms( final String orgClms ) {
284                    String viewClms = editVals[EDIT_KEY_VIEW];
285    
286                    if( orgClms == null || orgClms.isEmpty() ) { return viewClms; }         // orgClms ãŒãªã‘れã°ã€viewClms ã‚’è¿”ã™ã€?
287                    // 基本çš?«ã¯ã€ä¸¡è€??カラãƒ??ã€ä¸??ã™ã‚‹ã¯ãšã?
288                    String[] vclms = viewClms.split( "," );         // 表示é ??éžè¡¨ç¤ºå‡¦ç?‚’行ã£ãŸã‚«ãƒ©ãƒ?
289                    String[] fclms = orgClms.split( "," );          // å…??ã®è¡¨ç¤ºå¯èƒ½ã‚«ãƒ©ãƒ?™ã¹ã¦(fullClms)
290    
291                    // 表示å¯èƒ½ã‚«ãƒ©ãƒ?™ã¹ã¦ã® Set を作æ?ã—ã¾ã™ã?
292                    Set<String> fset = new HashSet<String>();
293                    for( int i=0; i<fclms.length; i++ ) {                // orgClms ã‚’Set ã«è¿½åŠ?—ã¾ã™ã?
294                            fset.add( fclms[i] );
295                    }
296    
297                    // éžè¡¨ç¤ºã‚«ãƒ©ãƒ??å†??表示å¯èƒ½ã‚«ãƒ©ãƒ?«å­˜åœ¨ã—ãªã??ã?‘ã® Set を作æ?ã—ã¾ã™ã?        
298                    // ã¾ãŸã?表示å¯èƒ½ã‚«ãƒ©ãƒ?‹ã‚‰ã?é ?•ªã«ã€viewClms ã®å€¤ã‚’削除ã—ã¦ã?ã¾ã™ã?
299                    Set<String> vset = new HashSet<String>();
300                    StringBuilder vbuf = new StringBuilder();       // æ–°ã—ã„ viewClms 作æ?用
301                    for( int i=0; i<vclms.length; i++ ) {                // viewClms ã‚’Set ã«è¿½åŠ?—ã¾ã™ã?
302                            String clm = vclms[i];
303                            if( clm == null || clm.isEmpty() ) { continue; }                        // 6.0.2.5 (2014/10/31) 潜在ãƒã‚°??å…ˆé?ã«"," ãŒæ¥ã‚‹ã¨ã‚¢ãƒ™ãƒ³ãƒ‰ã™ã‚‹ã?
304                            clm = clm.charAt(0) == '!' ? clm.substring(1) : clm ;           // éžè¡¨ç¤ºã® (!) ã¯å‰Šé™¤ã—ã¾ã™ã?
305                            if( fset.remove( clm ) ) {                              // fullSet ã«ã‚れã°ã€å‰Šé™¤ã™ã‚‹ã¨ã¨ã‚‚ã«ã€æ–°viewClmsを作æ?ã™ã‚‹ã€?
306                                    if( vbuf.length() > 0 ) { vbuf.append(','); }        // æœ??以é™ã?ã€ã‚«ãƒ³ãƒžã§é€£çµã™ã‚‹ã?             // 6.0.2.5 (2014/10/31) char ã‚?append ã™ã‚‹ã€?
307                                    vbuf.append( vclms[i] );                        // append ã™ã‚‹ã®ã¯ã€?!) 付ã?カラãƒ?
308                            }
309                            else {
310                                    vset.add( clm );                                        // fullSet ã«ãªã‘れã°ã€viewSet ã«è¿½åŠ?
311                            }
312                    }
313    
314                    // ã“ã?段階ã§ã€fsetã€vset ã¨ã‚‚ã«ã€ãれãžã‚Œç‹¬è‡ªã®ã‚«ãƒ©ãƒ?Œæ®‹ã£ã¦ã?‚‹ã€?
315                    // ã©ã¡ã‚‰ã‚‚ã€æ®‹ã£ã¦ã?ªã‘れã°ã€æ­£å¸¸ãªã®ã§ã€viewClms ã‚’è¿”ã™ã€?
316                    if( vset.isEmpty() && fset.isEmpty() ) { return viewClms; }
317    
318                    // fullSet ã«ã‚«ãƒ©ãƒ?Œæ®‹ã£ã¦ã?‚Œã°ã€?žè¡¨ç¤ºã§ã€æ–°viewClmsã«ã€è¿½åŠ?™ã‚‹ã?
319                    if( !fset.isEmpty() ) {
320                            String[] defClms = fset.toArray( new String[fset.size()] );
321                            for( int i=0; i<defClms.length; i++ ) {
322                                    if( vbuf.length() > 0 ) { vbuf.append(','); }        // 6.0.2.5 (2014/10/31) æœ??以é™ã?ã€ã‚«ãƒ³ãƒžã§é€£çµã™ã‚‹ã?
323                                    vbuf.append('!').append( defClms[i] );                                          // éžè¡¨ç¤ºã‚«ãƒ©ãƒ?¨ã—ã¦ã€å¾Œã‚ã«è¿½åŠ?™ã‚‹ã?
324                            }
325                    }
326                    viewClms = vbuf.toString();
327    
328                    editVals[EDIT_KEY_VIEW] = viewClms;
329                    return viewClms;
330            }
331    
332            /**
333             * é›?¨ˆã‚«ãƒ©ãƒ??ä¸?¦§ã‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
334             *
335             * @return é›?¨ˆã‚«ãƒ©ãƒ??ä¸?¦§(カンマ区åˆ?
336             */
337            public String getSumClms() {
338                    return editVals[EDIT_KEY_SUM];
339            }
340    
341            /**
342             * é›?¨ˆå?ç?‚’行ã†ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
343             * ã“れã¯ã€?›†è¨ˆã‚«ãƒ©ãƒ?ŒæŒ?®šã•れã¦ã?‚‹ã‹ã?ã¨åŒã˜æ„味ã§ã™ã?
344             *
345             * @return true:対象 false:éžå¯¾è±¡
346             */
347            public boolean useSum() {
348                    return ( editVals[EDIT_KEY_SUM] != null && editVals[EDIT_KEY_SUM].length() > 0 );
349            }
350    
351            /**
352             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ?Œé›?¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
353             *
354             * @param clm カラ�
355             *
356             * @return true:対象 false:éžå¯¾è±¡
357             */
358            public boolean isSumClm( final String clm ) {
359                    if( clm == null || editVals[EDIT_KEY_SUM] == null ) { return false; }
360                    return ( ( ","+editVals[EDIT_KEY_SUM]+"," ).indexOf( ","+clm+"," ) >= 0 );
361            }
362    
363            /**
364             * é›?¨ˆã‚«ãƒ©ãƒ??カラãƒ?•°ã‚’è¿”ã—ã¾ã™ã?
365             *
366             * @return é›?¨ˆã‚«ãƒ©ãƒ??カラãƒ?•°
367             */
368            public int getSumClmCount() {
369                    return sumClmCount;
370            }
371    
372            /**
373             * グループカラãƒ??ä¸?¦§ã‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
374             *
375             * @return グループカラãƒ??ä¸?¦§(カンマ区åˆ?
376             */
377            public String getGroupClms() {
378                    return editVals[EDIT_KEY_GROUP];
379            }
380    
381            /**
382             * グループå?ç?‚’行ã†ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
383             * ã“れã¯ã€ã‚°ãƒ«ãƒ¼ãƒ—カラãƒ?ŒæŒ?®šã•れã¦ã?‚‹ã‹ã?ã¨åŒã˜æ„味ã§ã™ã?
384             *
385             * @return true:対象 false:éžå¯¾è±¡
386             */
387            public boolean useGroup() {
388                    return ( editVals[EDIT_KEY_GROUP] != null && editVals[EDIT_KEY_GROUP].length() > 0 );
389            }
390    
391            /**
392             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ?Œã‚°ãƒ«ãƒ¼ãƒ—対象ã®ã‚«ãƒ©ãƒ?‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
393             *
394             * @param clm カラ�
395             *
396             * @return true:対象 false:éžå¯¾è±¡
397             */
398            public boolean isGroupClm( final String clm ) {
399                    if( clm == null || editVals[EDIT_KEY_GROUP] == null ) { return false; }
400                    return ( ( ","+editVals[EDIT_KEY_GROUP]+"," ).indexOf( ","+clm+"," ) >= 0 );
401            }
402    
403            /**
404             * グループカラãƒ??カラãƒ?•°ã‚’è¿”ã—ã¾ã™ã?
405             *
406             * @return グループカラãƒ??カラãƒ?•°
407             */
408            public int getGroupClmCount() {
409                    return groupClmCount;
410            }
411    
412            /**
413             * å°è¨ˆã‚«ãƒ©ãƒ??ä¸?¦§ã‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
414             *
415             * @return å°è¨ˆã‚«ãƒ©ãƒ??ä¸?¦§(カンマ区åˆ?
416             */
417            public String getSubTotalClms() {
418                    return editVals[EDIT_KEY_SUBTOTAL];
419            }
420    
421            /**
422             * å°è¨ˆå?ç?‚’行ã†ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
423             * ã“れã¯ã€å°è¨ˆã‚«ãƒ©ãƒ?ŒæŒ?®šã•れã¦ã?‚‹ã‹ã?ã¨åŒã˜æ„味ã§ã™ã?
424             *
425             * @return true:対象 false:éžå¯¾è±¡
426             */
427            public boolean useSubTotal() {
428                    return ( editVals[EDIT_KEY_SUBTOTAL] != null && editVals[EDIT_KEY_SUBTOTAL].length() > 0 );
429            }
430    
431            /**
432             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ?Œå°è¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
433             *
434             * @param clm カラ�
435             *
436             * @return true:対象 false:éžå¯¾è±¡
437             */
438            public boolean isSubTotalClm( final String clm ) {
439                    if( clm == null || editVals[EDIT_KEY_SUBTOTAL] == null ) { return false; }
440                    return ( ( ","+editVals[EDIT_KEY_SUBTOTAL]+"," ).indexOf( ","+clm+"," ) >= 0 );
441            }
442    
443            /**
444             * å°è¨ˆã‚«ãƒ©ãƒ??カラãƒ?•°ã‚’è¿”ã—ã¾ã™ã?
445             *
446             * @return グループカラãƒ??カラãƒ?•°
447             */
448            public int getSubTotalClmCount() {
449                    return subTotalClmCount;
450            }
451    
452            /**
453             * åˆè¨ˆã‚«ãƒ©ãƒ??ä¸?¦§ã‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
454             *
455             * @return åˆè¨ˆã‚«ãƒ©ãƒ??ä¸?¦§(カンマ区åˆ?
456             */
457            public String getTotalClms() {
458                    return editVals[EDIT_KEY_TOTAL];
459            }
460    
461            /**
462             * åˆè¨ˆå?ç?‚’行ã†ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
463             * ã“れã¯ã€åˆè¨ˆã‚«ãƒ©ãƒ?ŒæŒ?®šã•れã¦ã?‚‹ã‹ã?ã¨åŒã˜æ„味ã§ã™ã?
464             *
465             * @return true:対象 false:éžå¯¾è±¡
466             */
467            public boolean useTotal() {
468                    return ( editVals[EDIT_KEY_TOTAL] != null && editVals[EDIT_KEY_TOTAL].length() > 0 );
469            }
470    
471            /**
472             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ?Œåˆè¨ˆå¯¾è±¡ã®ã‚«ãƒ©ãƒ?‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
473             *
474             * @param clm カラ�
475             *
476             * @return true:対象 false:éžå¯¾è±¡
477             */
478            public boolean isTotalClm( final String clm ) {
479                    if( clm == null || editVals[EDIT_KEY_TOTAL] == null ) { return false; }
480                    return ( ( ","+editVals[EDIT_KEY_TOTAL]+"," ).indexOf( ","+clm+"," ) >= 0 );
481            }
482    
483            /**
484             * åˆè¨ˆã‚«ãƒ©ãƒ??カラãƒ?•°ã‚’è¿”ã—ã¾ã™ã?
485             *
486             * @return グループカラãƒ??カラãƒ?•°
487             */
488            public int getTotalClmCount() {
489                    return totalClmCount;
490            }
491    
492            /**
493             * ç·åˆè¨ˆè¡Œã‚’付加ã™ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
494             *
495             * @return true:対象 false:éžå¯¾è±¡
496             */
497            public boolean useGrandTotal() {
498                    return StringUtil.nval( editVals[EDIT_KEY_GRANDTOTAL], false );
499            }
500    
501            /**
502             * 表示é ?‚«ãƒ©ãƒ?‚’カンマ区åˆ?‚Šã§è¿”ã—ã¾ã™ã?
503             * カラãƒ??並ã³é ?Œè¡¨ç¤ºé ?¨ã—ã¦ã®å„ªå…ˆé?ã«ãªã‚Šã¾ã™ã?
504             * ã¾ãŸã?é™é?ã§è¡¨ç¤ºã™ã‚‹ã‚«ãƒ©ãƒ?«ã¤ã?¦ã¯ã€ã‚«ãƒ©ãƒ?ã®å…ˆé?ã«"!"ãŒä»˜åŠ ã•れã¾ã™ã?
505             *
506             * @return 標準é?カラãƒ??ä¸?¦§(カンマ区åˆ?
507             */
508            public String getOrderByClms() {
509                    return editVals[EDIT_KEY_ORDERBY];
510            }
511    
512            /**
513             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ??表示é ??優先番å·ã‚’è¿”ã—ã¾ã™ã?
514             * æŒ?®šã‚«ãƒ©ãƒ?Œæ¨™æº–ã¨ã—ã¦æŒ?®šã•れã¦ã?ªã??åˆã?ã€?"(ゼロストリング)ã‚’è¿”ã—ã¾ã™ã?
515             *
516             * @param clm カラ�
517             *
518             * @return 表示é ??優先番å·
519             */
520            public String getOrder( final String clm ) {
521                    if( clm == null || editVals[EDIT_KEY_ORDERBY] == null ) { return ""; }
522    
523                    String rtn = orderMap.get( clm );
524                    return ( rtn == null ? "" : rtn );
525            }
526    
527            /**
528             * æŒ?®šã•れãŸã‚«ãƒ©ãƒ??表示é ?Œ‡å®šãŒé™é?ã§ã‚ã‚‹ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
529             * æ¨™æº–ã¨æŒ?®šã•れã¦ã?ªã??åˆã?ã€falseã‚’è¿”ã—ã¾ã™ã?
530             *
531             * @param clm カラ�
532             *
533             * @return true:é™é? false:æ˜??
534             */
535            public boolean isOrderByDesc( final String clm ) {
536                    if( clm == null || orderByDescClms == null ) { return false; }
537                    return ( ( ","+orderByDescClms+"," ).indexOf( ","+clm+"," ) >= 0 );
538            }
539    
540            /**
541             * ä¸¦ã³æ›¿ãˆå?ç?‚’行ã†ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
542             * ã“れã¯ã€è¡¨ç¤ºé ?‚«ãƒ©ãƒ?ŒæŒ?®šã•れã¦ã?‚‹ã‹ã?ã¨åŒã˜æ„味ã§ã™ã?
543             *
544             * @return true:対象 false:éžå¯¾è±¡
545             */
546            public boolean useOrderBy() {
547                    return ( editVals[EDIT_KEY_ORDERBY] != null && editVals[EDIT_KEY_ORDERBY].length() > 0 );
548            }
549    
550            /**
551             * ã“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトãŒã€å?é€?全ユーザー公é–?エãƒ?‚£ãƒ?ƒˆã?
552             * ã©ã?‹ã‚’è¿”ã—ã¾ã™ã?
553             *
554             * @return 0以å¤?å…±é€?0:個人ã®ã¿
555             */
556            public boolean isCommon() {
557                    return StringUtil.nval( editVals[EDIT_KEY_COMMON], false );
558            }
559    }