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.io.TableWriter;
022    import org.opengion.fukurou.util.FileUtil;
023    import org.opengion.fukurou.util.HybsEntry;
024    import org.opengion.fukurou.util.Closer ;
025    import org.opengion.fukurou.util.StringUtil ;
026    import static org.opengion.fukurou.util.StringUtil.nval ;
027    
028    import javax.servlet.ServletResponse ;
029    import javax.servlet.http.HttpServletResponse ;
030    import javax.servlet.jsp.JspWriter ;
031    
032    import java.util.zip.GZIPOutputStream;
033    import java.util.zip.ZipOutputStream;
034    import java.util.zip.ZipEntry;
035    import java.util.List;
036    import java.util.ArrayList;
037    import java.util.Locale;
038    import java.io.File;
039    import java.io.OutputStream;
040    import java.io.PrintWriter;
041    import java.io.FileOutputStream;
042    import java.io.ByteArrayOutputStream;
043    import java.io.ObjectOutputStream;
044    import java.io.ObjectInputStream;
045    import java.io.IOException;
046    
047    /**
048     * DBTableModelオブジェクトをæŒ?®šã?ファイルに出力するタグですã?
049     *
050     * ãƒ??タ(DBTableModel)と、コントローラ(WriteTableTagForm)を与えてã€?
051     * 外部からコントロールすることで、各種形式で ãƒ??タ(DBTableModel)を表示できますã?
052     * writeTableタグ に対して、コマンドを与えることにより、å?部のコントローラの
053     * 実è£?�«対応したã? 形式でãƒ??タを作æ?しますã?
054     *
055     * @og.formSample
056     * ●形式ï¼?
057     *     <og:writeTable
058     *         fileURL   = "{@USER.ID}"    保存å?ãƒ?‚£レクトリå�?
059     *         filename  = "{@filename}"   保存ファイルå�?
060     *         encode    = "UnicodeLittle"      保存ファイルエンコード名
061     *     />
062     *
063     * ●body?šあã‚?EVAL_BODY_BUFFERED:BODYを評価しã?{@XXXX} を解析しまã�?
064     *
065     * ●Tag定義??
066     *   <og:writeTable
067     *       writerClass        【TAG】実際に書きå?すクラス名ã?略称(TableWriter_**** クラスの ****)を指定しまã�?初期値:Default)
068     *       separator          【TAG】可変長ファイルを作æ?するときã?é ?›®区åˆ?‚Šæ–?­—をセãƒ?ƒˆしまã�?(初期値:TableWriter#TAB_SEPARATOR[= ])
069     *       headerSequence     【TAG】DBTableModelの出力é?(LNSCD など)をセãƒ?ƒˆしまã�?
070     *       fileURL            【TAG】ファイル保存å?ãƒ?‚£レクトリ名をæŒ?®šしまã�?
071     *       filename           【TAG】ファイルを作æ?するときã?ファイル名をセãƒ?ƒˆしまã�?(初期値:FILE_FILENAME[=UnicodeLittle])
072     *       sheetName          【TAG】EXCELファイルを書きå?すときã?シート名を設定しまã�?
073     *       beforeDelete       【TAG】事前にファイルを削除するかどã�?�‹をセãƒ?ƒˆしまã�?(初期値:false)
074     *       encode             【TAG】ファイルを作æ?するときã?ファイルエンコーãƒ?‚£ング名をセãƒ?ƒˆしまã�?(初期値:FILE_ENCODE[=UnicodeLittle])
075     *       fileAppend         【TAG】追åŠ?ƒ¢ードで書き込ã‚?�‹どã�?�‹[true/false]を指定しまã�?初期値:false[新規モード])
076     *       direct             【å»?­¢】結果をダイレクトにEXCEL起動するかどã�?�‹[true/false]を指定しまã�?初期値:false[ファイル])
077     *       zip                【TAG】結果をファイルに出力するときに、ZIPで圧縮するかどã�?�‹[true/false]を指定しまã�?初期値:false)
078     *       tableId            【TAGã€?通常使ã�?�¾せん)sessionからæ‰?¾—すã‚?DBTableModelオブジェクトã? ID
079     *       scope              【TAG】キャãƒ?‚·ュする場合ã?スコープ[request/page/session/applicaton]を指定しまã�?初期値:session)
080     *       disposition        【TAG】Content-Disposition (inline:埋め込ã‚?attachment:ãƒ?‚¤アログを起å‹?を指定しまã�?初期値:attachment)
081     *       refFileURL         【TAG】EXCEL雛型参ç?ファイルのãƒ?‚£レクトリ名をセãƒ?ƒˆしまã�?
082     *       refFilename        【TAG】EXCEL雛型参è?ファイル名をセãƒ?ƒˆしまã�?
083     *       refSheetName       【TAG】EXCEL雛型参è?ファイルのシート名を設定しまã�?
084     *       useNumber          【TAG】行番号æƒ??をã?出力すã‚?しない[true/false]を指定しまã�?初期値:true)
085     *       columns            【TAG】書き込み先ファイルのカラãƒ??をã?外部(タグ)よりæŒ?®šしまã�?
086     *       useRenderer        【TAG】書込処ç�?�§コードリソースのラベル変換を行うかどã�?�‹を指定しまã�?(初期値:USE_TABLE_WRITER_RENDERER[=false])
087     *       selectedAll        【TAG】チェãƒ?‚¯行ã?みを対象にするかをæŒ?®šしまã�?初期値:true)ã€?
088     *       fontName           【TAG】EXCEL出力時のãƒ?ƒ•ォルトフォント名を設定しまã�?(初期値:TABLE_WRITER_DEFAULT_FONT_NAME[=?­?³ ?°ゴシãƒ?‚¯])
089     *       fontPoint          【TAG】EXCEL出力時のãƒ?ƒ•ォルトフォントã?イント数を設定しまã�?初期値:TABLE_WRITER_DEFAULT_FONT_POINTS[=11])
090     *       skipRowCount       【TAGã€?通常は使ã�?�¾せん)ãƒ??タの書き込み開始位置を設定しまã�?
091     *       language           【TAG】タグå†?ƒ¨で使用するè¨?ªžコード[ja/en/zh/…]を指定しまã�?
092     *       caseKey            【TAG】このタグ自体を利用するかどã�?�‹の条件キーを指定しまã�?初期値:null) 5.7.7.2 (2014/06/20)
093     *       caseVal            【TAG】このタグ自体を利用するかどã�?�‹の条件値を指定しまã�?初期値:null) 5.7.7.2 (2014/06/20)
094     *       caseNN             【TAG】指定ã?値がã?null/ゼロæ–?­—å? でなã�??å�?Not Null=NN)は、このタグは使用されまã�?初期値:true) 5.7.7.2 (2014/06/20)
095     *       caseNull           【TAG】指定ã?値がã?null/ゼロæ–?­—å? の場合ã?、このタグは使用されまã�?初期値:true) 5.7.7.2 (2014/06/20)
096     *       debug              【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
097     *   >   ... Body ...
098     *   </og:writeTable>
099     *
100     * ●使用ä¾?
101     *     <og:writeTable ?¥?¥?¥?¥?¥ >
102     *         <og:writeTableParam
103     *             key  = "Tablename"  value="GE12"
104     *         />
105     *         <og:writeTableParam
106     *             key  = "First"             First:æœ??に登録
107     *         >
108     *                      insert into GE12bk
109     *                         select * from GE12
110     *                         where SYSTEM_ID='**'
111     *         </og:writeTableParam
112     *         <og:writeTableParam
113     *             key  = "First"             First:の?’番目に登録
114     *         >
115     *              delete from GE12 where SYSTEM_ID='**' and KBSAKU='0'
116     *         </og:writeTableParam
117     *         <og:writeTableParam
118     *             key  = "Last"              Last:æœ?¾Œに登録
119     *         >
120     *              update GE12 set XXXX='YYYY' where SYSTEM_ID='**' and KBSAKU='0'
121     *         </og:writeTableParam
122     *     </og:writeTableParam
123     *
124     * @og.group ファイル出åŠ?
125     *
126     * @version  4.0
127     * @author   Kazuhiko Hasegawa
128     * @since    JDK5.0,
129     */
130    public class WriteTableTag extends CommonTagSupport {
131            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
132            private static final String VERSION = "5.7.9.0 (2014/08/08)" ;
133    
134            private static final long serialVersionUID = 579020140808L ;
135    
136            private final String  BASE_URL  = HybsSystem.sys( "FILE_URL" );
137    
138            private String  separator               = TableWriter.TAB_SEPARATOR;     // é ?›®区åˆ?‚Šæ–?­?
139            private String  headerSequence  = null;                         // ヘッãƒ??é ?›®の並びé ?
140            private String  fileURL                 = BASE_URL;
141            private String  filename                = HybsSystem.sys( "FILE_FILENAME" );   // ファイルå�?
142            private String  sheetName               = "Sheet1" ;            // 3.5.4.2 (2003/12/15)
143            private String  refFileURL              = BASE_URL;                     // 3.5.4.3 (2004/01/05)
144            private String  refFilename     = null;                         // 3.5.4.3 (2004/01/05)
145            private String  refSheetName    = null ;                        // 3.5.4.3 (2004/01/05)
146            private String  fontName                = HybsSystem.sys( "TABLE_WRITER_DEFAULT_FONT_NAME" );                   // 3.8.5.3 (2006/08/07)
147            private String  fontPoint               = HybsSystem.sys( "TABLE_WRITER_DEFAULT_FONT_POINTS" );                 // 3.8.5.3 (2006/08/07)
148            private String  encode                  = HybsSystem.sys( "FILE_ENCODE" );      // ファイルエンコーãƒ?‚£ング  "DEFAULT","JISAutoDetect" ,"JIS", "EUC_JP", "MS932", "SJIS" , "Windows-31J" , "Shift_JIS"
149            private String  writerClass     = HybsSystem.sys( "TABLE_WRITER_DEFAULT_CLASS" );               // 3.8.5.3 (2006/08/07)
150            private boolean fileAppend              = false;                        // ファイルをAPPENDモードで出力するか
151            private boolean direct                  = false;
152            private boolean zip                     = false;
153            private String  disposition     = "attachment";         // 3.8.0.9 (2005/10/17) Content-Disposition 初期値変更 inline â‡?attachment
154    
155            private transient DBTableModel table      = null;
156            private String  tableId                 = HybsSystem.TBL_MDL_KEY ;
157            private String  directory               = null ;                        // 3.8.6.0 (2006/08/23)
158    
159            private transient List<HybsEntry> param   = null ;                // 4.0.0 (2005/02/28)
160    
161            private boolean useNumber               = true;                         // 3.7.0.2 (2005/02/14)
162            // 4.0.0 (2005/12/31) 外部よりカラãƒ??(カンマ区åˆ?‚Š)を指定できるようにするã€?
163            private String          columns         = null;
164            // 5.2.1.0 (2010/10/01) 書込処ç�?�§コードリソースのラベル変換を行うかどã�?�‹
165            private boolean useRenderer             = HybsSystem.sysBool( "USE_TABLE_WRITER_RENDERER" );    // 5.2.1.0 (2010/10/01)
166            
167            // 5.5.5.5 (2012/08/24) チェãƒ?‚¯対å¿?
168            private boolean selectedAll             = true;                         // 5.5.5.5 (2012/08/24)
169    
170            // 5.5.9.1 (2012/12/07) 事前にファイルを削除するかどã�?�‹。互換性のため、false に設定ã?推奨は、true
171            private boolean beforeDelete    = false;                        // 5.5.9.1 (2012/12/07) 事前にファイルを削除するかどã�?�‹ã€?
172    
173            private int             skipRowCount    = 0;                            // 5.7.9.0 (2014/08/08) ãƒ??タの書き込み開始位置設å®?
174    
175            /**
176             * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
177             *
178             * @og.rev 5.5.9.1 (2012/12/07) 事前にファイルを削除するかどã�?�‹??eforeDelete?‰フラグを追åŠ?
179             * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属æ?を追åŠ?
180             *
181             * @return      後続å?ç�??æŒ?¤º( EVAL_BODY_BUFFERED )
182             */
183            @Override
184            public int doStartTag() {
185                    // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属æ?を追åŠ?
186                    if( !useTag() ) { return SKIP_BODY ; }
187    
188                    directory = HybsSystem.url2dir( fileURL );              // 5.5.9.1 (2012/12/07) doEndTag() から移å‹?
189    
190                    // 5.5.9.1 (2012/12/07) 事前にファイルを削除するかどã�?�‹
191                    if( beforeDelete && !fileAppend ) {
192                            File delFile = null;
193                            if( zip ) { delFile = new File( directory,filename + ".zip" ); }
194                            else      { delFile = new File( directory,filename ); }
195                            if( delFile.exists() ) { delFile.delete(); }
196                    }
197    
198                    return EVAL_BODY_BUFFERED ;     // Body を評価するã€? extends BodyTagSupport æ™?
199            }
200    
201            /**
202             * Taglibの終äº?‚¿グが見つかったときに処ç�?�™ã‚?doEndTag() ã‚?オーバã?ライドしますã?
203             *
204             * @og.rev 2.1.3.1 (2002/12/13) ContentType をã?x-msexcel から vnd.ms-excel に変更したã€?
205             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
206             * @og.rev 3.1.3.0 (2003/04/10) FILE_ENCODE から、エンコード情報を取得するã?
207             * @og.rev 3.1.5.0 (2003/04/20) Content-Disposition を外部からæŒ?®šできるように変更ã€?
208             * @og.rev 3.2.0.0 (2003/05/22) GZIPOutputStream を使用してã�?�Ÿがã?ZipOutputStream に変更ã€?
209             * @og.rev 3.5.4.1 (2003/12/01) 引数の PrintWriter をã?OutputStream に変更ã€?
210             * @og.rev 3.5.4.3 (2004/01/05) 引数をã? PrintWriter に戻すã?
211             * @og.rev 3.6.0.2 (2004/10/04) EXCELãƒ?‚¤レクトå?力時にファイルエンドまで出力されなã�?¸�å?合対ç­?
212             * @og.rev 3.8.0.9 (2005/10/17) disposition属æ?を使用できるように変更しますã?
213             * @og.rev 3.8.6.0 (2006/08/23) フォルãƒ?�Œなã�??合ã?、è¤?•°階層åˆ??フォルãƒ?‚’自動で作æ?しますã?
214             * @og.rev 4.3.4.3 (2008/12/22) Excel出力ã?判別方法を前方ä¸??に変更
215             * @og.rev 5.1.6.0 (2010/05/01) 画面帳票作æ?機è?対å¿?
216             * @og.rev 5.5.2.0 (2012/05/01) ZIP時にもencodeが有効にする
217             * @og.rev 5.5.5.5 (2012/08/24) selectedAllの処ç�?‚’追åŠ?
218             * @og.rev 5.5.9.1 (2012/12/07) beforeDeleteフラグの追åŠ?�«伴ã�??ロジãƒ?‚¯変更
219             * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属æ?を追åŠ?
220             *
221             * @return      後続å?ç�??æŒ?¤º
222             */
223            @Override
224            public int doEndTag() {
225                    debugPrint();           // 4.0.0 (2005/02/28)
226    
227                    // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属æ?を追åŠ?
228                    if( !useTag() ) { return EVAL_PAGE ; }
229    
230                    table = (DBTableModel)getObject( tableId );
231                    if( ! selectedAll ){ // 5.5.5.5 (2012/08/24) 
232                            table = getSelRowsTable( table );
233                    }
234                    if( table != null && table.getRowCount() > 0 ) {
235    
236                            File dir = new File(directory);
237                            if( ! dir.exists() && ! dir.mkdirs() ) {
238                                    String errMsg = "ãƒ?‚£レクトリの作æ?に失敗しましたã€?" + directory + "]";
239                                    throw new HybsSystemException( errMsg );
240                            }
241    
242                            PrintWriter pw = null;
243                            ByteArrayOutputStream bt = null ;
244                            try {
245                                    if( direct ) {
246                                            if( zip ) {
247                                                    bt = new ByteArrayOutputStream();
248                                                    pw = new PrintWriter( bt );
249                                                    create( pw ) ;
250                                                    pw.flush();                             // 3.6.0.2 (2004/10/04)
251                                                    ServletResponse response = pageContext.getResponse() ;
252                                                    ((HttpServletResponse)response).addHeader( "Content-Encoding","gzip" );
253    
254                                                    GZIPOutputStream gzip = new GZIPOutputStream(bt);
255                                                    gzip.finish() ;
256                                                    response.setContentLength( bt.size() );
257    
258                                                    JspWriter out = pageContext.getOut();
259                                                    out.clear();
260                                                    out.print( bt );
261                                                    out.flush();                    // 3.6.0.2 (2004/10/04)
262                                            }
263                                            else {
264                                                    bt = new ByteArrayOutputStream();
265                                                    pw = new PrintWriter( bt );
266                                                    create( pw ) ;
267                                                    pw.flush();                             // 3.6.0.2 (2004/10/04)
268                                                    ServletResponse response = pageContext.getResponse() ;
269                                                    response.setContentType( "application/vnd.ms-excel; charset=" + encode );
270            //                                      response.setContentType( "application/x-msexcel; charset=" + encode );
271            //                                      response.setContentType( "text/comma-separated-values ; charset=" + encode );
272            //                                      ((HttpServletResponse)response).setHeader( "contentType","application/x-msexcel; charset=Shift_JIS" );
273            //                                      ((HttpServletResponse)response).setHeader( "Content-Disposition","attachment; filename=\"" + filename + "\"" );
274            //                                      ((HttpServletResponse)response).setHeader( "Content-Disposition","inline; filename=\"" + filename + "\"" );
275                                                    // 3.8.0.9 (2005/10/17) disposition属æ?を使用できるように変更しますã?
276                                                    ((HttpServletResponse)response).setHeader( "Content-Disposition",disposition + "; filename=\"" + filename + "\"" );
277    
278                                                    JspWriter out = pageContext.getOut();
279                                                    out.clear();
280                                                    out.print( bt );
281                                                    out.flush();                    // 3.6.0.2 (2004/10/04)
282                                            }
283                                    }
284                                    else {
285                                    // 3.2.0.0 (2003/05/22) GZIPOutputStream を使用してã�?�Ÿがã?ZipOutputStream に変更ã€?
286                                            if( zip ) {
287                                                    bt = new ByteArrayOutputStream();
288                                                    if( writerClass.toUpperCase(Locale.JAPAN).startsWith("EXCEL") // 5.5.2.0(2012/05/01)
289                                                                    || writerClass.toUpperCase(Locale.JAPAN).startsWith("CALC") ) {
290                                                            pw = new PrintWriter( bt );
291                                                    }
292                                                    else{
293                                                            pw = getPrintWriter(bt);
294                                                    }
295                                                    create( pw ) ;
296                                                    pw.flush();                             // 3.6.0.2 (2004/10/04)
297    
298                                                    ZipOutputStream gzip = null;
299                                                    try {
300                                                            gzip = new ZipOutputStream(
301                                                                                            new FileOutputStream(
302                                                                                                    StringUtil.urlAppend( directory,filename + ".zip" )));
303                                                            gzip.putNextEntry( new ZipEntry( filename ) );
304                                                            (bt).writeTo( gzip );
305                                                            gzip.finish() ;
306                                                    }
307                                                    finally {
308                                                            Closer.ioClose( gzip );         // 4.0.0 (2006/01/31) close 処ç�?™‚の IOException を無è¦?
309                                                    }
310                                            }
311                                            else {
312                                                    // if( "Excel".equalsIgnoreCase( writerClass ) ) {
313                                                    if( writerClass.toUpperCase(Locale.JAPAN).startsWith("EXCEL") // 4.3.4.3 (2008/12/22)
314                                                            ||  writerClass.toUpperCase(Locale.JAPAN).startsWith("CALC") ) { // 5.1.6.0 (2010/05/01)
315                                                            create( null );
316                                                    }
317                                                    else {
318                                                            pw = getPrintWriter();
319                                                            create( pw );
320                                                            pw.flush();                             // 3.6.0.2 (2004/10/04)
321                                                    }
322                                            }
323                                    }
324                            }
325                            catch( IOException ex ) {
326                                    String errMsg = "ãƒ??ブル出力時に、IOエラーが発生しましたã€? + toString();
327                                    throw new HybsSystemException( errMsg,ex );             // 3.5.5.4 (2004/04/15) 引数の並びé ?¤‰更
328                            }
329                            finally {
330                                    Closer.ioClose( pw );           // 4.0.0 (2006/01/31) close 処ç�?™‚の IOException を無è¦?
331                                    Closer.ioClose( bt );           // 4.0.0 (2006/01/31) close 処ç�?™‚の IOException を無è¦?
332                            }
333                    }
334    
335                    return EVAL_PAGE ;
336            }
337    
338            /**
339             * タグリブオブジェクトをリリースしますã?
340             * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
341             *
342             * @og.rev 2.0.0.4 (2002/09/27) カスタãƒ?‚¿グの release() メソãƒ?ƒ‰をã?追åŠ?
343             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
344             * @og.rev 3.1.3.0 (2003/04/10) FILE_ENCODE から、エンコード情報を取得するã?
345             * @og.rev 3.1.5.0 (2003/04/20) Content-Disposition を外部からæŒ?®šできるように変更ã€?
346             * @og.rev 3.5.4.2 (2003/12/15) EXCELのシート名を指定できるように変更ã€?
347             * @og.rev 3.5.4.3 (2004/01/05) EXCEL雛型参ç?ファイルのURL,filenameを追åŠ?�—ますã?
348             * @og.rev 3.8.5.3 (2006/08/07) writerClass 属æ?の初期値をシスãƒ?ƒ リソースより取得しますã?
349             * @og.rev 3.8.5.3 (2006/08/07) fontName 属æ?を追åŠ?�—ますã?
350             * @og.rev 3.8.5.3 (2006/08/07) fontPoint 属æ?を追åŠ?�—ますã?
351             * @og.rev 3.8.6.0 (2006/08/23) directory 属æ?を追åŠ?�—ますã?
352             * @og.rev 4.0.0.0 (2005/02/28) XMLファイルにセãƒ?ƒˆする、param を追åŠ??
353             * @og.rev 5.2.1.0 (2010/10/01) 書込処ç�?�§コードリソースのラベル変換を行うかどã�?�‹ useRenderer 属æ?追åŠ?
354             * @og.rev 5.5.5.5 (2012/08/24) selectedAll属æ?を追åŠ?
355             * @og.rev 5.5.9.1 (2012/12/07) 事前にファイルを削除するかどã�?�‹。互換性のため、false に設定ã?推奨は、true
356             * @og.rev 5.7.9.0 (2014/08/08) ãƒ??タの書き込み開始位置(skipRowCount)を設å®?
357             *
358             */
359            @Override
360            protected void release2() {
361                    super.release2();
362                    separator               = TableWriter.TAB_SEPARATOR;   // é ?›®区åˆ?‚Šæ–?­?
363                    headerSequence  = null;                         // ヘッãƒ??é ?›®の並びé ?
364                    fileURL                 = BASE_URL;
365                    filename                = HybsSystem.sys( "FILE_FILENAME" );   // ファイルå�?
366                    sheetName               = "Sheet1";                     // 3.5.4.2 (2003/12/15)
367                    beforeDelete    = false;                        // 5.5.9.1 (2012/12/07)
368                    refFileURL              = BASE_URL;                     // 3.5.4.3 (2004/01/05)
369                    refFilename     = null;                         // 3.5.4.3 (2004/01/05)
370                    refSheetName    = null;                         // 3.5.4.2 (2003/12/15)
371                    fontName                = HybsSystem.sys( "TABLE_WRITER_DEFAULT_FONT_NAME" );                   // 3.8.5.3 (2006/08/07)
372                    fontPoint               = HybsSystem.sys( "TABLE_WRITER_DEFAULT_FONT_POINTS" );                 // 3.8.5.3 (2006/08/07)
373                    encode                  = HybsSystem.sys( "FILE_ENCODE" );       // ファイルエンコーãƒ?‚£ング  "DEFAULT","JISAutoDetect" ,"JIS", "EUC_JP", "MS932", "SJIS" , "Windows-31J" , "Shift_JIS"
374                    writerClass     = HybsSystem.sys( "TABLE_WRITER_DEFAULT_CLASS" );               // 3.8.5.3 (2006/08/07)
375                    fileAppend              = false;                        // ファイルをAPPENDモードで出力するか
376                    direct                  = false;
377                    zip                     = false;
378                    table                   = null;
379                    tableId                 = HybsSystem.TBL_MDL_KEY ;
380                    disposition     = "attachment";         // 3.8.0.9 (2005/10/17) 初期値変更 inline â‡?attachment
381                    param                   = null ;                        // 4.0.0 (2005/01/31)
382                    useNumber               = true;                         // 3.7.0.2 (2005/02/14)
383                    skipRowCount    = 0;                            // 5.7.9.0 (2014/08/08) ãƒ??タの書き込み開始位置を設å®?
384                    directory               = null;                         // 3.8.6.0 (2006/08/23)
385                    columns                 = null;                         // 4.0.0 (2005/12/31)
386                    useRenderer             = HybsSystem.sysBool( "USE_TABLE_WRITER_RENDERER" );    // 5.2.1.0 (2010/10/01)
387                    selectedAll             = true;                         // 5.5.5.5 (2012/08/24)
388            }
389    
390            /**
391             * TableWriter の実オブジェクトを生æ?して?ŒOutputStream に書き込みますã?
392             *
393             * @og.rev 3.5.4.1 (2003/12/01) 引数の PrintWriter をã?OutputStream に変更ã€?
394             * @og.rev 3.5.4.2 (2003/12/15) lang 引数ã‚?table と同時に設定しますã?
395             * @og.rev 3.5.4.2 (2003/12/15) TableWriter のサブクラス名変更ã€?
396             * @og.rev 3.5.4.3 (2004/01/05) EXCEL雛型参è?ファイルを指定するよã�?�«変更ã€?
397             * @og.rev 3.5.4.3 (2004/01/05) 引数をã? PrintWriter に戻すã?
398             * @og.rev 3.5.4.5 (2004/01/23) æ–?­—エンコードを渡すよã�?�«変更するã€?
399             * @og.rev 3.5.6.0 (2004/06/18) å�?¨®プラグイン関連付け設定を、シスãƒ?ƒ パラメータ に記述しますã?
400             * @og.rev 3.8.5.3 (2006/08/07) EXCEL時に fontName と fontPoint 属æ?をセãƒ?ƒˆしますã?
401             * @og.rev 4.0.0.0 (2005/01/31) キーのæŒ?®šを、TableWriter. から、TableWriter_ に変更しますã?
402             * @og.rev 4.0.0.0 (2005/12/31) 外部よりカラãƒ??(カンマ区åˆ?‚Š)を指定できるようにするã€?
403             * @og.rev 5.2.1.0 (2010/10/01) 書込処ç�?�§コードリソースのラベル変換を行うかどã�?�‹設å®?useRenderer 属æ?追åŠ?
404             * @og.rev 5.7.9.0 (2014/08/08) ãƒ??タの書き込み開始位置(skipRowCount)を設å®?
405             *
406             * @param   out PrintWriterオブジェクãƒ?
407             */
408            private void create( final PrintWriter out )  {
409                    // 5.2.1.0 (2010/10/01) writerClass で Renderer系の場合ã?、useRendererフラグに変更するã€?
410                    if( "ExcelRenderer".equalsIgnoreCase( writerClass ) ) {
411                            writerClass = "Excel" ;
412                            useRenderer = true;
413                    }
414                    else if( "Renderer".equalsIgnoreCase( writerClass ) ) {
415                            writerClass = "Default" ;
416                            useRenderer = true;
417                    }
418    
419                    String className = HybsSystem.sys( "TableWriter_" + writerClass ) ;             // 4.0.0 (2005/01/31)
420                    TableWriter writer = (TableWriter)HybsSystem.newInstance( className );  // 3.5.5.3 (2004/04/09)
421    
422                    writer.setDBTableModel( table,getLanguage() );
423                    writer.setSeparator( separator );
424                    writer.setHeaderSequence( headerSequence );
425                    writer.setEncode( encode );                                     // 3.5.4.5 (2004/01/23)
426                    writer.setAppend( fileAppend );                         // 3.5.4.2 (2003/12/15)
427                    if( param != null ) { writer.setParam( param ); }       // 4.0.0 (2005/01/31)
428                    writer.setUseNumber( useNumber );                       // 3.7.0.2 (2005/02/14)
429            //      if( columns == null ) {
430            //              columns = (String)getSessionAttribute( HybsSystem.TBL_WRITER_CLMS );
431            //              removeSessionAttribute( HybsSystem.TBL_WRITER_CLMS );
432            //      }
433                    writer.setColumns( columns );                           // 4.0.0 (2005/12/31)
434                    writer.setUseRenderer( useRenderer );           // 5.2.1.0 (2010/10/01)
435                    if( writer.isExcel() ) {                                        // 3.5.4.3 (2004/01/05)
436                            writer.setSheetName( sheetName );
437                            writer.setFilename( StringUtil.urlAppend( directory , filename ) );
438                            if( refFileURL != null && refFilename != null ) {
439                                    writer.setRefFilename( StringUtil.urlAppend( HybsSystem.url2dir(refFileURL) , refFilename ) );
440                            }
441                            if( refSheetName != null && fontPoint.length() > 0 ) {               // 5.7.9.0 (2014/08/08) nullチェãƒ?‚¯
442                                    writer.setRefSheetName( refSheetName );
443                            }
444    //                      writer.setFontName( nval( fontName,null ) );                            // 3.8.5.3 (2006/08/07)
445                            writer.setFontName( fontName )  ;                                                       // 5.7.9.0 (2014/08/08) nvalはずし
446                            if( fontPoint != null && fontPoint.length() > 0 ) {
447                                    writer.setFontPoint( Short.parseShort( fontPoint ) );   // 3.8.5.3 (2006/08/07)
448                            }
449                            writer.setSkipRowCount( skipRowCount );                                         // 5.7.9.0 (2014/08/08)
450                            writer.writeDBTable();
451                    }
452                    else {
453                            writer.writeDBTable( out );
454                    }
455            }
456    
457            /**
458             * PrintWriter を取得しますã?
459             *
460             * ここでは、ä¸?ˆ¬çš?�ªファイル出力をè€??した PrintWriter を作æ?しますã?
461             *
462             * @og.rev 2.2.0.0 (2002/12/17) 中国èª?国際化)対å¿?エンコードã?取得方法変更
463             * @og.rev 3.1.3.0 (2003/04/10) FILE_ENCODE から、エンコード情報を取得するã?
464             * @og.rev 3.5.4.1 (2003/12/01) PrintWriter をã?OutputStream に変更ã€?
465             * @og.rev 3.5.5.9 (2004/06/07) FileUtil.getBufferedReader を使用
466             * @og.rev 3.7.1.1 (2005/05/23) フォルãƒ?�Œなã�??合ã?、è¤?•°階層åˆ??フォルãƒ?‚’自動で作æ?しますã?
467             * @og.rev 3.8.0.0 (2005/06/07) FileUtil#getPrintWriter を利用ã€?
468             *
469             * @return      ファイル書きå?し用のPrintWriterオブジェクãƒ?
470             */
471            private PrintWriter getPrintWriter() {
472                    if( filename == null ) {
473                            String errMsg = "ファイル名がセãƒ?ƒˆされてã�?�¾せんã€?;
474                            throw new HybsSystemException( errMsg );
475                    }
476    
477                    // ※ 注æ„?StringUtil.urlAppend をçµ?�¿込んでã�?‚‹意図が不æ?。ä¸?—¦削除してã�?�¾すが、注æ„?
478                    // 3.8.0.0 (2005/06/07) FileUtil#getPrintWriter を利用ã€?
479            //      out = FileUtil.getPrintWriter( StringUtil.urlAppend( directory,filename ),fileAppend,encode);
480                    PrintWriter out = FileUtil.getPrintWriter( new File( directory,filename ),encode,fileAppend );
481    
482                    return out ;
483            }
484    
485            /**
486             * PrintWriter を取得しますã?
487             *
488             * 引数でæŒ?®šしたOutputStreamを利用して出力しますã?
489             *
490             * @og.rev 5.5.2.0 (2012/05/01) 新規作æ?
491             *
492             * @param       os      OutputStreamオブジェクãƒ?
493             *
494             * @return      æŒ?®šしたstreamに書きå?すPrintWriter
495             */
496            private PrintWriter getPrintWriter( final OutputStream os ) {
497                    PrintWriter out = FileUtil.getPrintWriter( os,encode );
498    
499                    return out ;
500            }
501            
502            /**
503             * チェãƒ?‚¯åˆ??ãƒ??ブルモãƒ?ƒ«をå?構æ?しますã?
504             *
505             * @og.rev 5.5.5.5 (2012/08/24) 新規作æ?
506             * @og.rev 5.5.9.1 (2012/12/07) å†?ƒ¨処ç�?¤‰更
507             *
508             * @param       oldTable        コピã?å…?ƒ†ーブルモãƒ?ƒ«
509             *
510             * @return      チェãƒ?‚¯したåˆ?� けで再構æ?したãƒ??ブルモãƒ?ƒ«
511             */
512            private DBTableModel getSelRowsTable( final DBTableModel oldTable ) {
513                    if( oldTable == null ) { return null; }         // 5.5.9.1 (2012/12/07) 引数のDBTableModelã�?null の場合ã?処ç�??
514    
515                    DBTableModel newTable = oldTable.newModel();
516                    final int[] rowNo = getParameterRows();
517                    final int rowCount = rowNo.length ;
518    
519                    for( int i=0; i<rowCount; i++ ) {
520                            newTable.addValues( oldTable.getValues(rowNo[i]), i );
521                    }
522                    return newTable;
523            }
524    
525            /**
526             * 【TAGã€?通常は使ã�?�¾せん)結果のDBTableModelをã?sessionに登録するときã?キーを指定しまã�?
527             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])ã€?
528             *
529             * @og.tag
530             * 検索結果より、DBTableModelオブジェクトを作æ?しますã?これをã?下流ã?viewタグ等に
531             * 渡すå?合にã€??常は、session を利用しますã?そã?場合ã?登録キーですã?
532             * query タグを同時に実行して、結果を求めるå?合ã?同ä¸?ƒ¡モリに配置される為ã€?
533             * こã? tableId 属æ?を利用して、メモリ空間をåˆ?�‘ますã?
534             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])ã€?
535             *
536             * @param       id sessionに登録する時ã? ID
537             */
538            public void setTableId( final String id ) {
539                    tableId = nval( getRequestParameter( id ), tableId );
540            }
541    
542            /**
543             * 【TAG】可変長ファイルを作æ?するときã?é ?›®区åˆ?‚Šæ–?­—をセãƒ?ƒˆしまã�?
544             *              (初期値:TableWriter#TAB_SEPARATOR[={@og.value TableWriter#TAB_SEPARATOR}])ã€?
545             *
546             * @og.tag 可変長ファイルを作æ?するときã?é ?›®区åˆ?‚Šæ–?­—をセãƒ?ƒˆしますã?
547             * (初期値:TableWriter#TAB_SEPARATOR[={@og.value TableWriter#TAB_SEPARATOR}])ã€?
548             *
549             * @param   separator é ?›®区åˆ?‚Šæ–?­?
550             * @see         org.opengion.hayabusa.io.TableWriter#TAB_SEPARATOR
551             */
552            public void setSeparator( final String separator ) {
553                    this.separator = nval( getRequestParameter( separator ),this.separator );
554            }
555    
556            /**
557             * 【TAG】DBTableModelの出力é?(LNSCD など)をセãƒ?ƒˆしますã?
558             *
559             * @og.tag
560             * Label,Name,Size,Class,Data のå�?ƒ•ィールドã?頭æ–?­—ã?アルファベットで
561             * 出力é?を設定しますã?
562             *
563             * @param   hs 出力é? (LNSCD など)
564             */
565            public void setHeaderSequence( final String hs ) {
566                    String[] headers = getRequestParameterValues( hs );
567                    if( headers != null ) {
568                            StringBuilder buf = new StringBuilder();
569                            for( int i=0; i<headers.length; i++ ) {
570                                    if( headers[i] != null ) { buf.append( headers[i] ); }
571                            }
572                            headerSequence = buf.toString();
573                    }
574            }
575    
576            /**
577             * 【TAG】ファイル保存å?ãƒ?‚£レクトリ名をæŒ?®šしますã?
578             *
579             * @og.tag
580             * こã?属æ?でæŒ?®šされるãƒ?‚£レクトリに、ファイルをセーブしますã?
581             * æŒ?®š方法ã?ã€??常の fileURL 属æ?と同様に、å?頭がã?'/' (UNIX) またã?ã€?¼’文字目がã?
582             * ":" (Windows)の場合ã?、指定ã?URLそã?ままのãƒ?‚£レクトリに、そã�?�§なã�??合ã?ã€?
583             * シスãƒ?ƒ パラメータ の FILE_URL 属æ?でæŒ?®šã?フォルãƒ??下に、作æ?されますã?
584             * fileURL = "{&#064;USER.ID}" とæŒ?®šすると、FILE_URL 属æ?でæŒ?®šã?フォルãƒ??下にã€?
585             * さらに、各個人ID別のフォルãƒ?‚’作æ?して、そこにセーブしますã?
586             *
587             * @og.rev 3.5.4.3 (2004/01/05) å†?ƒ¨処ç�?‚’、makeFileURL に移動ã?
588             * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソãƒ?ƒ‰の利用
589             * @og.rev 4.0.0.0 (2007/11/20) æŒ?®šされたãƒ?‚£レクトリ名ã?æœ?¾Œが"\"or"/"で終わってã�?�ªã�??合にã€?/"を付加するã€?
590             *
591             * @param       url 保存å?ãƒ?‚£レクトリå�?
592             */
593            public void setFileURL( final String url ) {
594                    String furl = nval( getRequestParameter( url ),null );
595                    if( furl != null ) {
596                            char ch = furl.charAt( furl.length()-1 );
597                            if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
598                            fileURL = StringUtil.urlAppend( fileURL,furl );
599                    }
600            }
601    
602            /**
603             * 【TAG】ファイルを作æ?するときã?ファイル名をセãƒ?ƒˆしまã�?
604             *              (初期値:FILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
605             *
606             * @og.tag ファイルを作æ?するときã?ファイル名をセãƒ?ƒˆしますã?
607             * (初期値:シスãƒ?ƒ 定数のFILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
608             *
609             * @param   filename ファイルå�?
610             * @see         org.opengion.hayabusa.common.SystemData#FILE_ENCODE
611             */
612            public void setFilename( final String filename ) {
613                    this.filename = nval( getRequestParameter( filename ),this.filename );
614            }
615    
616            /**
617             * 【TAG】EXCELファイルを書きå?すときã?シート名を設定しますã?
618             *
619             * @og.tag
620             * EXCELファイルを書きå?す時に、シート名を指定しますã?これにより、è¤?•°の形式ã?
621             * 異なるデータをé?次書きå?したã‚?appendモードを併用)することã‚??シートをæŒ?®šして
622             * 新規にEXCELを作æ?することが可能になりますã?
623             * 初期値は、Sheet1 ですã?
624             *
625             * @og.rev 3.5.4.2 (2003/12/15) 新規追åŠ?
626             *
627             * @param   sheet EXCELファイルのシート名
628             */
629            public void setSheetName( final String sheet ) {
630                    sheetName = nval( getRequestParameter( sheet ),sheetName );
631            }
632    
633            /**
634             * 【TAG】ファイルを作æ?するときã?ファイルエンコーãƒ?‚£ング名をセãƒ?ƒˆしまã�?
635             *              (初期値:FILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
636             *
637             * @og.tag
638             * "DEFAULT","JISAutoDetect" ,"JIS", "EUC_JP", "MS932", "SJIS" , "Windows-31J" , "Shift_JIS"
639             * (初期値:シスãƒ?ƒ 定数のFILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
640             *
641             * @og.rev 2.2.0.0 (2002/12/17) 中国èª?国際化)対å¿?エンコードã?取得方法変更
642             * @og.rev 3.1.3.0 (2003/04/10) FILE_ENCODE から、エンコード情報を取得するã?
643             *
644             * @param   enc ファイルエンコーãƒ?‚£ングå�?
645             * @see     <a href="http://www.iana.org/assignments/character-sets">IANA Charset Registry</a>
646             * @see         org.opengion.hayabusa.common.SystemData#FILE_ENCODE
647             */
648            public void setEncode( final String enc ) {
649                    encode = nval( getRequestParameter( enc ),encode );
650            }
651    
652            /**
653             * 【TAG】実際に書きå?すクラス名ã?略称({@og.doc03Link writerClass TableWriter_**** クラスの ****})を指定しまã�?初期値:Default)ã€?
654             *
655             * @og.tag
656             * 実際に書きå?すクラスå�?の略称)をセãƒ?ƒˆしますã?
657             * org.opengion.hayabusa.io.TableWriter インターフェースを継承したサブクラスですã?
658             * これは、org.opengion.plugin.io 以下ã? TableWriter_**** クラスの **** を与えますã?
659             * 属æ?クラス定義の {@link org.opengion.hayabusa.io.TableWriter TableWriter} を参照願いますã?
660             * {@og.doc03Link writerClass TableWriter_**** クラス}
661             *
662             * ExcelRenderer と、Renderer は、特別な名前で、useRenderer 属æ?にã€?true" をセãƒ?ƒˆするのと同じ効果がありますã?
663             * 実際は、ExcelRenderer â‡?Excel 、Renderer  â‡?Default のクラスが呼ばれますã?
664             *
665             * @param   writerClass クラスå�?の略称)
666             * @see         org.opengion.hayabusa.io.TableWriter  TableWriterのサブクラス
667             */
668            public void setWriterClass( final String writerClass ) {
669                    this.writerClass = nval( getRequestParameter( writerClass ),this.writerClass );
670            }
671    
672            /**
673             * 【TAG】追åŠ?ƒ¢ードで書き込ã‚?�‹どã�?�‹[true/false]を指定しまã�?初期値:false[新規モード])ã€?
674             *
675             * @og.tag DBTableModelのファイルをã?追åŠ?ƒ¢ードで書き込ã‚?�‹どã�?�‹をセãƒ?ƒˆしますã?
676             *
677             * @param   flag  [true:追åŠ?ƒ¢ーãƒ?それ以å¤?新規モード]
678             */
679            public void setFileAppend( final String flag ) {
680                    fileAppend = nval( getRequestParameter( flag ),fileAppend );
681            }
682    
683            /**
684             * 【å»?­¢】結果をダイレクトにEXCEL起動するかどã�?�‹[true/false]を指定しまã�?初期値:false[ファイル])ã€?
685             *
686             * @og.tag 結果をダイレクトに EXCEL ファイルとして出力するかどã�?�‹をセãƒ?ƒˆしますã?
687             *
688             * @param  flag  [true:ãƒ?‚¤レクãƒ?それ以å¤?ファイル]
689             * @deprecated 結果をダイレクトするとエンコード等でおかしな動きをする可能性があるã?
690             */
691            @Deprecated public void setDirect( final String flag ) {
692                    direct = nval( getRequestParameter( flag ),direct );
693            }
694    
695            /**
696             * 【TAG】結果をファイルに出力するときに、ZIPで圧縮するかどã�?�‹[true/false]を指定しまã�?初期値:false)ã€?
697             *
698             * @og.tag
699             * 初期値は、圧縮しなã�?�§すã?
700             *
701             * @param  flag ZIPで圧縮する [true:圧縮する/それ以å¤?しない]
702             */
703            public void setZip( final String flag ) {
704                    zip = nval( getRequestParameter( flag ),zip );
705            }
706    
707            /**
708             * 【TAG】Content-Disposition (inline:埋め込ã‚?attachment:ãƒ?‚¤アログを起å‹?を指定しまã�?初期値:attachment)ã€?
709             *
710             * @og.tag
711             * Content-Disposition を指定することで、ブラウザにアプリケーションãƒ??タã‚?
712             * 埋め込ã‚??ã�?inline)、セーãƒ?オープンのãƒ?‚¤アログを起動するã?ã�?attachment)
713             * æŒ?®šしますã?
714             * こã?属æ?が有効なのは、direct="true" で、zip="false"(初期値)のときã?みですã?
715             * 値は、inline 、attachment が指定できますã?
716             * 初期値は、attachment ですã?
717             * 注意:動作検証しましたがã?inline と attachment で動作に差が現れませんでしたã€?
718             *
719             * @og.rev 3.1.5.0 (2003/04/20) Content-Disposition を外部からæŒ?®šできるように変更ã€?
720             * @og.rev 3.8.0.9 (2005/10/17) Content-Disposition 初期値変更 inline â‡?attachment
721             *
722             * @param  pos Content-Disposition [inline/attachment]
723             */
724            public void setDisposition( final String pos ) {
725                    disposition = nval( getRequestParameter( pos ),disposition );
726                    if( !"inline".equals( disposition ) && !"attachment".equals( disposition ) ) {
727                            String errMsg = "disposition には、inline ã�?attachment 以外ã?æŒ?®šできませんã€?
728                                                    + "disposition=[" + disposition + "]" ;
729                            throw new HybsSystemException( errMsg );
730                    }
731            }
732    
733            /**
734             * 【TAG】EXCEL雛型参ç?ファイルのãƒ?‚£レクトリ名をセãƒ?ƒˆしますã?
735             *
736             * @og.tag
737             * こã?属æ?でæŒ?®šされるãƒ?‚£レクトリに、ファイルをセーブしますã?
738             * æŒ?®š方法ã?ã€??常の fileURL 属æ?と同様に、å?頭がã?'/' (UNIX) またã?ã€?¼’文字目がã?
739             * ":" (Windows)の場合ã?、指定ã?URLそã?ままのãƒ?‚£レクトリに、そã�?�§なã�??合ã?ã€?
740             * シスãƒ?ƒ パラメータ の FILE_URL 属æ?でæŒ?®šã?フォルãƒ??下に、作æ?されますã?
741             * fileURL = "{&#064;USER.ID}" とæŒ?®šすると、FILE_URL 属æ?でæŒ?®šã?フォルãƒ??下にã€?
742             * さらに、各個人ID別のフォルãƒ?‚’作æ?して、そこにセーブしますã?
743             *
744             * @og.rev 3.5.4.3 (2004/01/05) 新規作æ?
745             * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソãƒ?ƒ‰の利用
746             * @og.rev 4.0.0.0 (2007/11/20) æŒ?®šされたãƒ?‚£レクトリ名ã?æœ?¾Œが"\"or"/"で終わってã�?�ªã�??合にã€?/"を付加するã€?
747             *
748             * @param       url EXCEL雛型参ç?ファイルのãƒ?‚£レクトリå�?
749             */
750            public void setRefFileURL( final String url ) {
751                    String furl = nval( getRequestParameter( url ),null );
752                    if( furl != null ) {
753                            char ch = furl.charAt( furl.length()-1 );
754                            if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
755                            refFileURL = StringUtil.urlAppend( refFileURL,furl );
756                    }
757            }
758    
759            /**
760             * 【TAG】EXCEL雛型参è?ファイル名をセãƒ?ƒˆしますã?
761             *
762             * @og.tag
763             * å†?ƒ¨処ç�?š„にはã€?››形ファイルの雛形シートをメモリ上に構築しã€?
764             * そã?シートã?セルに、データを追åŠ?�—てã�?��ますã?
765             * æœ?¾Œにはã€?››形シートとして存在しなã�?ƒ¨åˆ??、すべて削除しますã?
766             * 雛形シートを使わなã�??合ã?、新規シートに追åŠ?�—てã�?��ことになりますã?
767             * appendモードã?場合ã?、オリジナルが雛形ファイルになりますã?
768             * 雛形ファイルのæŒ?®šã?、無効になりますã?
769             * ※ 互換性の為、同じ名前ã?設定ã?有効ですã?
770             *
771             * ※ Excel2007形å¼?XSSF)では、行å?体をæŒ?®šした色ã‚?½«線ã?ã€?
772             * セルとして認識されません。ç¯?›²æŒ?®šで、罫線や色付けを行うå¿?¦�がありますã?
773             *
774             * @og.rev 3.5.4.3 (2004/01/05) 新規作æ?
775             *
776             * @param   filename EXCEL雛型参è?ファイルå�?
777             */
778            public void setRefFilename( final String filename ) {
779                    refFilename = nval( getRequestParameter( filename ),refFilename );
780            }
781    
782            /**
783             * 【TAG】EXCEL雛型参è?ファイルのシート名を設定しますã?
784             *
785             * @og.tag
786             * EXCELファイルを書きå?す時にã€?››型として参ç?するシート名を指定しますã?
787             * これにより、è¤?•°の形式ã?異なるデータをé?次書きå?したã‚?appendモードを併用)する
788             * ことã‚??シートをæŒ?®šして新規にEXCELを作æ?する場合にフォーãƒ?‚’設定する事が可能になりますã?
789             * 初期値は、null(第ä¸?‚·ーãƒ? ですã?
790             *
791             * @og.rev 3.5.4.3 (2004/01/05) 新規追åŠ?
792             *
793             * @param   sheet EXCEL雛型参è?ファイルのシート名
794             */
795            public void setRefSheetName( final String sheet ) {
796                    refSheetName = nval( getRequestParameter( sheet ),refSheetName );
797            }
798    
799            /**
800             * 【TAG】EXCEL出力時のãƒ?ƒ•ォルトフォント名を設定しまã�?
801             *              (初期値:TABLE_WRITER_DEFAULT_FONT_NAME[={@og.value org.opengion.hayabusa.common.SystemData#TABLE_WRITER_DEFAULT_FONT_NAME}])ã€?
802             *
803             * @og.tag
804             * これは、EXCEL追åŠ?©Ÿè?として実è£?�•れてã�?�¾すã?
805             *
806             * EXCELファイルを書きå?す時に、デフォルトフォント名を指定しますã?
807             * フォント名は、EXCELのフォント名をそのまま使用してくださいã€?
808             * å†?ƒ¨çš?�«、POI の org.apache.poi.hssf.usermodel.HSSFFont#setFontName( String )
809             * に設定されますã?
810             * (初期値:シスãƒ?ƒ 定数のTABLE_WRITER_DEFAULT_FONT_NAME[={@og.value org.opengion.hayabusa.common.SystemData#TABLE_WRITER_DEFAULT_FONT_NAME}])ã€?
811             *
812             * @og.rev 3.8.5.3 (2006/08/07) 新規追åŠ?
813             *
814             * @param   name ãƒ?ƒ•ォルトフォント名
815             * @see         org.opengion.hayabusa.common.SystemData#TABLE_WRITER_DEFAULT_FONT_NAME
816             */
817            public void setFontName( final String name ) {
818                    fontName = nval( getRequestParameter( name ),fontName );
819            }
820    
821            /**
822             * 【TAG】EXCEL出力時のãƒ?ƒ•ォルトフォントã?イント数を設定しますã?
823             *
824             * @og.tag
825             * これは、EXCEL追åŠ?©Ÿè?として実è£?�•れてã�?�¾すã?
826             *
827             * EXCELファイルを書きå?す時に、デフォルトã?イント数を指定しますã?
828             * å†?ƒ¨çš?�«、POI の org.apache.poi.hssf.usermodel.HSSFFont#setFontHeightInPoints( short )
829             * に設定されますã?
830             * 初期値は、シスãƒ?ƒ リソース の TABLE_WRITER_DEFAULT_FONT_POINTS ですã?
831             *
832             * @og.rev 3.8.5.3 (2006/08/07) 新規追åŠ?
833             *
834             * @param   point ãƒ?ƒ•ォルトフォントã?イント数
835             */
836            public void setFontPoint( final String point ) {
837                    fontPoint = nval( getRequestParameter( point ),fontPoint );
838            }
839    
840            /**
841             * 【TAG】行番号æƒ??をã?出力すã‚?しない[true/false]を指定しまã�?初期値:true)ã€?
842             *
843             * @og.tag
844             * 通常のフォーマットでは、各行ã?先é?に行番号をå?力しますã?
845             * これはã€?NAME 属æ?を使用する場合には、å¿?�š出力するå¿?¦�がありますã?
846             * (#NAME 属æ?は、読み取り時には、å¿??ですã?)
847             * こã?、å?頭の行番号が不要な場å�?つまりã?他ã?シスãƒ?ƒ へのãƒ??タ出力ã?
848             * こã?シスãƒ?ƒ ではã€?NAME 属æ?がå?力されなã�?�Ÿめã?読み込みできませんã€?
849             * こã?行番号をå?力しなã�?‚ˆã�?�«できますã?
850             * なおã?EXCEL 出力には、この設定ã?適用されませんã€?暫定対å¿?
851             * 初期値は、true(出力すã‚? ですã?
852             *
853             * @og.rev 3.7.0.2 (2005/02/14) 新規追åŠ?
854             *
855             * @param   useNo 行番号æƒ??を指å®?[true:出力すã‚?false:しない]
856             */
857            public void setUseNumber( final String useNo ) {
858                    useNumber = nval( getRequestParameter( useNo ),useNumber );
859            }
860    
861            /**
862             * 【TAG】書き込み先ファイルのカラãƒ??をã?外部(タグ)よりæŒ?®šしますã?
863             *
864             * @og.tag
865             * こã?æŒ?®šにより、書き込ã‚?‚«ラãƒ?‚’限定的に使用することが可能ですã?
866             * カラãƒ?��は、検索したDBTableModel上に含まれる名前でæŒ?®šするå¿?¦�がありますã?
867             * 別名で書き込みたい場合ã?、予めそã?名前で検索しておくå¿?¦�がありますã?
868             *
869             * @og.rev 4.0.0.0 (2005/12/31) 新規作æ?
870             *
871             * @param   clms 書き込み先ファイルのカラãƒ??(カンマ区åˆ?‚Šæ–?­?
872             */
873            public void setColumns( final String clms ) {
874                    columns = nval( getRequestParameter( clms ),columns );
875            }
876    
877            /**
878             * 【TAG】書込処ç�?�§コードリソースのラベル変換を行うかどã�?�‹を指定しまã�?
879             *              (初期値:USE_TABLE_WRITER_RENDERER[={@og.value org.opengion.hayabusa.common.SystemData#USE_TABLE_WRITER_RENDERER}])ã€?
880             *
881             * @og.tag
882             * コードリソースをそのままの値で出力すると、数字や記号になり何が書かれてã�?‚‹のã�?
883             * 不æ?になりますã?
884             * これは、コードリソースをラベルに変換して出力するかどã�?�‹を指定しますã?
885             * 当然、コードã?ユニã?クですが、ラベルはユニã?クになるかどã�?�‹保障はされてã�?�¾せんので
886             * TableReader 系で読み込ã‚??合には、リスクが発生しますã?
887             * またã?TableReader 系で読み込ã‚??合にもã?ラベルからコードを求めるé?変換を行うようにã€?
888             * setUseRenderer メソãƒ?ƒ‰でæŒ?®šするå¿?¦�がありますã?
889             *
890             * 従来は、TableWriter 系に、TableWriter_Renderer 系のクラスを作って対応してã�?�¾したがã?
891             * こã?メソãƒ?ƒ‰の属æ?値のフラグで、制御しますã?
892             * (初期値:シスãƒ?ƒ 定数のUSE_TABLE_WRITER_RENDERER[={@og.value org.opengion.hayabusa.common.SystemData#USE_TABLE_WRITER_RENDERER}])ã€?
893             *
894             * @og.rev 5.2.1.0 (2010/10/01) 新規作æ?
895             *
896             * @param  flag コードリソースのラベル変換を行うかどã�?�‹
897             * @see         org.opengion.hayabusa.common.SystemData#USE_TABLE_WRITER_RENDERER
898             */
899            public void setUseRenderer( final String flag ) {
900                    useRenderer = nval( getRequestParameter( flag ),useRenderer );
901            }
902    
903            /**
904             * 【TAGã€?通常は使ã�?�¾せん)ãƒ??タの書き込み開始行番号を設定しまã�?初期値:0)ã€?
905             *
906             * @og.tag
907             * TAB区åˆ?‚Šãƒ?‚­ストやEXCEL等ã?ãƒ??タの書き込みの開始行番号を指定しますã?
908             * 属æ?名ã?、行を飛ã?すå?ç�?�¨ã�?�†ことで、readTable タグと同じ名称ですã?
909             * ファイルの先é?行がã€?¼�行としてカウントしますã?で、設定å?は、読み飛ã?ã�?
910             * 件数になりますã?(?‘とæŒ?®šするとã€?¼‘行読み飛ã?しã??’行目から読み込みますã?)
911             * 行ã?読み飛ã?しと、カラãƒ??読み飛ã?ã�?columns)、refFileURL、refFilenameã€?
912             * refSheetName とともに使用すれば、ある程度のレイアウト設定が可能ですã?
913             * なおã?こã?機è?は、TableWriter_Excel のみに実è£?�—ますã?
914             *
915             * @og.rev 5.7.9.0 (2014/08/08) 新規作æ?
916             *
917             * @param       count 書き込み開始行番号
918             */
919            public void setSkipRowCount( final String count ) {
920                    skipRowCount = nval( getRequestParameter( count ),skipRowCount );
921            }
922    
923            /**
924             * 【TAG】チェãƒ?‚¯行ã?みを対象にするかをæŒ?®šしまã�?初期値:true)ã€?
925             *
926             * @og.tag
927             * falseを指定する事で、前画面でチェãƒ?‚¯した行ã?みをå?力しますã?
928             * 初期値は全ての行を出åŠ?true)ですã?
929             * 出力されるファイルの行番号はã€?から振りなおされますã?
930             *
931             * @og.rev 5.5.5.5 (2012/08/24) 新規作æ?
932             *
933             * @param   flag 対象にするか指å®?[true:全件/false:対象のみ]
934             */
935            public void setSelectedAll( final String flag ) {
936                    selectedAll = nval( getRequestParameter( flag ),selectedAll );          // 5.5.9.1 (2012/12/07) バグ対å¿?
937            }
938            
939            /**
940             * 【TAG】事前にファイルを削除するかどã�?�‹を指定しまã�?初期値:false)ã€?
941             *
942             * @og.tag
943             * 出力å?の DBTableModel がã?存在しなã�?�‹ã€?¼�件の場合ã?過去に作æ?したファイルã�?
944             * そã?まま、残ってã�?‚‹と、不要なトラブルのもととなる為、実行前に削除するã�?
945             * どã�?�‹を指定できますã?
946             * なおã?fileAppend="true"?ˆ追åŠ?ƒ¢ードで書き込ã‚?‚’æŒ?®?時には、データが0件でã‚?
947             * 事前削除は行いませんã€?
948             * 初期値は互換性のため削除しなã�?false)ですã?
949             *
950             * @og.rev 5.5.9.1 (2012/12/07) 新規作æ?
951             *
952             * @param   flag 事前削除するかどã�?�‹ [true:削除する/false:削除しない]
953             */
954            public void setBeforeDelete( final String flag ) {
955                    beforeDelete = nval( getRequestParameter( flag ),beforeDelete );
956            }
957    
958            /**
959             * WriteTable オブジェクトに渡すパラメータオブジェクトをセãƒ?ƒˆしますã?
960             *
961             * @og.tag
962             * WriteTableParamTag クラスよりセãƒ?ƒˆされますã?
963             *
964             * @og.rev 4.0.0.0 (2005/02/28) 新規追åŠ?
965             *
966             * @param   entry HybsEntryオブジェクãƒ?
967             */
968            protected void addParam( final HybsEntry entry ) {
969                    if( param == null ) { param = new ArrayList<HybsEntry>(); }
970                    param.add( entry );
971            }
972    
973            /**
974             * シリアライズ用のカスタãƒ?‚·リアライズ書き込みメソãƒ?ƒ‰
975             *
976             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
977             * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
978             *
979             * @param       strm    ObjectOutputStreamオブジェクãƒ?
980             * @throws IOException  入出力エラーが発生したå?å�?
981             */
982            private void writeObject( final ObjectOutputStream strm ) throws IOException {
983                    strm.defaultWriteObject();
984            }
985    
986            /**
987             * シリアライズ用のカスタãƒ?‚·リアライズ読み込みメソãƒ?ƒ‰
988             *
989             * ここでは、transient 宣è¨?�•れたå†?ƒ¨変数のå†??初期化がå¿?¦�なフィールドã?み設定しますã?
990             *
991             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
992             * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
993             *
994             * @param       strm    ObjectInputStreamオブジェクãƒ?
995             * @see #release2()
996             * @throws IOException  シリアライズに関する入出力エラーが発生したå?å�?
997             * @throws ClassNotFoundException       クラスを見つけることができなかったå?å�?
998             */
999            private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
1000                    strm.defaultReadObject();
1001            }
1002    
1003            /**
1004             * こã?オブジェクトã?æ–?­—å?表現を返しますã?
1005             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
1006             *
1007             * @return こã?クラスのæ–?­—å?表現
1008             */
1009            @Override
1010            public String toString() {
1011                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
1012                                    .println( "VERSION"                     ,VERSION                )
1013                                    .println( "BASE_URL"            ,BASE_URL               )
1014                                    .println( "separator"           ,separator              )
1015                                    .println( "headerSequence"      ,headerSequence )
1016                                    .println( "fileURL"                     ,fileURL                )
1017                                    .println( "filename"            ,filename               )
1018                                    .println( "refFileURL"          ,refFileURL             )
1019                                    .println( "refFilename"         ,refFilename    )
1020                                    .println( "encode"                      ,encode                 )
1021                                    .println( "writerClass"         ,writerClass    )
1022                                    .println( "fileAppend"          ,fileAppend             )
1023                                    .println( "direct"                      ,direct                 )
1024                                    .println( "zip"                         ,zip                    )
1025                                    .println( "disposition"         ,disposition    )
1026                                    .println( "tableId"                     ,tableId                )
1027                                    .println( "sheetName"           ,sheetName              )
1028                                    .println( "refSheetName"        ,refSheetName   )
1029                                    .println( "useNumber"           ,useNumber              )
1030                                    .println( "Other..."    ,getAttributes().getAttribute() )
1031                                    .fixForm().toString() ;
1032            }
1033    }