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.fukurou.business;
017    
018    import java.sql.Connection;
019    import java.sql.ParameterMetaData;
020    import java.sql.PreparedStatement;
021    import java.sql.ResultSet;
022    import java.sql.ResultSetMetaData;
023    import java.sql.SQLException;
024    // import java.text.DateFormat;
025    // import java.text.SimpleDateFormat;
026    import java.util.Date;
027    import java.util.HashMap;
028    import java.util.Locale;
029    import java.util.Map;
030    import java.util.Set;
031    import java.util.Arrays;
032    
033    import org.opengion.fukurou.db.ConnectionFactory;
034    import org.opengion.fukurou.db.DBFunctionName;
035    import org.opengion.fukurou.db.DBUtil;
036    import org.opengion.fukurou.db.Transaction;
037    import org.opengion.fukurou.model.Formatter;
038    import org.opengion.fukurou.util.Closer;
039    import org.opengion.fukurou.util.ErrMsg;
040    import org.opengion.fukurou.util.ErrorMessage;
041    import org.opengion.fukurou.util.HybsLoader;
042    import org.opengion.fukurou.util.StringUtil;
043    import org.opengion.fukurou.util.SystemParameter;
044    import org.opengion.fukurou.util.HybsDateUtil;
045    
046    /**
047     * 業務ロジãƒ?‚¯ã‚’å?ç?™ã‚‹ãŸã‚ã«å¿?¦ãªå…±é€šãƒ¡ã‚½ãƒ?ƒ‰ã®å®Ÿè¡Œã‚’行ã£ã¦ã?‚‹æŠ½è±¡ã‚¯ãƒ©ã‚¹ã§ã™ã?
048     *
049     * メインロジãƒ?‚¯ã«ã¤ã?¦ã¯ã€å„サブクラスã§å®Ÿè£?™ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
050     *
051     * @og.rev 5.1.1.0 (2009/12/01) æ–°è¦ä½œæ?
052     * @og.group 業務ロジãƒ?‚¯
053     *
054     * @version 5.0
055     * @author Hiroki Nakamura
056     * @since JDK1.6,
057     */
058    public abstract class AbstractBizLogic {
059            private static final String CR = System.getProperty("line.separator");
060    
061            /** エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’ã‚»ãƒ?ƒˆã™ã‚‹éš›ã«ä½¿ç”¨ã—ã¾ã?{@value} */
062            protected static final int OK        = ErrorMessage.OK;
063            /** エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’ã‚»ãƒ?ƒˆã™ã‚‹éš›ã«ä½¿ç”¨ã—ã¾ã?{@value} */
064            protected static final int WARNING   = ErrorMessage.WARNING;
065            /** エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’ã‚»ãƒ?ƒˆã™ã‚‹éš›ã«ä½¿ç”¨ã—ã¾ã?{@value} */
066            protected static final int NG        = ErrorMessage.NG;
067            /** エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’ã‚»ãƒ?ƒˆã™ã‚‹éš›ã«ä½¿ç”¨ã—ã¾ã?{@value} */
068            protected static final int EXCEPTION = ErrorMessage.EXCEPTION;
069            /** エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’ã‚»ãƒ?ƒˆã™ã‚‹éš›ã«ä½¿ç”¨ã—ã¾ã?{@value} */
070            protected static final int ORCL_ERR  = ErrorMessage.ORCL_ERR;
071    
072            private Connection conn = null;
073            private Transaction tran = null; // 5.1.9.0 (2010/08/01) シーケンス対�
074            private String dbid = null; // 5.1.9.0 (2010/08/01) シーケンス対�
075            DBFunctionName dbName = null; //  5.1.9.0 (2010/08/01) シーケンス対�
076            private HybsLoader loader = null;
077            private String[] keys = null;
078            private String[] vals = null;
079            private final StringBuilder paramKeysStr = new StringBuilder( "|" );
080            private final Map<String, String> variableMap = new HashMap<String, String>();
081            private final Map<String, Formatter> formatMap = new HashMap<String, Formatter>();
082            private final Map<String, SystemParameter> sysParamMap = new HashMap<String, SystemParameter>();
083            private final ErrorMessage errMsg = new ErrorMessage();
084    //      private String rtn = null;
085            private String bizRtn = null;                   // 5.1.8.0 (2010/07/01) メソãƒ?ƒ‰åã¨å¤‰æ•°åã‚’åˆ?‘ã‚‹ã?
086    //      private boolean isDebug = false;
087            private boolean debugFlag = false;              // 5.1.8.0 (2010/07/01) メソãƒ?ƒ‰åã¨å¤‰æ•°åã‚’åˆ?‘ã‚‹ã?
088    
089            private final StringBuilder debugMsg = new StringBuilder();
090            private boolean useParamMetaData = false;       // 5.3.8.0 (2011/08/01) useParamMetaData ã‚?ConnectionFactory経由ã§å–å¾—ã?(PostgreSQL対å¿?
091    
092            /**
093             * é…å?å´ãƒ??ブルモãƒ?ƒ«
094             *
095             * é…å?型テーブルモãƒ?ƒ«è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
096             * ä½?—ã€ã“れã?ã€å„業務ロジãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
097             * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
098             * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
099             * ã“ã?ãŸã‚ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
100             */
101            protected ArrayTableModel table = null;
102    
103            /**
104             * é…å?型テーブルモãƒ?ƒ«ã®ç¾åœ¨ã®å‡¦ç?¡?
105             *
106             * 行番å·è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
107             * ä½?—ã€ã“れã?ã€å„業務ロジãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
108             * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
109             * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
110             * ã“ã?ãŸã‚ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
111             *
112             * ※ インãƒ?ƒƒã‚¯ã‚¹(row)ã¨ã¯ã€ã“ã®ArrayTableModel ã«æŒã¤ vals é…å?ã®è¡Œã?インãƒ?ƒƒã‚¯ã‚¹ã§ã™ã?
113             * よã£ã¦ã€ã‚ªãƒªã‚¸ãƒŠãƒ«ã®DBTableModelã®è¡Œç•ªå·ã§ã¯ã‚りã¾ã›ã‚“ã€?
114             */
115            protected int row = -1;
116    
117    //      /**
118    //       * DBã®ã‚³ãƒã‚¯ã‚·ãƒ§ãƒ³ã‚ªãƒ–ジェクトをæŒ?®šã—ã¾ã™ã?
119    //       * å?®Ÿè£?‚¯ãƒ©ã‚¹ã§ã¯ã€ã‚³ãƒã‚¯ã‚·ãƒ§ãƒ³ã®commit,rollbackã¯è¡Œã‚れã¾ã›ã‚“ã€?
120    //       * (å…¨ã¦ã®DB処ç??ã€?ã¤ã®ãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ã¨ã—ã¦å‡¦ç?•れã¾ã™ã?)
121    //       * ã“ã?ãŸã‚ã€commit,rollbackã¯å‘¼ã³å‡ºã—å?ã§è¡Œã†å¿?¦ãŒã‚りã¾ã™ã?
122    //       * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
123    //       *
124    //       * @param cn DB接�
125    //       */
126    //      void setConnection( final Connection cn ) {
127    //              if( conn != null ) { throw new RuntimeException( "æ—¢ã«æŽ¥ç¶šã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" ); }
128    //              conn = cn;
129    //      }
130    
131            /**
132             * DBã®ãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ã‚ªãƒ–ジェクトをæŒ?®šã—ã¾ã™ã?
133             * å?®Ÿè£?‚¯ãƒ©ã‚¹ã§ã¯ã€ã‚³ãƒã‚¯ã‚·ãƒ§ãƒ³ã®commit,rollbackã¯è¡Œã‚れã¾ã›ã‚“ã€?
134             * (å…¨ã¦ã®DB処ç??ã€?ã¤ã®ãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ã¨ã—ã¦å‡¦ç?•れã¾ã™ã?)
135             * ã“ã?ãŸã‚ã€commit,rollbackã¯å‘¼ã³å‡ºã—å?ã§è¡Œã†å¿?¦ãŒã‚りã¾ã™ã?
136             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
137             *
138             * @og.rev 5.1.9.0 (2010/08/01) æ–°è¦ä½œæ?
139             * @og.rev 5.3.8.0 (2011/08/01) useParamMetaData ã‚?ConnectionFactory経由ã§å–å¾—ã?(PostgreSQL対å¿?
140             *
141             * @param tr トランザクション
142             */
143            public void setTransaction( final Transaction tr ) {
144                    tran = tr;
145                    conn = tran.getConnection( dbid );
146                    useParamMetaData = ConnectionFactory.useParameterMetaData( dbid );      // 5.3.8.0 (2011/08/01)
147            }
148    
149            /**
150             * 接続å?IDを指定ã—ã¾ã™ã?
151             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
152             *
153             * @og.rev 5.1.9.0 (2010/08/01) æ–°è¦ä½œæ?
154             *
155             * @param id 接続å?ID
156             */
157            void setDbid( final String id ) {
158                    dbid = id;
159            }
160    
161            /**
162             * 業務ロジãƒ?‚¯ã®ã‚¯ãƒ©ã‚¹ã‚’ロードã™ã‚‹ãŸã‚ã?クラスローãƒ??ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
163             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
164             *
165             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
166             *
167             * @param ldr クラスロー�?
168             */
169            void setLoader( final HybsLoader ldr ) {
170                    if( loader != null ) {
171                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
172    //                      throw new RuntimeException( "æ—¢ã«ã‚¯ãƒ©ã‚¹ãƒ­ãƒ¼ãƒ??ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" );
173                            String errMsg = "æ—¢ã«ã‚¯ãƒ©ã‚¹ãƒ­ãƒ¼ãƒ??ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" ;
174                            throw new RuntimeException( errMsg );
175                    }
176                    loader = ldr;
177            }
178    
179            /**
180             * é…å?型テーブルモãƒ?ƒ«ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
181             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
182             *
183             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
184             *
185             * @param tbl é…å?型テーブルモãƒ?ƒ«
186             */
187            void setTable( final ArrayTableModel tbl ) {
188                    if( table != null ) {
189                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
190    //                      throw new RuntimeException( "æ—¢ã«é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" );
191                            String errMsg = "æ—¢ã«é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" ;
192                            throw new RuntimeException( errMsg );
193                    }
194                    table = tbl;
195            }
196    
197            /**
198             * 固定å?ã®ã‚­ãƒ¼ã‚’CSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
199             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
200             *
201             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
202             *
203             * @param ks キー
204             */
205            void setKeys( final String[] ks ) {
206                    if( keys != null ) {
207                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
208    //                      throw new RuntimeException( "æ—¢ã«å›ºå®šå?é…å?(キー)ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" );
209                            String errMsg = "æ—¢ã«å›ºå®šå?é…å?(キー)ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?"   + CR
210                                                    + "   KESY   =" + Arrays.toString( keys )                       + CR
211                                                    + "   in keys=" + Arrays.toString( ks ) ;
212                            throw new RuntimeException( errMsg );
213                    }
214                    keys = ks;
215            }
216    
217            /**
218             * 固定å?ã®å€¤ã‚’CSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
219             * ã“ã?メソãƒ?ƒ‰ã¯ã€?度ã—ã‹ã‚»ãƒ?ƒˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?回以上呼ã³å‡ºã—ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
220             *
221             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
222             *
223             * @param vs 値
224             */
225            void setVals( final String[] vs ) {
226                    if( vals != null ) {
227                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
228    //                      throw new RuntimeException( "æ—¢ã«å›ºå®šå?é…å?(値)ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?" );
229                            String errMsg = "æ—¢ã«å›ºå®šå?é…å?(値)ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã™ã?"     + CR
230                                                    + "   VALS   =" + Arrays.toString( vals )               + CR
231                                                    + "   in vals=" + Arrays.toString( vs ) ;
232                            throw new RuntimeException( errMsg );
233                    }
234                    vals = vs;
235            }
236    
237            /**
238             * ã“ã?処ç??実行ユーザーIDを指定ã—ã¾ã™ã?
239             *
240             * @param id 実行ユーザーID
241             */
242            void setUserId( final String id ) {
243                    variableMap.put( "CON.USERID", id);
244            }
245    
246            /**
247             * 親(呼ã³å‡ºã?PGIDを指定ã—ã¾ã™ã?
248             *
249             * @param id 親PGID
250             */
251            void setParentPgId( final String id ) {
252                    variableMap.put( "CON.PGPID", id );
253            }
254    
255            /**
256             * ãƒ?ƒãƒ?‚°ãƒ¢ãƒ¼ãƒ‰ã«ã—ã¾ã™ã?
257             */
258            void setDebug() {
259    //              isDebug = true;
260                    debugFlag = true;
261            }
262    
263            /**
264             * ãƒ?ƒãƒ?‚°ãƒ¡ãƒ?‚»ãƒ¼ã‚¸ã‚’å–å¾—ã—ã¾ã™ã?
265             *
266             * @return ãƒ?ƒãƒ?‚°ãƒ¡ãƒ?‚»ãƒ¼ã‚¸
267             */
268            String getDebugMsg() {
269                    return debugMsg.toString();
270            }
271    
272            /**
273             * 処ç?‚’実行ã—ã¾ã™ã?
274             * 処ç??方法ã?ã€main()メソãƒ?ƒ‰ã«ã‚ˆã‚Šå®šç¾©ã•れã¾ã™ã?
275             * 実è£?‚¯ãƒ©ã‚¹ã§ç™ºç”Ÿã—ãŸå?ã¦ã®ä¾‹å¤–ã?ã€Throwableオブジェクトã¨ã—ã¦ã‚¹ãƒ­ãƒ¼ã•れã¾ã™ã?
276             * 呼ã³å‡ºã—å?ã§ã¯ã€ä¾‹å¤–を確実ã«catchã—ã¦ã€commit,rollbackを行ã£ã¦ãã ã•ã„ã€?
277             *
278             * @og.rev 5.1.9.0 (2010/08/01) シーケンス対�
279             *
280             * @return 処ç?ŒæˆåŠŸã—ãŸã‹ã©ã?‹
281             * @throws Throwable
282             */
283            boolean exec() throws Throwable {
284                    dbName = DBFunctionName.getDBName( ConnectionFactory.getDBName( dbid ) );
285                    makeParamMap();
286                    init();
287                    return main();
288            }
289    
290            /**
291             * 処ç??メインロジãƒ?‚¯ã®å‰å?ç?‚’記述ã—ã¾ã™ã?
292             *
293             * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
294             * ä½?—ã€ã“れã?ã€å„業務ロジãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
295             * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
296             * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
297             * ã“ã?ãŸã‚ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
298             */
299            abstract protected void init();
300    
301            /**
302             * 処ç??メインロジãƒ?‚¯ã‚’記述ã—ã¾ã™ã?
303             *
304             * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
305             * ä½?—ã€ã“れã?ã€å„業務ロジãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
306             * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
307             * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
308             * ã“ã?ãŸã‚ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
309             *
310             * @return 処ç?Œæ­£å¸¸çµ‚äº?—ãŸã‹
311             */
312            abstract protected boolean main();
313    
314            /**
315             * çµæžœã‚¹ãƒ??タスを返ã—ã¾ã™ã?
316             *
317             * @return çµæžœã‚¹ãƒ??タス
318             */
319            int getKekka() {
320                    return errMsg.getKekka();
321            }
322    
323            /**
324             * エラーメãƒ?‚»ãƒ¼ã‚¸ã‚ªãƒ–ジェクトを返ã—ã¾ã™ã?
325             *
326             * @return エラーメãƒ?‚»ãƒ¼ã‚¸
327             */
328            ErrorMessage getErrMsg() {
329                    return errMsg;
330            }
331    
332            /**
333             * 業務ロジãƒ?‚¯ã®æˆ»ã‚Šå?ã‚’è¿”ã—ã¾ã™ã?
334             *
335             * @return 戻りå?
336             */
337            String getReturn() {
338                    return bizRtn;
339            }
340    
341            /**
342             * 業務ロジãƒ?‚¯ã‚’実行ã™ã‚‹ãŸã‚ã«ã€ãƒ†ãƒ¼ãƒ–ルモãƒ?ƒ«ãŒå¤–部ã‹ã‚‰ã‚»ãƒ?ƒˆã•れるå¿?¦ãŒã‚ã‚‹ã?
343             * ã‚’è¿”ã—ã¾ã™ã?
344             * å¿??ã§ã‚ã‚‹å ´åˆã?ãã?業務ロジãƒ?‚¯ã¯ã€å­ãƒ­ã‚¸ãƒ?‚¯ã¨ã—ã¦å‘¼ã³å‡ºã™ã“ã¨ãŒã§ãã¾ã›ã‚“ã€?
345             * ã“れã¯ã€å­ãƒ­ã‚¸ãƒ?‚¯å‘¼ã³å‡ºã—時ã¯ã€ãƒ†ãƒ¼ãƒ–ルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れãªã?Ÿã‚ã§ã™ã?
346             * (ã“ã?クラスã¯ã€ãƒ†ãƒ¼ãƒ–ルモãƒ?ƒ«ãŒå¤–部ã‹ã‚‰æŒ?®šã•れã¦ã?‚‹å¿?¦ã?ã‚りã¾ã›ã‚“ã€?
347             *
348             * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
349             * ä½?—ã€ã“れã?ã€å„業務ロジãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
350             * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
351             * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
352             * ã“ã?ãŸã‚ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
353             *
354             * @return      ãƒ??ブルモãƒ?ƒ«ãŒå¤–部ã‹ã‚‰ã‚»ãƒ?ƒˆã•れるå¿?¦ãŒã‚ã‚‹ã‹ã©ã?‹(常ã«false)
355             */
356            protected boolean isRequireTable() {
357                    return false;
358            }
359    
360            /**
361             * ãƒ?ƒãƒ?‚°ãƒ¢ãƒ¼ãƒ‰ã‹ã©ã?‹ã‚’è¿”ã—ã¾ã?
362             *
363             * @return ãƒ?ƒãƒ?‚°ãƒ¢ãƒ¼ãƒ‰ã‹ã©ã?‹
364             */
365            final protected boolean isDebug() {
366    //              return isDebug;
367                    return debugFlag;
368            }
369    
370            /**
371             * ãƒ?ƒãƒ?‚°ãƒ¡ãƒ?‚»ãƒ¼ã‚¸ã‚’追åŠ?—ã¾ã™ã?
372             *
373             * @param msg 追åŠ?™ã‚‹ãƒ‡ãƒãƒƒã‚°ãƒ¡ãƒ?‚»ãƒ¼ã‚¸
374             */
375            final protected void debug( final String msg ) {
376                    debugMsg.append( msg ).append( CR );
377            }
378    
379            /**
380             * æŒ?®šã•れãŸã‚­ãƒ¼ã®å€¤ã‚’è¿”ã—ã¾ã™ã?
381             *
382             * @param key キー
383             *
384             * @return 変数値
385             */
386            final protected String var( final String key ) {
387                    return variableMap.get( key );
388            }
389    
390            /**
391             * æŒ?®šã•れãŸã‚­ãƒ¼ã®å€¤ã‚’intåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
392             *
393             * @param key キー
394             *
395             * @return 変数値
396             */
397            final protected int vari( final String key ) {
398                    return var( key ) == null ? 0 : Integer.valueOf( var( key ) );
399            }
400    
401            /**
402             * æŒ?®šã•れãŸã‚­ãƒ¼ã®å€¤ã‚’doubleåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
403             *
404             * @param key キー
405             *
406             * @return 変数値
407             */
408            final protected double vard( final String key ) {
409                    return var( key ) == null ? 0.0 : Double.valueOf( var( key ) );
410            }
411    
412            /**
413             * パラメーターã®ã‚­ãƒ¼ä¸?¦§ã‚’é?列形å¼ã§è¿”ã—ã¾ã™ã?
414             * ã“ã?パラメーターã¯ã€æ¥­å‹™ãƒ­ã‚¸ãƒ?‚¯å†?§ã‚»ãƒ?ƒˆã•れãŸãƒ‘ラメーターもå«ã¾ã‚Œã¾ã™ã?ã§ã”注æ„下ã•ã??
415             *
416             * @return パラメーターã®ã‚­ãƒ¼é…å?
417             */
418            final protected String[] varKeys() {
419    //              return variableMap.keySet().toArray( new String[0] );
420                    Set<String> keys = variableMap.keySet();
421                    return keys.toArray( new String[keys.size()] );
422            }
423    
424            /**
425             * æŒ?®šã•れãŸã‚­ãƒ¼ã§å€¤ã‚’登録ã—ã¾ã™ã?
426             * パラメーターã¨ã—ã¦ã“ã?業務ロジãƒ?‚¯ãŒå‘¼ã°ã‚Œã‚‹éš›ã?引数ã¨ãªã£ã¦ã?‚‹å ´åˆã?ã€?
427             * エラーã¨ãªã‚Šã¾ã™ã?
428             *
429             * @og.rev 5.2.1.0 (2010/10/01) ãƒã‚§ãƒ?‚¯ã®ãƒã‚°ã‚’修正
430             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
431             *
432             * @param key キー
433             * @param val 値
434             */
435            final protected void set( final String key, final String val ) {
436    //              if( paramKeysStr.indexOf( key ) >= 0 ) {
437                    if( paramKeysStr.indexOf( "|" + key + "|" ) >= 0 ) {
438                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
439    //                      throw new RuntimeException( "引数ã¨åŒã˜åå‰ã®å¤‰æ•°ã‚’定義ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" );
440                            String errMsg = "引数ã¨åŒã˜åå‰ã®å¤‰æ•°ã‚’定義ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€?       + CR
441                                                    + "   key   =" + key                            + CR
442                                                    + "   引数  =" + paramKeysStr ;
443                            throw new RuntimeException( errMsg );
444                    }
445                    variableMap.put( key, val );
446            }
447    
448            /**
449             * æŒ?®šã•れãŸã‚­ãƒ¼ã§å€¤ã‚’登録ã—ã¾ã™ã?
450             * パラメーターã¨ã—ã¦ã“ã?業務ロジãƒ?‚¯ãŒå‘¼ã°ã‚Œã‚‹éš›ã?引数ã¨ãªã£ã¦ã?‚‹å ´åˆã?ã€?
451             * エラーã¨ãªã‚Šã¾ã™ã?
452             *
453             * @og.rev 5.1.9.0 (2010/08/01) æ–°è¦ä½œæ?
454             *
455             * @param key キー
456             * @param val 値
457             */
458            final protected void set( final String key, final int val ) {
459                    set( key, String.valueOf( val ) );
460            }
461    
462            /**
463             * æŒ?®šã•れãŸã‚­ãƒ¼ã§å€¤(doubleåž?を登録ã—ã¾ã™ã?
464             * パラメーターã¨ã—ã¦ã“ã?業務ロジãƒ?‚¯ãŒå‘¼ã°ã‚Œã‚‹éš›ã?引数ã¨ãªã£ã¦ã?‚‹å ´åˆã?ã€?
465             * エラーã¨ãªã‚Šã¾ã™ã?
466             *
467             * @og.rev 5.1.9.0 (2010/08/01) æ–°è¦ä½œæ?
468             *
469             * @param key キー
470             * @param val 値
471             */
472            final protected void set( final String key, final double val ) {
473                    set( key, String.valueOf( val ) );
474            }
475    
476            /**
477             * 処ç?¸­ã®è¡Œã?æŒ?®šã•れãŸã‚­ãƒ¼(カラãƒ?)ã®å€¤ã‚’è¿”ã—ã¾ã™ã?
478             *
479             * @param key キー
480             *
481             * @return 値
482             */
483            final protected String line( final String key ) {
484                    return line( key, row );
485            }
486    
487            /**
488             * メインã®é…å?型テーブルモãƒ?ƒ«ã«å¯¾ã—ã¦ã€è¡Œã‚’æŒ?®šã—ã¦å€¤ã‚’å–å¾—ã—ã¾ã™ã?
489             * æŒ?®šã•れãŸè¡ŒãŒç¯?›²ã‚’è¶?ˆã¦ã?‚‹å ´åˆã?ã€nullã‚’è¿”ã—ã¾ã™ã?
490             *
491             * @og.rev 5.1.8.0 (2010/07/01) ãƒ??ブルã«å­˜åœ¨ã—ãªã?‚«ãƒ©ãƒ?を指定ã—ãŸå?åˆã«ã€NullPointerExceptionãŒç™ºç”Ÿã™ã‚‹ãƒã‚°ã‚’修正
492             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
493             *
494             * @param key キー
495             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
496             *
497             * @return 値
498             */
499            final protected String line( final String key, final int rw ) {
500    //              return( rw < 0 || rw >= table.getRowCount() ? null : table.getValue( rw, key ) );
501                    if( table == null ) {
502                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
503    //                      throw new RuntimeException( "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#line()メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€? );
504                            String errMsg = "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#line( String,int )メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€?     + CR
505                                                    + "   line( " + key + "," + rw + " );"  + CR ;
506                            throw new RuntimeException( errMsg );
507                    }
508                    else if( rw < 0 || rw >= table.getRowCount() ) {
509                            return null;
510                    }
511                    else {
512                            int col = table.getColumnNo( key );
513                            if( col < 0 ) {
514                                    return null;
515                            }
516                            else {
517                                    return table.getValue( rw, col );
518                            }
519                    }
520            }
521    
522            /**
523             * 処ç?¸­ã®è¡Œã?æŒ?®šã•れãŸã‚­ãƒ¼(カラãƒ?)ã®å€¤ã‚’intåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
524             *
525             * @param key キー
526             *
527             * @return 値
528             */
529            final protected int linei( final String key ) {
530                    return line( key ) == null ? 0 : Integer.valueOf( line( key ) );
531            }
532    
533            /**
534             * メインã®é…å?型テーブルモãƒ?ƒ«ã«å¯¾ã—ã¦ã€è¡Œã‚’æŒ?®šã—ã¦å€¤ã‚’intåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
535             * æŒ?®šã•れãŸè¡ŒãŒç¯?›²ã‚’è¶?ˆã¦ã?‚‹å ´åˆã?ã€nullã‚’è¿”ã—ã¾ã™ã?
536             *
537             * @param key キー
538             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
539             *
540             * @return 値
541             */
542            final protected int linei( final String key, final int rw ) {
543                    return line( key, rw ) == null ? 0 : Integer.valueOf( line( key, rw ) );
544            }
545    
546            /**
547             * 処ç?¸­ã®è¡Œã?æŒ?®šã•れãŸã‚­ãƒ¼(カラãƒ?)ã®å€¤ã‚’doubleåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
548             *
549             * @param key キー
550             *
551             * @return 値
552             */
553            final protected double lined( final String key ) {
554                    return line( key ) == null ? 0.0 : Double.valueOf( line( key ) );
555            }
556    
557            /**
558             * メインã®é…å?型テーブルモãƒ?ƒ«ã«å¯¾ã—ã¦ã€è¡Œã‚’æŒ?®šã—ã¦å€¤ã‚’doubleåž‹ã«å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
559             * æŒ?®šã•れãŸè¡ŒãŒç¯?›²ã‚’è¶?ˆã¦ã?‚‹å ´åˆã?ã€nullã‚’è¿”ã—ã¾ã™ã?
560             *
561             * @param key キー
562             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
563             *
564             * @return 値
565             */
566            final protected double lined( final String key, final int rw ) {
567                    return line( key, rw ) == null ? 0.0 : Double.valueOf( line( key, rw ) );
568            }
569    
570            /**
571             * ãƒ??ブルã®ã‚«ãƒ©ãƒ?ã®ä¸?¦§ã‚’é?列形å¼ã§è¿”ã—ã¾ã™ã?
572             *
573             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
574             *
575             * @return ãƒ??ブルã®ã‚«ãƒ©ãƒ?é…å?
576             */
577            final protected String[] lineKeys() {
578                    if( table == null ) {
579                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
580    //                      throw new RuntimeException( "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#line()メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€? );
581                            String errMsg = "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#lineKeys()メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€? ;
582                            throw new RuntimeException( errMsg );
583                    }
584                    else {
585                            return table.getNames();
586                    }
587            }
588    
589            /**
590             * ãƒ??ブルã«ã‚«ãƒ©ãƒ?Œå­˜åœ¨ã—ã¦ã?‚‹ã‹ã‚’è¿”ã—ã¾ã™ã?
591             *
592             * @og.rev 5.2.0.0 (2010/09/01)
593             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
594             *
595             * @param clm カラ�
596             *
597             * @return 存在ã—ã¦ã?‚‹å ´å?rueã€å­˜åœ¨ã—ã¦ã?ªã??å?alse
598             */
599            final protected boolean isLine( final String clm ) {
600                    if( table == null ) {
601                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
602    //                      throw new RuntimeException( "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#line()メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€? );
603                            String errMsg = "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?ªã?Ÿã‚ã?#isLine( String )メソãƒ?ƒ‰ã¯ã§ãã¾ã›ã‚“ã€?       + CR
604                                                    + "   isLine( " + clm + " );"   + CR ;
605                            throw new RuntimeException( errMsg );
606                    }
607                    return ( table.getColumnNo( clm ) < 0 ) ? false : true ;
608            }
609    
610            /**
611             * 業務ロジãƒ?‚¯ã®æˆ»ã‚Šå?ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
612             *
613             * @param rtn 戻りå?
614             */
615            final protected void rtn( final String rtn ) {
616    //      final protected void setReturn( final String rtn ) {
617    //              rtn = r;
618                    bizRtn = rtn;
619            }
620    
621            /**
622             * å­ãƒ­ã‚¸ãƒ?‚¯ã‚’実行ã—ã¾ã™ã?
623             * 実行ã™ã‚‹å­ãƒ­ã‚¸ãƒ?‚¯ã®å‘¼ã³å‡ºã—ã?ã€è¦ªã‚¯ãƒ©ã‚¹ã¨åŒã˜ã‚½ãƒ¼ã‚¹ãƒ‘スã€ã‚¯ãƒ©ã‚¹ãƒ‘スã§å‘¼ã³å‡ºã—ã•れã¾ã™ã?
624             * å­ãƒ­ã‚¸ãƒ?‚¯ã«æ¸¡ã™å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
625             * ã¾ãŸã?å­ãƒ­ã‚¸ãƒ?‚¯ã®æˆ»ã‚Šå?ã¯ã€val("SUB_RETURN")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
626             *
627             * @param subLogicName å­ãƒ­ã‚¸ãƒ?‚¯å?
628             * @param key キー(CSV形�
629             * @param val 値(CSV形�
630             *
631             * @return 処ç?Œæ­£å¸¸çµ‚äº?—ãŸã‹
632             */
633            final protected boolean call( String subLogicName, String key, String val ) {
634                    return call( subLogicName, key, val, row, table );
635            }
636    
637            /**
638             * å­ãƒ­ã‚¸ãƒ?‚¯ã‚’実行ã—ã¾ã™ã?
639             * 実行ã™ã‚‹å­ãƒ­ã‚¸ãƒ?‚¯ã®å‘¼ã³å‡ºã—ã?ã€è¦ªã‚¯ãƒ©ã‚¹ã¨åŒã˜ã‚½ãƒ¼ã‚¹ãƒ‘スã€ã‚¯ãƒ©ã‚¹ãƒ‘スã§å‘¼ã³å‡ºã—ã•れã¾ã™ã?
640             * å­ãƒ­ã‚¸ãƒ?‚¯ã«æ¸¡ã™å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
641             * ã“ã?å ´åˆã?値ã¯ã€å¼•æ•°ã§æŒ?®šã•れãŸã€??列型ãƒ??ブルモãƒ?ƒ«ã®è¡Œã«å¯¾å¿œã™ã‚‹å?ã«ãªã‚Šã¾ã™ã?
642             * ã¾ãŸã?å­ãƒ­ã‚¸ãƒ?‚¯ã®æˆ»ã‚Šå?ã¯ã€val("RETURN")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
643             *
644             * @og.rev 5.1.9.0 (2010/08/01) シーケンス対�
645             * @og.rev 5.4.1.0 (2011/11/01) 値ã«ã‚«ãƒ³ãƒžãŒå«ã¾ã‚Œã¦ã?‚‹å ´åˆã«æ­£ã—ã動作ã—ãªã?ƒã‚°ã‚’修正
646             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
647             *
648             * @param subLogicName å­ãƒ­ã‚¸ãƒ?‚¯å?
649             * @param key キー(CSV形�
650             * @param val 値(CSV形�
651             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
652             * @param tbl é…å?型テーブルモãƒ?ƒ«
653             *
654             * @return 処ç?Œæ­£å¸¸çµ‚äº?—ãŸã‹
655             */
656            final protected boolean call( String subLogicName, String key, String val, int rw, ArrayTableModel tbl ) {
657                    AbstractBizLogic subLogic = (AbstractBizLogic)loader.newInstance( subLogicName );
658    
659                    if( subLogic.isRequireTable() ) {
660                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
661    //                      throw new RuntimeException( "ã“ã?クラスã¯ã€å¤–部ã‹ã‚‰ãƒ??ブルモãƒ?ƒ«ã‚’ã‚»ãƒ?ƒˆã™ã‚‹å¿?¦ãŒã‚ã‚‹ãŸã‚ã€å­ãƒ­ã‚¸ãƒ?‚¯ã¨ã—ã¦å‘¼ã³å‡ºã™ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€?クラスå?" + subLogic.getClass().getName() + "]" );
662                            String errMsg = "ã“ã?クラスã¯ã€å¤–部ã‹ã‚‰ãƒ??ブルモãƒ?ƒ«ã‚’ã‚»ãƒ?ƒˆã™ã‚‹å¿?¦ãŒã‚ã‚‹ãŸã‚ã€å­ãƒ­ã‚¸ãƒ?‚¯ã¨ã—ã¦å‘¼ã³å‡ºã™ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€? + CR
663                                                    + "  [クラスå?" + subLogic.getClass().getName() + "]"   + CR
664                                                    + "   subLogicName =" + subLogicName 
665                                                    + "   key =[" + key + "]"
666                                                    + "   val =[" + val + "]" + CR ;
667                            throw new RuntimeException( errMsg );
668                    }
669    
670    //              subLogic.setConnection( conn );
671                    subLogic.setTransaction( tran );
672                    subLogic.setLoader( loader );
673                    subLogic.setKeys( StringUtil.csv2Array( key ) );
674    //              subLogic.setVals( StringUtil.csv2Array( replaceParam( val, rw, tbl ) ) );
675                    // 5.4.1.0 (2011/11/01) 値ã«ã‚«ãƒ³ãƒžãŒå«ã¾ã‚Œã¦ã?‚‹å ´åˆã«æ­£ã—ã動作ã—ãªã?ƒã‚°ã‚’修正
676                    String[] vals = StringUtil.csv2Array( val );
677                    for( int i=0; i<vals.length; i++ ) {
678                            vals[i] = replaceParam( vals[i], rw, tbl );
679                    }
680                    subLogic.setVals( vals );
681                    subLogic.setUserId( variableMap.get( "CON.USERID" ) );
682                    subLogic.setParentPgId( variableMap.get( "CON.PGID" ) );
683                    if( debugFlag ) {
684                            subLogic.setDebug();
685                    }
686    
687                    boolean rtn = false;
688                    try {
689                            rtn = subLogic.exec();
690                    }
691                    catch( Throwable th ) {
692    //                      // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
693    //                      throw new RuntimeException( "å­ãƒ­ã‚¸ãƒ?‚¯ã®å‘¼ã³å‡ºã—ã§ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸã€?logic=" + subLogicName + "]", th );
694                            String errMsg = "å­ãƒ­ã‚¸ãƒ?‚¯ã®å‘¼ã³å‡ºã—ã§ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸã€? + CR
695                                                    + "   subLogicName =" + subLogicName  + CR
696                                                    + "   key =[" + key + "]"
697                                                    + "   val =[" + val + "]" + CR ;
698                            throw new RuntimeException( errMsg ,th );
699                    }
700                    variableMap.put( "RETURN", subLogic.getReturn() );
701    
702                    if( debugFlag ) { debug( subLogic.getDebugMsg() ); }
703    
704                    ErrMsg[] errs = subLogic.getErrMsg().toArray();
705                    if( errs.length > 0 ) {
706                            ErrorMessage errMsgTmp = new ErrorMessage();
707                            for( int i = 0; i < errs.length; i++ ) {
708    //                              errMsgTmp.addMessage( errs[i].copy( errs[i].getNo() + rw ) );
709                                    errMsgTmp.addMessage( errs[i].copy( rw ) );
710                            }
711                            errMsg.append( errMsgTmp );
712                    }
713    
714                    return rtn;
715            }
716    
717            /**
718             * SQLを実行ã—ã¾ã™ã?
719             * SQLæ–?«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
720             * selectæ–?‚’発行ã—ãŸå?åˆã?ãã?çµæžœã‚»ãƒ?ƒˆã¯ã€var(カラãƒ?)ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
721             * 2行以上ãŒè¿”ã•れãŸå ´åˆã§ã‚‚ã?1行目ã®ã¿ãŒç™»éŒ²ã•れã¾ã™ã?
722             * ã¾ãŸã?æ¤œç´¢ä»¶æ•°ã€æ›´æ–°ä»¶æ•°ã«ã¤ã?¦ã¯ã€var("SQL_ROWCOUNT")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
723             *
724             * @param sq SQLæ–?­—å?
725             */
726            final protected void sql( final String sq ) {
727                    sql( sq, row, table );
728            }
729    
730            /**
731             * SQLを実行ã—ã¾ã™ã?
732             * SQLæ–?«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
733             * [XXXX]å½¢å¼ã?変数ã®ç½®ãæ›ãˆã«ã¯ã€å¼•æ•°ã§æŒ?®šã•れãŸé…å?型テーブルモãƒ?ƒ«ã®è¡ŒãŒä½¿ç”¨ã•れã¾ã™ã?
734             * selectæ–?‚’発行ã—ãŸå?åˆã?ãã?çµæžœã‚»ãƒ?ƒˆã¯ã€var(カラãƒ?)ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
735             * 2行以上ãŒè¿”ã•れãŸå ´åˆã§ã‚‚ã?1行目ã®ã¿ãŒç™»éŒ²ã•れã¾ã™ã?
736             * ã¾ãŸã?æ¤œç´¢ä»¶æ•°ã€æ›´æ–°ä»¶æ•°ã«ã¤ã?¦ã¯ã€var("SQL_ROWCOUNT")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
737             *
738             * @param sq SQLæ–?­—å?
739             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
740             * @param tbl é…å?型テーブルモãƒ?ƒ«
741             */
742            final protected void sql( final String sq, final int rw, final ArrayTableModel tbl ) {
743                    ArrayTableModel tbl2 = execSQL( sq, rw, tbl );
744    
745                    if( tbl2 != null && tbl2.getRowCount() > 0 ) {
746                            String[] names = tbl2.getNames();
747                            String[] vals = tbl2.getValues( 0 );
748                            for( int i = 0; i < names.length; i++ ) {
749                                    variableMap.put( names[i], vals[i] );
750                            }
751                    }
752            }
753    
754            /**
755             * シーケンスåよりシーケンスオブジェクトを検索ã—ã?次ã®å€¤ã‚’å–りå?ã—ã¾ã™ã?
756             * DBã«å¯¾ã™ã‚‹ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚ªãƒ–ジェクトã?予ã‚作æ?ã•れã¦ã?‚‹å¿?¦ãŒã‚りã¾ã™ã?
757             *
758             * ã¾ãŸã?MySQLã®å ´åˆã?ã€ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚ªãƒ–ジェクトãŒå®Ÿè£?•れã¦ã?ªã?Ÿã‚ã?
759             * å†?ƒ¨çš?«ã¯ã€å¼•æ•°ã®ã‚·ãƒ¼ã‚±ãƒ³ã‚¹åã¨åŒã˜åå‰ã®ãƒ??ブルã‹ã‚‰ã€Integeråž‹ã?
760             * "SEQID"ã¨ã?†é ?›®åを検索ã™ã‚‹ã“ã¨ã«ã‚ˆã‚Šã€ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚’エミュレートã—ã¦ã?¾ã™ã?
761             *
762             * @og.rev 5.1.9.0 (2010/08/01) æ–°è¦è¿½åŠ?
763             *
764             * @param seqName       シーケンスå?
765             *
766             * @return シーケンス番å·
767             * @see org.opengion.fukurou.db.DBFunctionName#getSequence(String,Transaction)
768             */
769            final protected int seq( final String seqName ) {
770                    return dbName.getSequence( seqName, tran );
771            }
772    
773            /**
774             * SQLを実行ã—ã¾ã™ã?
775             *
776             * @param sq SQLæ–?­—å?
777             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
778             * @param tbl é…å?型テーブルモãƒ?ƒ«
779             *
780             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
781             *
782             * @return çµæžœã‚»ãƒ?ƒˆ(é…å?型テーブルモãƒ?ƒ«)
783             *
784             * @og.rev 5.1.2.0 (2010/01/01) setObject ã« ParameterMetaData ã® getParameterType を渡ã™ã?(PostgreSQL対å¿?
785             * @og.rev 5.1.8.0 (2010/07/01) columnåã?大æ–?­—化ã—ã?é ?›®åã?å–å¾—ã?#getColumnLabel()ã§è¡Œã†ã€?PotgreSQL対å¿?ãƒã‚°ä¿®æ­£)
786             * @og.rev 5.3.8.0 (2011/08/01) useParamMetaData ã‚?ConnectionFactory経由ã§å–å¾—ã?(PostgreSQL対å¿?ã€setNull 対å¿?
787             */
788            private ArrayTableModel execSQL( final String sq, final int rw, final ArrayTableModel tbl ) {
789                    String sql = sq;
790    
791                    sql = replaceParam( sql, false ); // [XXXX]ã®å¤‰æ›ã¯ã“ã“ã§ã¯è¡Œã‚ãªã??
792    
793                    Formatter format = null;
794                    if( tbl != null && sql.indexOf( '[' ) >= 0 ) {
795                            format = getFormatter( sql, tbl );
796                            sql = format.getQueryFormatString();
797                    }
798    
799                    PreparedStatement pstmt = null;
800                    ResultSet result = null;
801                    ArrayTableModel tbl2 = null;
802                    try {
803                            pstmt = conn.prepareStatement( sql );
804                            if( tbl != null && format != null ) {
805                                    int[] clmNo = format.getClmNos();
806    
807                                    // 5.1.2.0 (2010/01/01) setObject ã« ParameterMetaData ã® getParameterType を渡ã™ã?(PostgreSQL対å¿?
808    //                              boolean useParamMetaData = ApplicationInfo.useParameterMetaData( conn );        // 5.3.8.0 (2011/08/01)
809                                    if( useParamMetaData ) {
810                                            ParameterMetaData pMeta = pstmt.getParameterMetaData();
811                                            for( int i = 0; i < clmNo.length; i++ ) {
812                                                    int   type = pMeta.getParameterType( i+1 );
813                                                    // 5.3.8.0 (2011/08/01) setNull 対�
814    //                                              pstmt.setObject( i+1, tbl.getValue( rw, clmNo[i] ), type );
815                                                    String val = tbl.getValue( rw, clmNo[i] );
816                                                    if( val == null || val.isEmpty() ) {
817                                                            pstmt.setNull( i+1, type );
818                                                    }
819                                                    else {
820                                                            pstmt.setObject( i+1, val, type );
821                                                    }
822                                            }
823                                    }
824                                    else {
825                                            for( int i = 0; i < clmNo.length; i++ ) {
826                                                    pstmt.setObject( i+1, tbl.getValue( rw, clmNo[i] ) );
827                                            }
828                                    }
829                            }
830                            boolean status = pstmt.execute();
831                            result = pstmt.getResultSet();
832    
833                            if( status ) {
834                                    ResultSetMetaData metaData = result.getMetaData();
835                                    int cols = metaData.getColumnCount();
836    
837                                    String[] names = new String[cols];
838                                    for( int i = 0; i < cols; i++ ) {
839                                            // 5.1.8.0 (2010/07/01) columnåã?大æ–?­—化ã—ã?é ?›®åã?å–å¾—ã?#getColumnLabel()ã§è¡Œã†ã€?PotgreSQL対å¿?ãƒã‚°ä¿®æ­£)
840    //                                      names[i] = metaData.getColumnName( i+1 );
841                                            names[i] = metaData.getColumnLabel( i+1 ).toUpperCase( Locale.JAPAN );
842                                    }
843    
844                                    String[][] tblVals = DBUtil.resultToArray( result, false );
845                                    tbl2 = new ArrayTableModel( names, tblVals );
846    
847                                    variableMap.put( "SQL_ROWCOUNT", String.valueOf( pstmt.getFetchSize() ) );
848                            }
849                            else {
850                                    variableMap.put( "SQL_ROWCOUNT", String.valueOf( pstmt.getUpdateCount() ) );
851                            }
852                    }
853                    catch( SQLException ex ) {
854                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
855    //                      throw new RuntimeException( "é…å?型テーブルモãƒ?ƒ«ã®ç”Ÿæ?ã«å¤±æ•—ã—ã¾ã—ãŸ", ex );
856                            String errMsg = "é…å?型テーブルモãƒ?ƒ«ã®ç”Ÿæ?ã«å¤±æ•—ã—ã¾ã—ãŸã€?    + CR
857                                                    + "   sql =" + sql              + CR
858                                                    + "   ArrayTableModel=" + tbl ;
859                            throw new RuntimeException( errMsg,ex );
860                    }
861                    finally {
862                            Closer.resultClose( result );
863                            Closer.stmtClose( pstmt );
864                    }
865                    return tbl2;
866            }
867    
868            /**
869             * エラーメãƒ?‚»ãƒ¼ã‚¸ã‚’追åŠ?—ã¾ã™ã?
870             * エラーメãƒ?‚»ãƒ¼ã‚¸ã®å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
871             *
872             * @param kekka エラーレベル
873             * @param id エラーメãƒ?‚»ãƒ¼ã‚¸ID
874             * @param args エラーメãƒ?‚»ãƒ¼ã‚¸ãƒ‘ラメーター
875             */
876            final protected void error( final int kekka, final String id, final String... args ) {
877                    error( row, kekka, id, args );
878            }
879    
880            /**
881             * 行指定ã§ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒ?‚»ãƒ¼ã‚¸ã‚’追åŠ?—ã¾ã™ã?
882             * エラーメãƒ?‚»ãƒ¼ã‚¸ã®å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
883             *
884             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
885             * @param kekka エラーレベル
886             * @param id エラーメãƒ?‚»ãƒ¼ã‚¸ID
887             * @param args エラーメãƒ?‚»ãƒ¼ã‚¸ãƒ‘ラメーター
888             */
889            final protected void error( final int rw, final int kekka, final String id, final String... args ) {
890                    errMsg.addMessage( rw, kekka, id, replaceParam( args ) );
891            }
892    
893            /**
894             * パラメーターã®å¿??ãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
895             * キーã¯ã€ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã§è¤?•°æŒ?®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
896             *
897             * @param cs カラãƒ?カンマ区åˆ?‚Š)
898             *
899             * @return エラーãŒç™ºç”Ÿã—ãŸå?åˆã?falseã€ãれ以外ã?true
900             */
901            final protected boolean must( final String cs ) {
902                    if( cs == null || cs.length() == 0 ) {
903                            return true;
904                    }
905    
906                    boolean rtn = true;
907                    String[] clms = StringUtil.csv2Array( cs );
908                    for( int i=0; i<clms.length; i++ ) {
909                            String val = variableMap.get( clms[i] );
910                            if( val == null || val.length() == 0 ) {
911                                    error( 2, "ERR0012", "{#" + clms[i] + "}" );
912                                    rtn = false;
913                            }
914                    }
915                    return rtn;
916            }
917    
918            /**
919             * マスタãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
920             *
921             * @og.rev 5.6.3.1 (2013/04/05) isErrThrow 引数を追�
922             *
923             * @see #exist(String, String, String, String, String, String)
924             * @param type エラーãƒã‚§ãƒ?‚¯ã®ã‚¿ã‚¤ãƒ?
925             * @param tblId ãƒ??ブルå?
926             * @param ns カラãƒ?カンマ区åˆ?‚Š)
927             * @param vs 値(カンマ区åˆ?‚Š)
928             *
929             * @return エラーãŒç™ºç”Ÿã—ãŸå?åˆã?falseã€ãれ以外ã?true
930             */
931            final protected boolean exist( final String type, final String tblId, final String ns, final String vs ) {
932    //              return exist( type, tblId, ns, vs, null, null );
933                    return exist( type, tblId, ns, vs, null, null,true );
934            }
935    
936            /**
937             * マスタãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
938             *
939             * å¼•æ•°ã«æŒ?®šã•れãŸãƒ??ブルåã?åŠã?æ¡ä»¶å¥ã‚’生æˆã™ã‚‹ãŸã‚ã?カラãƒ??値ã‹ã‚‰
940             * ä»¶æ•°ã‚’å–å¾—ã—ã€typeã«å¿œã˜ã¦ä»¶æ•°ãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
941             * (カラãƒ??値ã«ã¯ã€ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã§è¤?•°æŒ?®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã?
942             *  type=true  存在ã™ã‚‹å ´å?rue  存在ã—ãªã??å?alse
943             *  type=false 存在ã™ã‚‹å ´å?alse 存在ã—ãªã??å?rue
944             *  type=one   1件以�   true  2件以�    false
945             *
946             * å¿??ãƒã‚§ãƒ?‚¯ã®å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
947             *
948             * ã¾ãŸã?固定å?カラãƒ??値ã«ã‚‚æ¡ä»¶ã¨ãªã‚‹ã‚«ãƒ©ãƒ?Šã³å€¤ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ãŒã€?
949             * ã“ã“ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ??ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒ?‚»ãƒ¼ã‚¸è¡¨ç¤ºæ™‚ã«ã‚«ãƒ©ãƒ??値ãŒç”»é¢ã«è¡¨ç¤ºã•れã¾ã›ã‚“ã€?
950             *
951             * @og.rev 5.6.3.1 (2013/04/05) isErrThrow 引数を追�
952             *
953             * @param type エラーãƒã‚§ãƒ?‚¯ã®ã‚¿ã‚¤ãƒ?
954             * @param tblId ãƒ??ブルå?
955             * @param ns カラãƒ?カンマ区åˆ?‚Š)
956             * @param vs 値(カンマ区åˆ?‚Š)
957             * @param conNs 固定å?カラãƒ?カンマ区åˆ?‚Š)
958             * @param conVs 固定å?(カンマ区åˆ?‚Š)
959             *
960             * @return エラーãŒç™ºç”Ÿã—ãŸå?åˆã?falseã€ãれ以外ã?true
961             */
962            final protected boolean exist( final String type, final String tblId
963                            , final String ns, final String vs, final String conNs, final String conVs ) {
964                    return exist( type, tblId, ns, vs, conNs, conVs,true );
965            }
966    
967            /**
968             * マスタãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
969             * å¼•æ•°ã«æŒ?®šã•れãŸãƒ??ブルåã?åŠã?æ¡ä»¶å¥ã‚’生æˆã™ã‚‹ãŸã‚ã?カラãƒ??値ã‹ã‚‰
970             * ä»¶æ•°ã‚’å–å¾—ã—ã€typeã«å¿œã˜ã¦ä»¶æ•°ãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
971             * (カラãƒ??値ã«ã¯ã€ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã§è¤?•°æŒ?®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã?
972             *  type=true  存在ã™ã‚‹å ´å?rue  存在ã—ãªã??å?alse
973             *  type=false 存在ã™ã‚‹å ´å?alse 存在ã—ãªã??å?rue
974             *  type=one   1件以�   true  2件以�    false
975             *
976             * å¿??ãƒã‚§ãƒ?‚¯ã®å¼•æ•°ã«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
977             *
978             * ã¾ãŸã?固定å?カラãƒ??値ã«ã‚‚æ¡ä»¶ã¨ãªã‚‹ã‚«ãƒ©ãƒ?Šã³å€¤ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ãŒã€?
979             * ã“ã“ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ??ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒ?‚»ãƒ¼ã‚¸è¡¨ç¤ºæ™‚ã«ã‚«ãƒ©ãƒ??値ãŒç”»é¢ã«è¡¨ç¤ºã•れã¾ã›ã‚“ã€?
980             *
981             * isErrThrow ã¯ã€ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå?åˆã«ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒ?‚»ãƒ¼ã‚¸??rrorMessage?‰ã«æ›¸ãè¾¼ã‚?‹ã©ã?‹ã‚’指定ã—ã¾ã™ã?
982             * 基本ã¯ã€äº’æ›æ€§ã‚’è?æ…®ã—ã?true(書ãè¾¼ã‚?ã§ã™ã?
983             * false ã«ã™ã‚‹ã‚±ãƒ¼ã‚¹ã¯ã€å­˜åœ¨??½ª?¯?¸ã‚’行ã„ã€ã‚れã?æ›´æ–°ã€ãªã‘れã°è¿½åŠ?ãªã©å¾Œç¶šå?ç?‚’行ã„ãŸã„å ´åˆã«ä½¿ã?¾ã™ã?
984             *
985             * @og.rev 5.6.3.1 (2013/04/05) isErrThrow 引数を追�
986             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
987             *
988             * @param type エラーãƒã‚§ãƒ?‚¯ã®ã‚¿ã‚¤ãƒ?
989             * @param tblId ãƒ??ブルå?
990             * @param ns カラãƒ?カンマ区åˆ?‚Š)
991             * @param vs 値(カンマ区åˆ?‚Š)
992             * @param conNs 固定å?カラãƒ?カンマ区åˆ?‚Š)
993             * @param conVs 固定å?(カンマ区åˆ?‚Š)
994             * @param isErrThrow åˆ¤å®šçµæžœãŒfalseã®å ´åˆã«ã€error関数を呼ã¶å ´åˆã?ã€true。呼ã°ãªã??åˆã?ã€falseã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
995             *
996             * @return エラーãŒç™ºç”Ÿã—ãŸå?åˆã?falseã€ãれ以外ã?true
997             */
998            final protected boolean exist( final String type, final String tblId
999                            , final String ns, final String vs, final String conNs, final String conVs, final boolean isErrThrow ) {
1000                    if( ns == null || ns.length() == 0 || vs == null || vs.length() == 0 ) {
1001                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
1002    //                      throw new RuntimeException( "カラãƒ?ˆã¯ã€å?ã«nullã¯æŒ?®šã§ãã¾ã›ã‚“" );
1003                            String errMsg = "カラãƒ?ˆã¯ã€å?ã«nullã¯æŒ?®šã§ãã¾ã›ã‚“ã€?      + CR
1004                                                    + "   ns =[" + ns + "]"
1005                                                    + "   vs =[" + vs + "]" ;
1006                            throw new RuntimeException( errMsg );
1007                    }
1008    
1009                    String namesStr = ns + ( conNs == null || conNs.length() == 0 ? "" : "," + conNs );
1010                    String[] namesArr = StringUtil.csv2Array( namesStr );
1011                    String valsStr = vs + ( conVs == null || conVs.length() == 0 ? "" : "," + conVs );
1012                    String[] valsArr = StringUtil.csv2Array( valsStr );
1013                    if( namesArr.length != valsArr.length ) {
1014                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
1015    //                      throw new RuntimeException( "カラãƒ?¨å€¤ã®å€‹æ•°ãŒç•°ãªã‚Šã¾ã? );
1016                            String errMsg = "カラãƒ?¨å€¤ã®å€‹æ•°ãŒç•°ãªã‚Šã¾ã™ã?"                     + CR
1017                                                    + "   names = [" + namesStr     + "]"   + CR
1018                                                    + "   vals  = [" + valsStr      + "]";
1019                            throw new RuntimeException( errMsg );
1020                    }
1021    
1022                    StringBuilder sb = new StringBuilder();
1023                    sb.append( "select count(*) CNT from " ).append( tblId );
1024                    for( int i=0 ;i<namesArr.length; i++ ) {
1025                            if( i==0 )      { sb.append( " where " ); }
1026                            else            { sb.append( " and " ); }
1027                            sb.append( namesArr[i] ).append( " = " ).append( valsArr[i] );
1028                    }
1029    
1030                    int count = 0;
1031                    ArrayTableModel tbl2 = execSQL( sb.toString(), row, table );
1032                    if( tbl2 != null && tbl2.getRowCount() >= 0 ) {
1033                            count = Integer.valueOf( tbl2.getValues( 0 )[0] );
1034                    }
1035    
1036                    String repVals = replaceParam( vs );
1037                    if( "true".equalsIgnoreCase( type ) ) {
1038                            // ERR0025=ãƒ??タ未登録エラー。キー={0}ã€å?={1} ã®ãƒ??ã‚¿ã¯ã€å­˜åœ¨ã—ã¦ã?¾ã›ã‚“ã€?
1039                            if( count <= 0 ) {
1040                                    if( isErrThrow ) { error( NG, "ERR0025", "{#" + ns + "}", repVals ); }  // 5.6.3.1 (2013/04/05) 
1041                                    return false;
1042                            }
1043                    }
1044                    else if( "false".equalsIgnoreCase( type ) ) {
1045                            // ERR0026=ãƒ??タ登録済ã¿ã‚¨ãƒ©ãƒ¼ã€‚キー={0}ã€å?={1} ã®ãƒ??ã‚¿ã¯ã€ã™ã§ã«å­˜åœ¨ã—ã¦ã?¾ã™ã?
1046                            if( count > 0 ) {
1047                                    if( isErrThrow ) { error( NG, "ERR0026", "{#" + ns + "}", repVals ); }  // 5.6.3.1 (2013/04/05) 
1048                                    return false;
1049                            }
1050                    }
1051                    else if( "one".equalsIgnoreCase( type ) ) {
1052                            // ERR0027=ãƒ??ã‚¿?’é‡ç™»éŒ²ã‚¨ãƒ©ãƒ¼ã€‚キー={0}ã€å?={1} ã®ãƒ??ã‚¿ã¯ã€?‡è¤?—ã¦å­˜åœ¨ã—ã¦ã?¾ã™ã?
1053                            if( count > 1 ) {
1054                                    if( isErrThrow ) { error( NG, "ERR0027", "{#" + ns + "}", repVals ); }  // 5.6.3.1 (2013/04/05) 
1055                                    return false;
1056                            }
1057                    }
1058                    else {
1059                            // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
1060    //                      throw new RuntimeException( "typeã¯ã€trueã€falseã€oneã®ã?šã‚Œã‹ã§æŒ?®šã™ã‚‹å¿?¦ãŒã‚りã¾ã? );
1061                            String errMsg = "typeã¯ã€trueã€falseã€oneã®ã?šã‚Œã‹ã§æŒ?®šã™ã‚‹å¿?¦ãŒã‚りã¾ã™ã?"   + CR
1062                                                    + "   type = [" + type  + "]";
1063                            throw new RuntimeException( errMsg );
1064                    }
1065                    return true;
1066            }
1067    
1068            /**
1069             * å¼•æ•°ã«æŒ?®šã•れãŸã‚­ãƒ¼ã€å?ã‚’ã?ãƒ??å½¢å¼ã«å¤‰æ›ã—ã¾ã™ã?
1070             *
1071             * @og.rev 5.5.7.2 (2012/10/09) HybsDateUtil を利用ã™ã‚‹ã‚ˆã†ã«ä¿®æ­£ã—ã¾ã™ã?
1072             * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
1073             */
1074            private void makeParamMap() {
1075                    if( keys != null && vals != null ) {
1076                            if( keys.length == vals.length ) {
1077                                    for( int i = 0; i < keys.length; i++ ) {
1078                                            paramKeysStr.append( keys[i] ).append( "|" );
1079                                            variableMap.put( keys[i], vals[i] );
1080                                    }
1081                            }
1082                            else {
1083                                    // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
1084    //                              throw new RuntimeException( "keyã¨valã®å€‹æ•°ãŒç•°ãªã‚Šã¾ã? );
1085                                    String errMsg = "keysã¨valsã®å€‹æ•°ãŒç•°ãªã‚Šã¾ã™ã?"                    + CR
1086                                                            + "   keys   =" + Arrays.toString( keys )               + CR
1087                                                            + "   vals   =" + Arrays.toString( vals ) ;
1088                                    throw new RuntimeException( errMsg );
1089                            }
1090                    }
1091    
1092    //              DateFormat formatter = new SimpleDateFormat( "yyyyMMddHHmmss",Locale.JAPAN );
1093    //              String ymdh = formatter.format( new Date() );
1094                    String ymdh = HybsDateUtil.getDate( "yyyyMMddHHmmss" );                 // 5.5.7.2 (2012/10/09) HybsDateUtil を利用
1095                    variableMap.put( "CON.YMDH", ymdh );
1096                    variableMap.put( "CON.YMD", ymdh.substring( 0,8 ) );
1097                    variableMap.put( "CON.HMS", ymdh.substring( 8 ) );
1098    
1099                    variableMap.put( "CON.PGID", this.getClass().getSimpleName() );
1100            }
1101    
1102            /**
1103             * {&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?æ–?­—å?ã®ç½®ãæ›ãˆã‚’行ã„ã¾ã™ã?
1104             *
1105             * @param str ç½®ãæ›ãˆå¯¾è±¡ã®æ–?­—å?
1106             *
1107             * @return ç½®ãæ›ãˆçµæžœã®æ–?­—å?
1108             */
1109            private String replaceParam( final String str ) {
1110                    return replaceParam( str, row, table );
1111            }
1112    
1113            /**
1114             * {&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?æ–?­—å?ã®ç½®ãæ›ãˆã‚’行ã„ã¾ã™ã?
1115             * isRepTableã«falseを指定ã—ãŸå?åˆã?Formatterã«ã‚ˆã‚‹[XXXX]変æ›ã¯è¡Œã‚れã¾ã›ã‚“ã€?
1116             * (SQLã®å¤‰æ›ã®å ´åˆã?ã€PreparedStatementã§å‡¦ç?•ã›ã‚‹ãŸã‚ã€[XXXX]ã®å¤‰æ›ã¯è¡Œã‚ãªã??)
1117             *
1118             * @param str ç½®ãæ›ãˆå¯¾è±¡ã®æ–?­—å?
1119             * @param isRepTable Formatterã«ã‚ˆã‚‹[XXXX]変æ›ã‚’行ã†ã?
1120             *
1121             * @return ç½®ãæ›ãˆçµæžœã®æ–?­—å?
1122             */
1123            private String replaceParam( final String str, final boolean isRepTable ) {
1124                    return ( isRepTable ? replaceParam( str, row, table) : replaceParam( str, 0, null ) );
1125            }
1126    
1127            /**
1128             * {&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?æ–?­—å?ã®ç½®ãæ›ãˆã‚’行ã„ã¾ã™ã?
1129             * [XXXX]å½¢å¼ã?ç½®ãæ›ãˆã«ã¯ã€å¼•æ•°ã§æŒ?®šã•れãŸé…å?型テーブルモãƒ?ƒ«ã€è¡Œç•ªå·(インãƒ?ƒƒã‚¯ã‚¹)を使用ã—ã¾ã™ã?
1130             *
1131             * @og.rev 5.1.8.0 (2010/07/01) 引数ãƒã‚§ãƒ?‚¯æ¼ã‚Œå¯¾å¿?
1132             * @og.rev 5.3.9.0 (2011/09/01) nullãŒé?ç¶šã™ã‚‹å?åˆã«ã‚¼ãƒ­ã‚¹ãƒˆãƒªãƒ³ã‚°ã«ç½®ãæ›ãˆã‚‰ã‚Œãªã?ƒã‚°ã‚’修正
1133             *
1134             * @param str ç½®ãæ›ãˆå¯¾è±¡ã®æ–?­—å?
1135             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
1136             * @param tbl é…å?型テーブルモãƒ?ƒ«
1137             *
1138             * @return ç½®ãæ›ãˆçµæžœã®æ–?­—å?
1139             */
1140            private String replaceParam( final String str, final int rw, final ArrayTableModel tbl ) {
1141                    // 5.1.8.0 (2010/07/01) 引数ãƒã‚§ãƒ?‚¯æ¼ã‚Œå¯¾å¿?
1142                    if( str == null || str.length() == 0 ) { return ""; }
1143    
1144                    String rtn = str;
1145    
1146                    // {@XXXX}ã®å¤‰æ›
1147                    if( variableMap.size() > 0 && rtn.indexOf( "{@" ) >= 0 ) {
1148                            SystemParameter sysParam = getSysParam( rtn );
1149                            rtn = sysParam.replace( variableMap );
1150                    }
1151    
1152                    // [XXXX]ã®å¤‰æ›
1153                    if( tbl != null && rtn.indexOf( '[' ) >= 0 ) {
1154                            Formatter format = getFormatter( rtn, tbl );
1155                            rtn = format.getFormatString( rw );
1156                            // 以ä¸?行ã?Formatterã®ãƒã‚°ã‚’å¸å?値ãŒnullã®å ´åˆã«"null"ã¨ã?†æ–?­—å?ã§å‡ºåŠ›ã•れã¦ã—ã¾ã?
1157    //                      rtn = ',' + rtn + ',';
1158    //                      rtn = rtn.replace( ",null,", ",," );
1159    //                      rtn = rtn.substring( 1, rtn.length() - 1 );
1160                            // 5.3.9.0 (2011/09/01) nullãŒé?ç¶šã™ã‚‹å?åˆã«ã‚¼ãƒ­ã‚¹ãƒˆãƒªãƒ³ã‚°ã«ç½®ãæ›ãˆã‚‰ã‚Œãªã?ƒã‚°ã‚’修正
1161                            rtn = ',' + rtn;
1162                            rtn = rtn.replace( ",null", "," );
1163                            rtn = rtn.substring( 1 );
1164                    }
1165    
1166                    return rtn;
1167            }
1168    
1169            /**
1170             * {&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?æ–?­—å?(é…å?)ã®ç½®ãæ›ãˆã‚’行ã„ã¾ã™ã?
1171             *
1172             * @param str ç½®ãæ›ãˆå¯¾è±¡ã®æ–?­—å?(é…å?)
1173             *
1174             * @return ç½®ãæ›ãˆçµæžœã®æ–?­—å?
1175             */
1176            private String[] replaceParam( final String[] str ) {
1177                    return replaceParam( str, row, table );
1178            }
1179    
1180            /**
1181             * {&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?æ–?­—å?(é…å?)ã®ç½®ãæ›ãˆã‚’行ã„ã¾ã™ã?
1182             * [XXXX]å½¢å¼ã?ç½®ãæ›ãˆã«ã¯ã€å¼•æ•°ã§æŒ?®šã•れãŸé…å?型テーブルモãƒ?ƒ«ã€è¡Œç•ªå·(インãƒ?ƒƒã‚¯ã‚¹)を使用ã—ã¾ã™ã?
1183             *
1184             * @param str ç½®ãæ›ãˆå¯¾è±¡ã®æ–?­—å?(é…å?)
1185             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
1186             * @param tbl é…å?型テーブルモãƒ?ƒ«
1187             *
1188             * @return ç½®ãæ›ãˆçµæžœã®æ–?­—å?
1189             */
1190            private String[] replaceParam( final String[] str, final int rw, final ArrayTableModel tbl ) {
1191                    for( int i = 0; i < str.length; i++ ) {
1192                            str[i] = replaceParam( str[i], rw, tbl );
1193                    }
1194                    return str;
1195            }
1196    
1197            /**
1198             * [XXXX]変æ›ã‚’行ã†ãŸã‚ã®Formatterã‚’å–å¾—ã—ã¾ã™ã?
1199             *
1200             * @param str å¤‰æ›æ–?­—å?
1201             * @param tbl é…å?型テーブルモãƒ?ƒ«
1202             *
1203             * @return Formatterオブジェク�
1204             */
1205            private Formatter getFormatter( final String str, final ArrayTableModel tbl ) {
1206                    Formatter format = formatMap.get( str + tbl.toString() );
1207                    if( format == null ) {
1208                            format = new Formatter( tbl );
1209                            format.setFormat( str );
1210                            formatMap.put( str + tbl.toString(), format );
1211                    }
1212                    return format;
1213            }
1214    
1215            /**
1216             * {&#064;XXXX}変æ›ã‚’行ã†ãŸã‚ã®SystemParameterオブジェクトをå–å¾—ã—ã¾ã™ã?
1217             *
1218             * @param str å¤‰æ›æ–?­—å?
1219             *
1220             * @return SystemParameterオブジェク�
1221             */
1222            private SystemParameter getSysParam( final String str ) {
1223                    SystemParameter sysParam = sysParamMap.get( str );
1224                    if( sysParam == null ) {
1225                            sysParam = new SystemParameter( str );
1226                            sysParamMap.put( str, sysParam );
1227                    }
1228                    return sysParam;
1229            }
1230    
1231            /**
1232             * 検索SQLを実行ã—ã€çµæžœã‚’é?列型ãƒ??ブルモãƒ?ƒ«ã¨ã—ã¦è¿”ã—ã¾ã™ã?
1233             * SQLæ–?«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
1234             * ã¾ãŸã?検索件数ã«ã¤ã?¦ã¯ã€var("SQL_ROWCOUNT")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
1235             *
1236             * @param sq SQLæ–?
1237             *
1238             * @return é…å?型テーブルモãƒ?ƒ«
1239             */
1240            final protected ArrayTableModel createTableBySql( final String sq ) {
1241                    return createTableBySql( sq, row, table );
1242            }
1243    
1244            /**
1245             * 検索SQLを実行ã—ã€çµæžœã‚’é?列型ãƒ??ブルモãƒ?ƒ«ã¨ã—ã¦è¿”ã—ã¾ã™ã?
1246             * SQLæ–?«ã¯ã€{&#064;XXXX}å½¢å¼åŠã³[XXXX]å½¢å¼ã?変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
1247             * [XXXX]å½¢å¼ã?変数ã®ç½®ãæ›ãˆã«ã¯ã€å¼•æ•°ã§æŒ?®šã•れãŸé…å?型テーブルモãƒ?ƒ«ã®è¡ŒãŒä½¿ç”¨ã•れã¾ã™ã?
1248             * ã¾ãŸã?検索件数ã«ã¤ã?¦ã¯ã€var("SQL_ROWCOUNT")ã§å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
1249             *
1250             * @param sq SQLæ–?
1251             * @param rw 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
1252             * @param tbl é…å?型テーブルモãƒ?ƒ«
1253             *
1254             * @return é…å?型テーブルモãƒ?ƒ«
1255             */
1256            final protected ArrayTableModel createTableBySql( final String sq, final int rw, final ArrayTableModel tbl ) {
1257                    return execSQL( sq, rw, tbl );
1258            }
1259    }