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.taglib;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.common.HybsSystemException;
020    import org.opengion.hayabusa.db.DBTableModel;
021    import org.opengion.hayabusa.report.DBTableReport;
022    import org.opengion.fukurou.util.FileUtil;
023    import org.opengion.fukurou.util.Shell;
024    
025    import org.opengion.fukurou.util.StringUtil ;
026    import static org.opengion.fukurou.util.StringUtil.nval ;
027    
028    import java.io.File;
029    import java.io.IOException;
030    import java.io.ObjectOutputStream;
031    import java.io.ObjectInputStream;
032    
033    /**
034     * 検索結果の DBTableModelオブジェクトをレポ?ト形式に変換するタグです?
035     *
036     * ??タ(DBTableModel)と、コントローラ(DBTableReport クラス)を与えて?
037     * 外部からコントロールすることで、各種形式で ??タ(DBTableModel)を表示させること?
038     * 可能です?
039     *
040     * @og.formSample
041     * ●形式?lt;og:report fileURL="[???]" listId="[???]" ??? />
042     * ●body?な?
043     *
044     * ●Tag定義??
045     *   <og:report
046     *       listId           ○?TAG】帳票IDを指定しま???)?
047     *       fileURL            【TAG】雛型?HTMLファイルの保存してある ?レクトリを指定しま?
048     *       programFile        【TAG】HTMLファイルをEXCEL変換する場合に使用するBATファイルを指定しま?
049     *       outFileURL         【TAG】?力HTMLファイルの保存してある?レクトリを指定しま?
050     *       outFilename      ○?TAG】ファイルを作?するとき?出力ファイル名をセ?しま???)?
051     *       headerKeys         【TAG】固定部の{@KEY} の KEY 部?CSV形式で??しま?
052     *       headerVals         【TAG】固定部のKEY に対応する?をCSV形式で??しま?
053     *       footerKeys         【TAG】繰り返し部の終?に表示する key 部?CSV形式で??しま?
054     *       footerVals         【TAG】固定部のKEY に対応する?をCSV形式で??しま?
055     *       pageEndCut         【TAG】??ー部(繰り返し部)がなくなったときに、それ以降を表示するかど?[true/false]を指定しま?初期値:true)
056     *       reportClass        【TAG】実際に書き?すクラス名?略称(DBTableReport_**** の ****)をセ?しま?初期値:HTML)
057     *       language           【TAG】タグ?で使用する?コード[ja/en/zh/…]を指定しま?
058     *       scope              【TAG】キャ?ュする場合?スコープ[request/page/session/applicaton]を指定しま?初期値:session)
059     *       tableId            【TAG?通常使?せん)sessionから?す?DBTableModelオブジェクト? ID
060     *       debug              【TAG】デバッグ??を?力するかど?[true/false]を指定しま?初期値:false)
061     *   />
062     *
063     * ●使用?
064     *
065     * @og.group そ?他??
066     *
067     * @version  4.0
068     * @author   Kazuhiko Hasegawa
069     * @since    JDK5.0,
070     */
071    public class ReportTableTag extends CommonTagSupport {
072            //* こ?プログラ??VERSION??を設定します?       {@value} */
073            private static final String VERSION = "4.0.0.0 (2007/11/28)" ;
074    
075            private static final long serialVersionUID = 400020071128L ;    // 4.0.0.0 (2007/11/28)
076    
077            // 印刷時に使用する?ポラリフォル?
078            private final String REPORT_URL =
079                    nval( HybsSystem.sys( "REPORT_FILE_URL" ) ,
080                                     HybsSystem.sys( "FILE_URL" ) + "REPORT/" ) ;
081    
082            // 3.8.0.4 (2005/08/08) 印刷時に使用するシス?ID
083            private static final String SYSTEM_ID =HybsSystem.sys( "SYSTEM_ID" );
084    
085            // 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更
086            private final int TIMEOUT = HybsSystem.sysInt( "REPORT_DAEMON_TIMEOUT" );
087    
088            private final String  BASE_URL  = HybsSystem.sys( "FILE_URL" );
089    
090            private String[]  headerKeys    = null;   // 固定部の{@KEY} の KEY 部??する?カンマで??できる?
091            private String[]  headerVals    = null;   // 固定部のKEY に対応する?を指定する? {@KEY} に置き換わる?
092            private String[]  footerKeys    = null;   // 繰り返し部の終?に表示する key 部??する?カンマで??できる?
093            private String[]  footerVals    = null;   // 繰り返し部の終?に表示する key に対する値を指定する?
094            private boolean   pageEndCut    = true;   // ボディー部(繰り返し部)がなくなったときに、それ以降?ペ?ジを?力するか?する?
095            private String    fileURL               = BASE_URL;             // 雛型のHTMLファイルの保存してある ?レクトリを指定します?
096            private String    outFileURL    = BASE_URL;             // 出力HTMLファイルの保存してある ?レクトリを指定します?
097            private String    outFilename   = null;                 // 出力HTMLファイル名を?します? ?レクトリ名を含んでも構いません?
098            private String    reportClass   = "HTML";
099    
100            private transient DBTableModel table    = null;
101            private String  tableId                 = HybsSystem.TBL_MDL_KEY ;
102            // 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更
103            private String  listId                  = null ;        // 雛型のHTMLファイル名を?します?
104            private String  programFile             = null;         // HTMLファイルのEXCEL化を行うバッチファイルを指定します?
105    //      private boolean direct                  = false;
106    //      private static final String             disposition = "inline"; // 固?
107    
108            /**
109             * Taglibの終?グが見つかったときに処??doEndTag() ?オーバ?ライドします?
110             *
111             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ?
112             * @og.rev 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更
113             * @og.rev 4.0.0.0 (2007/10/18) メ?ージリソース統? getResource().getMessage > getResource().getLabel )
114             * @og.rev 4.0.0.0 (2007/11/28) メソ?の戻り?をチェ?します?
115             *
116             * @return      後続????
117             */
118            @Override
119            public int doEndTag() {
120                    debugPrint();
121    
122    //              int rtnCode = EVAL_PAGE;
123                    final int rtnCode;
124    
125                    table = (DBTableModel)getObject( tableId );
126                    if( table == null || table.getRowCount() == 0 ) {
127                            rtnCode = SKIP_PAGE ;           // ペ?ジの残りの処?行わな??
128                    }
129                    else {
130    
131    //                      try {
132    
133                                    synchronized( ReportTableTag.class ) {
134                                            String reportDir  = HybsSystem.url2dir( REPORT_URL ) + SYSTEM_ID + HybsSystem.FS + listId ;
135                            //              String ykno       = HybsSystem.getDate( "yyyyMMddHHmmss" );
136                                            String ykno       = String.valueOf( Math.round( Math.random() * 1000000 ) ) ;
137    
138                                            create( reportDir,ykno ) ;
139    
140                                            // 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が??
141                                            if( programFile != null && "HTML".equalsIgnoreCase( reportClass ) ) {
142                                                    String htmlFile = reportDir + HybsSystem.FS + ykno ;
143                                                    String cmd = makeShellCommand( htmlFile,listId );
144                                                    programRun( cmd );
145                                            }
146    
147                                            if( outFilename != null ) {
148                                                    File xlsFile = new File( reportDir,ykno + ".xls" );
149                                                    File outDir  = new File( HybsSystem.url2dir( outFileURL ) );
150    //                                              if( !outDir.exists() ) { outDir.mkdirs(); }
151                                                    if( !outDir.exists() && !outDir.mkdirs() ) {
152                                                            String errMsg = "??フォル?作?できませんでした?" + outDir + "]" ;
153                                                            throw new RuntimeException( errMsg );
154                                                    }
155                                                    File outFile = new File( outDir,outFilename );
156                    //                              File outFile = new File( outFileURL,outFilename );
157                                                    FileUtil.copy(  xlsFile , outFile );
158    
159    //                                              String msg = getResource().getMessage( "MSG0003" )              // MSG0003=ファイルの登録が完?ました?
160                                                    String msg = getResource().getLabel( "MSG0003" )                // MSG0003=ファイルの登録が完?ました?
161                                                                            + HybsSystem.BR
162    //                                                                      + getResource().getMessage( "MSG0022" )         // MSG0022=ファイル?
163                                                                            + getResource().getLabel( "MSG0022" )   // MSG0022=ファイル?
164                                                                            + ":" + outFile.getAbsolutePath() ;
165                                                    jspPrint( msg );
166    
167    //                                              if( direct ) {
168    //                                                      directLoad( outFile.getAbsolutePath(),outFilename );
169    //                                                      directLoad( xlsFile.getAbsolutePath(),outFilename );
170    //                                              }
171                                            }
172    //                                      else {
173    //                                              String redirectUrl = StringUtil.urlAppend( sys( "CONTEXT_URL" ),
174    //                                                                                              REPORT_URL + SYSTEM_ID + "/" +
175    //                                                                                              listId + "/" + ykno + ".xls" ) ;
176    //                                              HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
177    //                                              response.sendRedirect( response.encodeRedirectURL( redirectUrl ) );
178    //                                      }
179                                    }
180    //                      }
181    //                      catch(IOException ex) {
182    //                              String errMsg = "Error in ReportTableTag: " + toString();
183    //                              throw new HybsSystemException( errMsg,ex );             // 3.5.5.4 (2004/04/15) 引数の並び?更
184    //                      }
185                            rtnCode = EVAL_PAGE ;
186                    }
187    
188                    return( rtnCode );
189            }
190    
191            /**
192             * タグリブオブジェクトをリリースします?
193             * キャ?ュされて再利用される?で、フィールド?初期設定を行います?
194             *
195             * @og.rev 2.0.0.4 (2002/09/27) カスタ?グの release() メソ?を?追?
196             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ?
197             * @og.rev 3.1.3.0 (2003/04/10) REPORT_ENCODE(帳票エンコー?ング)を利用するように修正?
198             * @og.rev 3.8.0.4 (2005/08/08) filename 削除、listId ,programFile 追?,
199             *
200             */
201            @Override
202            protected void release2() {
203                    super.release2();
204                    headerKeys              = null;
205                    headerVals              = null;
206                    footerKeys              = null;
207                    footerVals              = null;
208                    pageEndCut              = true;
209                    fileURL                 = BASE_URL;
210                    outFileURL              = BASE_URL;
211                    outFilename             = null;                 // 出力ファイル?
212                    reportClass             = "HTML";
213                    table                   = null;
214                    tableId                 = HybsSystem.TBL_MDL_KEY ;
215                    listId                  = null ;                // 3.8.0.4 (2005/08/08)
216                    programFile             = null ;                // 3.8.0.4 (2005/08/08)
217    //              direct                  = false;
218            }
219    
220            /**
221             * TableWriter の実オブジェクトを生?して?PrintWriter に書き込みます?
222             *
223             * @og.rev 3.1.3.0 (2003/04/10) REPORT_ENCODE(帳票エンコー?ング)を利用するように修正?
224             * @og.rev 3.5.4.3 (2004/01/05) HTMLDBTableReport のクラス名変更?
225             * @og.rev 3.6.0.0 (2004/09/17) メソ?名?変更。setInputFile ?setTemplateFile
226             * @og.rev 3.8.0.0 (2005/06/07) setTemplateFile メソ?の引数?String  ?File に変更
227             * @og.rev 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更
228             * @og.rev 4.0.0.0 (2005/01/31) lang ?ResourceManager へ変更
229             *
230             * @param       reportDir       出力ディレクトリ?
231             * @param       ykno            要求番号
232             */
233            private void create( final String reportDir,final String ykno )  {
234    
235                    String className = "org.opengion.hayabusa.report.DBTableReport_" + reportClass  ;
236                    DBTableReport report = (DBTableReport)HybsSystem.newInstance( className );      // 3.5.5.3 (2004/04/09)
237    
238                    String MODELDIR = HybsSystem.url2dir( fileURL ) ;
239    
240                    File templateFile      = null;
241                    File firstTemplateFile = null;
242    
243                    // 本来は、各クラス中で処?べき?そ?ためのオブジェクト指向なの?ら?
244                    if( "HTML".equalsIgnoreCase( reportClass ) ) {
245                            templateFile      = FileUtil.checkFile( MODELDIR, listId + ".html" , 1 );
246                            firstTemplateFile = FileUtil.checkFile( MODELDIR, listId + "_FIRST.html" ,1 );
247                    }
248                    else if( "Excel".equalsIgnoreCase( reportClass ) ) {
249                            templateFile      = FileUtil.checkFile( MODELDIR, listId + ".xls" , 1 );
250                    }
251                    else {
252                            String errMsg = "リポ?トクラスがサポ?ト外です?[" + reportClass + "]"
253                                                    + "クラスは、HTML、Excel のみサポ?トされて?す?" ;
254                            throw new RuntimeException( errMsg );
255                    }
256    
257                    FileUtil.copy( templateFile,new File( reportDir ) );
258    
259                    report.setDBTableModel( table );
260                    report.setTemplateFile( templateFile ); // 3.6.0.0 (2004/09/17)
261                    report.setFirstTemplateFile( firstTemplateFile );       // 3.6.0.0 (2004/09/17)
262                    report.setOutputDir( reportDir );
263                    report.setOutputFileKey( ykno );
264                    report.setHeaderKeys( headerKeys );
265                    report.setHeaderVals( headerVals );
266                    report.setFooterKeys( footerKeys );
267                    report.setFooterVals( footerVals );
268                    report.setPageEndCut( pageEndCut );
269                    report.setResourceManager( getResource() );     // 4.0.0 (2005/01/31)
270                    report.setListId( listId );             // 3.6.1.0 (2005/01/05)
271                    report.writeReport();
272            }
273    
274            /**
275             * 【TAG?通常は使?せん)結果のDBTableModelを?sessionに登録するとき?キーを指定しま?
276             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])?
277             *
278             * @og.tag
279             * 検索結果より、DBTableModelオブジェクトを作?します?これを?下流?viewタグ等に
280             * 渡す?合に??常は、session を利用します?そ?場合?登録キーです?
281             * query タグを同時に実行して、結果を求める?合?同?モリに配置される為?
282             * こ? tableId 属?を利用して、メモリ空間を?ます?
283             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])?
284             *
285             * @param       id sessionに登録する時? ID
286             */
287            public void setTableId( final String id ) {
288                    tableId = nval( getRequestParameter( id ), tableId );
289            }
290    
291            /**
292             * 【TAG】帳票IDを指定します?
293             *
294             * @og.tag
295             * 雛形ファイルは、帳票ID.html となります?また?ファースト?ージ対応?場合??
296             * 帳票ID_FIRST.html になります?
297             * なお?filename 属?が指定された場合?、そちらが優先されます?
298             *
299             * @og.rev 3.8.0.4 (2005/08/08) 新規追?
300             *
301             * @param       listId  帳票ID
302             */
303            public void setListId( final String listId ) {
304                    this.listId = nval( getRequestParameter( listId ), this.listId );
305            }
306    
307            /**
308             * 【TAG】固定部の{@KEY} の KEY 部?CSV形式で??します?
309             *
310             * @og.tag
311             * カンマで??できます?
312             * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します?
313             * こうしな???タ自身にカンマを持って?場合に?をミスる為です?
314             *
315             * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取?
316             *
317             * @param   hKeys 固定部の key
318             */
319            public void setHeaderKeys( final String hKeys ) {
320                    headerKeys = getCSVParameter( hKeys );
321            }
322    
323            /**
324             * 【TAG】固定部のKEY に対応する?をCSV形式で??します?
325             *
326             * @og.tag
327             * カンマで??で、リクエスト情報でも設定できます?
328             * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します?
329             * こうしな???タ自身にカンマを持って?場合に?をミスる為です?
330             *
331             * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取?
332             *
333             * @param   hVals 固定部の値
334             */
335            public void setHeaderVals( final String hVals ) {
336                    headerVals = getCSVParameter( hVals );
337            }
338    
339            /**
340             * 【TAG】繰り返し部の終?に表示する key 部?CSV形式で??します?
341             *
342             * @og.tag
343             * カンマで??できます?
344             * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します?
345             * こうしな???タ自身にカンマを持って?場合に?をミスる為です?
346             *
347             * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取?
348             *
349             * @param   ftKeys 繰り返し部の終?に表示する key
350             */
351            public void setFooterKeys( final String ftKeys ) {
352                    footerKeys = getCSVParameter( ftKeys );
353            }
354    
355            /**
356             * 【TAG】固定部のKEY に対応する?をCSV形式で??します?
357             *
358             * @og.tag
359             * カンマで??で、リクエスト情報でも設定できます?
360             * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します?
361             * こうしな???タ自身にカンマを持って?場合に?をミスる為です?
362             *
363             * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取?
364             * @og.rev 3.8.1.2 (2005/12/19) footer 関連の値とpageEndCut の関係を解除します?
365             *
366             * @param   ftVals 繰り返し部の終?に表示する値
367             */
368            public void setFooterVals( final String ftVals ) {
369                    footerVals = getCSVParameter( ftVals );
370            }
371    
372            /**
373             * 【TAG】??ー部(繰り返し部)がなくなったときに、それ以降を表示するかど?[true/false]を指定しま?初期値:true)?
374             *
375             * @og.tag
376             * true では、それ以降を出力しません?
377             * 初期値は "true" (なくなった時点で、?力しな??)です?
378             *
379             * @og.rev 3.8.1.2 (2005/12/19) footer 関連の値とpageEndCut の関係を解除します?
380             *
381             * @param   peCut 繰り返し部の終?に継続??るかど? (true:処?な?false:処??
382             */
383            public void setPageEndCut( final String peCut ) {
384                    pageEndCut = nval( getRequestParameter( peCut ),pageEndCut );
385            }
386    
387            /**
388             * 【TAG】雛型?HTMLファイルの保存してある ?レクトリを指定します?
389             *
390             * @og.tag
391             * こ?属?で?される?レクトリのファイルを読み取ります?
392             * ?方法???常の fileURL 属?と同様に、?頭が?'/' (UNIX) また??文字目が?
393             * ":" (Windows)の場合?、指定?URLそ?ままの?レクトリに、そ?な??合??
394             * シス?パラメータ の FILE_URL 属?で??フォル??下に、作?されます?
395             * fileURL = "{@USER.ID}" と?すると、FILE_URL 属?で??フォル??下に?
396             * さらに、各個人ID別のフォル?作?して、そこを操作します?
397             *
398             * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソ?の利用
399             * @og.rev 4.0.0.0 (2007/11/20) ?された?レクトリ名??が"\"or"/"で終わって???合に?/"を付加する?
400             *
401             * @param       url 雛型のHTMLファイルの?レクトリ
402             */
403            public void setFileURL( final String url ) {
404                    String furl = nval( getRequestParameter( url ),null );
405                    if( furl != null ) {
406                            char ch = furl.charAt( furl.length()-1 );
407                            if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
408                            fileURL = StringUtil.urlAppend( fileURL,furl );
409                    }
410            }
411    
412            /**
413             * 【TAG】HTMLファイルをEXCEL変換する場合に使用するBATファイルを指定します?
414             *
415             * @og.tag
416             * ファイルは、フルパスで?してください?
417             * ?がな??合?、変換処??行いません?
418             * 通常は、dbdef2/def/Script/runExcelPrint.bat を呼び出してください?
419             * 初期値は、null(変換処?な?です?
420             *
421             * @og.rev 3.8.0.4 (2005/08/08) 新規追?
422             *
423             * @param   programFile プログラ?ァイル?
424             */
425            public void setProgramFile( final String programFile ) {
426                    this.programFile = nval( getRequestParameter( programFile ),this.programFile );
427            }
428    
429            /**
430             * 【TAG】?力HTMLファイルの保存してある?レクトリを指定します?
431             *
432             * @og.tag
433             * こ?属?で?される?レクトリにファイルを?力します?
434             * ?方法???常の fileURL 属?と同様に、?頭が?'/' (UNIX) また??文字目が?
435             * ":" (Windows)の場合?、指定?URLそ?ままの?レクトリに、そ?な??合??
436             * シス?パラメータ の FILE_URL 属?で??フォル??下に、作?されます?
437             * fileURL = "{@USER.ID}" と?すると、FILE_URL 属?で??フォル??下に?
438             * さらに、各個人ID別のフォル?作?して、そこに出力します?
439             *
440             * @og.rev 4.0.0.0 (2007/11/20) ?された?レクトリ名??が"\"or"/"で終わって???合に?/"を付加する?
441             *
442             * @param       url 出力HTMLファイルの?レクトリ
443             */
444            public void setOutFileURL( final String url ) {
445                    String furl = nval( getRequestParameter( url ),null );
446                    if( furl != null ) {
447                            char ch = furl.charAt( furl.length()-1 );
448                            if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
449                            outFileURL = StringUtil.urlAppend( outFileURL,furl );
450                    }
451            }
452    
453            /**
454             * 【TAG】ファイルを作?するとき?出力ファイル名をセ?します?
455             *
456             * @og.tag ファイルを作?するとき?出力ファイル名をセ?します?
457             *
458             * @param   filename 出力ファイル?
459             */
460            public void setOutFilename( final String filename ) {
461                    this.outFilename = nval( getRequestParameter( filename ),this.outFilename );
462            }
463    
464            /**
465             * 【TAG】実際に書き?すクラス名?略称(DBTableReport_**** の ****)をセ?しま?初期値:HTML)?
466             *
467             * @og.tag
468             * これは、org.opengion.hayabusa.report 以下? DBTableReport_**** クラスの **** ?
469             * 与えます?これら?、DBTableReport インターフェースを継承したサブクラスです?
470             * 初期値は?HTML" です?
471             * 属?クラス定義の {@link org.opengion.hayabusa.report.DBTableReport DBTableReport} を参照願います?
472             *
473             * @param   reportClass クラス?の略称)
474             * @see         org.opengion.hayabusa.report.DBTableReport  DBTableReportのサブクラス
475             */
476            public void setReportClass( final String reportClass ) {
477                    this.reportClass = nval( getRequestParameter( reportClass ),this.reportClass );
478            }
479    
480            /**
481             * 【TAG】結果をダイレクトにEXCEL起動するかど?[true/false]を指定しま?初期値:false[ファイル])?
482             *
483             * @og.tag 結果をダイレクトに EXCEL ファイルとして出力するかど?をセ?します?
484             *
485             * @param  flag ?レク?true)??ファイル(そ??
486             */
487    //      public void setDirect( final String flag ) {
488    //              direct = nval( getRequestParameter( flag ),direct );
489    //      }
490    
491            /**
492             * シェルコマンド???を作?します?
493             *
494             * 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が??
495             *
496             * @og.rev 3.8.0.4 (2005/08/08) 新規追?
497             * @og.rev 3.8.0.8 (2005/10/03) ??モングループ??ォルト?設?
498             *
499             * @param       htmlFile        パ?サ済みのHTMLファイル(拡張子な?
500             * @param       listId  雛形ファイル(帳票ID)
501             *
502             * @return シェルコマンド???
503             */
504            private String makeShellCommand( final String htmlFile,final String listId ) {
505                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
506    
507                    buf.append( programFile ).append( " " );                // 実行するコマン?
508                    buf.append( "\"" );
509                    buf.append( htmlFile ).append( "_*.html\" " );  // 入力HTMLファイル
510                    buf.append( "\"xls\" " );                                               // プリンタ?
511                    // ?ーファイルを指定する?がある?
512                    buf.append( "\"" );
513                    buf.append( htmlFile ).append( ".xls\" " );             // ?ー出力ファイル
514                    buf.append( listId );                                                   // モ?ファイル?
515                    buf.append( " NULL" );                                                  // ?ー??モングルー?
516    
517                    return buf.toString();
518            }
519    
520            /**
521             * 実際のレポ?ト?力??行います?
522             *
523             * 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が??
524             *
525             * @og.rev 3.8.0.4 (2005/08/08) 新規追?
526             *
527             * @param       shellCmd        シェルを実行するコマンド文字?
528             */
529            private void programRun( final String shellCmd ) {
530                    Shell shell = new Shell();
531                    shell.setCommand( shellCmd,true );              // BATCHプロセスで実行す?
532                    shell.setWait( true );                                  // プロセスの終??
533                    shell.setTimeout( TIMEOUT );                    // 3.6.1.0 (2005/01/05) Shell の タイ?ウトを設?
534    
535                    int rtnCode = shell.exec();                             // 0 は正常終?示?
536    
537                    if( rtnCode != 0 ) {
538                            String errMsg = "Shell Command exequte Error." + HybsSystem.CR
539                                                    + "=============================="
540                                                    + shellCmd + HybsSystem.CR
541                                                    + shell.getStdoutData() + HybsSystem.CR
542                                                    + shell.getStderrData() + HybsSystem.CR ;
543                            throw new HybsSystemException( errMsg );                // 3.5.5.4 (2004/04/15) 引数の並び?更
544                    }
545            }
546    
547            /**
548             * Excel ファイルをダイレクトで返す forward 処?行います?
549             *
550             * @og.rev 4.0.0.0 (2007/06/11) 新規追?
551             *
552             * @param       fwdUrl  実際に転送するファイルアドレス
553             * @param       fname   転送で返すファイル?
554             */
555    //      private void directLoad( final String fwdUrl,final String fname ) {
556    //              HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
557    //
558    //              try {
559    //                      String url = response.encodeRedirectURL( fwdUrl );      // 3.5.4.9 (2004/02/25)
560    //                      String filename = StringUtil.urlEncode( fname );
561    //
562    //                      (response).setHeader( "Content-Disposition",disposition + "; filename=\"" + filename + "\"" );
563    //                      response.sendRedirect( url );
564    //      //              pageContext.forward( url );
565    //              } catch(IOException ex) {
566    //                      String errMsg = "フォワードでIOエラーが発生しました? + toString();
567    //                      throw new HybsSystemException( errMsg,ex );
568    ////            } catch( ServletException ex) {
569    ////                    String errMsg = "フォワードでServletエラーが発生しました? + toString();
570    ////                    throw new HybsSystemException( errMsg,ex );
571    //              }
572    //      }
573    
574            /**
575             * タグの名称を?返します?
576             * 自??身のクラス名より?自動的に取り出せな?め?こ?メソ?をオーバ?ライドします?
577             *
578             * @og.rev 4.0.0.0 (2005/01/31) 新規追?
579             *
580             * @return  タグの名称
581             */
582            @Override
583            protected String getTagName() {
584                    return "report" ;
585            }
586    
587            /**
588             * シリアライズ用のカスタ?リアライズ書き込みメソ?
589             *
590             * @og.rev 4.0.0.0 (2006/09/31) 新規追?
591             * @serialData
592             *
593             * @param       strm    ObjectOutputStreamオブジェク?
594             */
595            private void writeObject( final ObjectOutputStream strm ) throws IOException {
596                    strm.defaultWriteObject();
597            }
598    
599            /**
600             * シリアライズ用のカスタ?リアライズ読み込みメソ?
601             *
602             * ここでは、transient 宣?れた?変数の??初期化が?なフィールド?み設定します?
603             *
604             * @og.rev 4.0.0.0 (2006/09/31) 新規追?
605             * @serialData
606             *
607             * @param       strm    ObjectInputStreamオブジェク?
608             * @see #release2()
609             */
610            private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
611                    strm.defaultReadObject();
612            }
613    
614            /**
615             * こ?オブジェクト???表現を返します?
616             * 基本???目?使用します?
617             *
618             * @return こ?クラスの??表現
619             */
620            @Override
621            public String toString() {
622                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
623                                    .println( "VERSION"             ,VERSION        )
624                                    .println( "headerKeys"          ,headerKeys             )
625                                    .println( "headerVals"          ,headerVals             )
626                                    .println( "footerKeys"          ,footerKeys             )
627                                    .println( "footerVals"          ,footerVals             )
628                                    .println( "pageEndCut"          ,pageEndCut             )
629                                    .println( "fileURL"                     ,fileURL                )
630                                    .println( "outFileURL"          ,outFileURL             )
631                                    .println( "outFilename"         ,outFilename    )
632                                    .println( "reportClass"         ,reportClass    )
633                                    .println( "tableId"                     ,tableId                )
634                                    .println( "listId"                      ,listId                 )
635                                    .println( "programFile"         ,programFile    )
636                                    .println( "REPORT_FILE_URL"     ,REPORT_URL             )
637                                    .println( "SYSTEM_ID"           ,SYSTEM_ID              )
638                                    .println( "TIMEOUT"                     ,TIMEOUT                )
639                                    .println( "BASE_URL"            ,BASE_URL               )
640                                    .println( "Other..."    ,getAttributes().getAttribute() )
641                                    .fixForm().toString() ;
642            }
643    }