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 */
016package org.opengion.hayabusa.taglib;
017
018import org.opengion.hayabusa.common.HybsSystem;
019import org.opengion.hayabusa.common.HybsSystemException;
020import org.opengion.fukurou.util.FileString;
021import org.opengion.fukurou.util.FileUtil;
022
023import org.opengion.fukurou.util.StringUtil ;
024import static org.opengion.fukurou.util.StringUtil.nval ;
025
026import java.io.File;
027import java.io.IOException;
028
029/**
030 * 各種アクションを指定して、ファイル関連の操作をおこなうタグです。
031 *
032 * 各種アクション に応じた振る舞いを行います。
033 * 結果については、false の場合は、body 要素を表示して、終了します。
034 * これは、BODYにエラーメッセージを書いておくことを想定した作りになっています。
035
036 * 判定結果を反転したい場合は、notEquals 属性を使用してください。また、
037 * 結果に応じて、処理を止めたくない場合は、useStop 属性を false に指定することで、
038 * 後続処理を実行できます。
039 *
040 * [各種アクション]
041 *       canRead          読み込めるかどうかを判定。
042 *       canWrite         変更できるかどうか判定。
043 *       createNewFile    空の新しいファイルを不可分 (atomic) に生成。(そのファイルがまだ存在しない場合だけ)
044 *       delete           ファイルまたはディレクトリを削除。
045 *       renameTo         ファイルまたはディレクトリ名を変更。
046 *       exists           ファイルが存在するかどうか判定。
047 *       isDirectory      ファイルがディレクトリであるかどうか判定。
048 *       isFile           ファイルが普通のファイルかどうか判定。
049 *       isHidden         ファイルが隠しファイルかどうか判定。
050 *       mkdir            ディレクトリを生成。
051 *       mkdirs           ディレクトリを複数生成。
052 *       read             ファイルを読み込んでjspWriterに出力
053 *       existsLength     ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
054 *       copy             ファイルまたはディレクトリをコピー(file1 ⇒ file2 にコピー)。
055 *
056 * @og.formSample
057 * ●形式:<og:file action="…" fileURL="…" >・・・</og:file>
058 * ●body:あり(EVAL_BODY_INCLUDE:BODYをインクルードし、{@XXXX} は解析しません)
059 *
060 * ●Tag定義:
061 *   <og:file
062 *       action           ○【TAG】アクション(canRead,canWrite,createNewFile,delete,exists,isDirectory,isFile,isHidden,mkdir,mkdirs)を指定します(必須)。
063 *       fileURL            【TAG】操作するファイルのディレクトリを指定します (初期値:FILE_URL[=filetemp/])
064 *       file1              【TAG】基準となるファイル名を指定します(コマンドの左辺のファイル名です)
065 *       file2              【TAG】処理結果となるファイル名を指定します(コマンドの右辺のファイル名です)
066 *       notEquals          【TAG】判定結果を反転させるかどうか[true/false]を指定します(初期値:false)
067 *       useStop            【TAG】エラー時BODYを処理後に停止するかどうか[true/false]を指定します(初期値:true)
068 *       encode             【TAG】ファイルを読み込む(action="READ")際のエンコードを指定します(初期値:OS依存文字コード)
069 *       caseKey            【TAG】このタグ自体を利用するかどうかの条件キーを指定します(初期値:null) 5.7.7.2 (2014/06/20)
070 *       caseVal            【TAG】このタグ自体を利用するかどうかの条件値を指定します(初期値:null) 5.7.7.2 (2014/06/20)
071 *       caseNN             【TAG】指定の値が、null/ゼロ文字列 でない場合(Not Null=NN)は、このタグは使用されます(初期値:true) 5.7.7.2 (2014/06/20)
072 *       caseNull           【TAG】指定の値が、null/ゼロ文字列 の場合は、このタグは使用されます(初期値:true) 5.7.7.2 (2014/06/20)
073 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
074 *   >   ... Body ...
075 *   </og:file>
076 *
077 * ●使用例
078 *    ・ファイルの存在チェック→存在しなければエラーメッセージを表示。
079 *        <og:file action="exists" fileURL="N:/CIR/" file1="{@USER.LKISB}/{@USER.LDNO1KAI}.cir/001.sht">
080 *            <og:message lbl="RKE_0157" comment="回路図が存在しません。" />
081 *        </og:file>
082 *
083 *    ・N:/Filetemp/にユーザーディレクトリが存在しなければ作成。→失敗した場合エラーメッセージを表示。
084 *        <og:file action="mkdir" fileURL="N:/Filetemp/{@USER.ID}" >
085 *            <og:message comment="エラーが発生しました。システム管理者に連絡してください。" />
086 *        </og:file>
087 *
088 *    ・N:/Filetemp/test.txt ファイルの削除。ファイルが存在しなくても処理を続ける。
089 *        <og:file action="delete" fileURL="N:/Filetemp/" file1="test.txt" useStop="false" >
090 *            <og:message comment="ファイルは存在しませんでした。" />
091 *        </og:file>
092 *
093 * @og.group その他部品
094 *
095 * @version  4.0
096 * @author       Kazuhiko Hasegawa
097 * @since    JDK5.0,
098 */
099public class FileTag extends CommonTagSupport {
100        //* このプログラムのVERSION文字列を設定します。   {@value} */
101        private static final String VERSION = "5.7.7.2 (2014/06/20)" ;
102
103        private static final long serialVersionUID = 577220140620L ;
104
105        /** action 引数に渡す事の出来る アクションコマンド  読み込めるかどうか {@value} */
106        public static final String ACT_CANREAD  = "canRead" ;
107        /** action 引数に渡す事の出来る アクションコマンド  変更できるかどうか {@value} */
108        public static final String ACT_CANWRITE    = "canWrite" ;
109        /** action 引数に渡す事の出来る アクションコマンド  空の新しいファイルを不可分 (atomic) に生成します (そのファイルがまだ存在しない場合だけ {@value} */
110        public static final String ACT_CREATENEWFILE    = "createNewFile" ;
111        /** action 引数に渡す事の出来る アクションコマンド  ファイルまたはディレクトリを削除{@value}       */
112        public static final String ACT_DELETE    = "delete" ;
113        /** action 引数に渡す事の出来る アクションコマンド  ファイルが存在するかどうか {@value} */
114        public static final String ACT_EXISTS    = "exists" ;
115        /** action 引数に渡す事の出来る アクションコマンド  ファイルがディレクトリであるかどうか{@value}     */
116        public static final String ACT_ISDIRECTORY        = "isDirectory" ;
117        /** action 引数に渡す事の出来る アクションコマンド  ファイルが普通のファイルかどうか{@value}       */
118        public static final String ACT_ISFILE    = "isFile" ;
119        /** action 引数に渡す事の出来る アクションコマンド  ファイルが隠しファイルかどうか {@value} */
120        public static final String ACT_ISHIDDEN    = "isHidden" ;
121        /** action 引数に渡す事の出来る アクションコマンド  ディレクトリを生成します。 {@value} */
122        public static final String ACT_MKDIR    = "mkdir" ;
123        /** action 引数に渡す事の出来る アクションコマンド  ディレクトリを生成します。 {@value} */
124        public static final String ACT_MKDIRS   = "mkdirs" ;
125        /** action 引数に渡す事の出来る アクションコマンド  ファイル名を変更します。 {@value} */
126        public static final String ACT_RENAMETO = "renameTo" ;          // 3.5.6.5 (2004/08/09)
127        /** action 引数に渡す事の出来る アクションコマンド  ファイルを読み込んで表示します。 {@value} */
128        public static final String ACT_READ     = "read" ;              // 3.6.0.0 (2004/09/25)
129        /** action 引数に渡す事の出来る アクションコマンド  ファイルサイズが0Byte以上のファイルが存在するかどうか判定。 {@value} */
130        public static final String ACT_EXISTSLENGTH      = "existsLength" ;             // 3.8.5.2 (2006/05/31)
131        /** action 引数に渡す事の出来る アクションコマンド  ファイルまたはディレクトリをコピーします。 {@value} */
132        public static final String ACT_COPY      = "copy" ;             // 5.3.6.0 (2011/06/01)
133
134        /** action 引数に渡す事の出来る コマンド リスト  */
135        private static final String[] ACTION_LIST = new String[] {
136                ACT_CANREAD , ACT_CANWRITE , ACT_CREATENEWFILE , ACT_DELETE , ACT_EXISTS , ACT_ISDIRECTORY ,
137                ACT_ISFILE , ACT_ISHIDDEN , ACT_MKDIR , ACT_MKDIRS , ACT_RENAMETO , ACT_READ , ACT_EXISTSLENGTH , ACT_COPY };
138
139        private String  fileURL         = HybsSystem.sys( "FILE_URL" );
140        private String  file1           = "";
141        private String  file2           = null;
142        private String  action          = null;
143        private boolean rtnCode         = false;
144
145        private boolean notEquals       = false;        // 3.8.5.2 (2006/05/31) 判定結果を反転させて処理します。
146        private boolean useStop         = true;         // 3.8.5.2 (2006/05/31) エラー時BODYを処理後に停止(true)するかどうか
147
148        private String encode           = null;         // 5.1.9.0 (2010/08/01) READ時のエンコード指定
149
150        /**
151         * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
152         *
153         * @og.rev 3.6.0.0 (2004/09/25) file オブジェクトの作成を actionExec 移動
154         * @og.rev 3.8.5.2 (2006/05/31) notEquals追加。 判定結果を反転させて処理します。
155         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
156         *
157         * @return      後続処理の指示
158         */
159        @Override
160        public int doStartTag() {
161                // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
162                if( useTag() ) {
163                        try {
164                                rtnCode = notEquals ^ actionExec( action );             // 3.8.5.2 (2006/05/31) 排他的論理和(XOR)
165                        }
166                        catch( IOException ex ) {
167                                String errMsg = "指定のアクションは実行できません。アクションエラー"
168                                                                + HybsSystem.CR
169                                                                + "action=[" + action + "] , "
170                                                                + "  fileURL=[" + fileURL + "]"
171                                                                + "  file1=[" + file1 + "]"
172                                                                + "  file2=[" + file2 + "]" ;
173                                throw new HybsSystemException( errMsg,ex );             // 3.5.5.4 (2004/04/15) 引数の並び順変更
174                        }
175
176                        if( rtnCode ) { return SKIP_BODY ; }                    // Body を評価しない
177                        else {                  return EVAL_BODY_INCLUDE ; }    // Body インクルード( extends TagSupport 時)
178                }
179
180                return SKIP_BODY ;
181        }
182
183        /**
184         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
185         *
186         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
187         * @og.rev 3.8.5.2 (2006/05/31) useStop 追加。 エラー時BODYを処理後に停止(true)するかどうか
188         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
189         *
190         * @return      後続処理の指示
191         */
192        @Override
193        public int doEndTag() {
194                debugPrint();           // 4.0.0 (2005/02/28)
195
196                if( useTag() ) {
197                        return ( useStop && !rtnCode ) ? SKIP_PAGE : EVAL_PAGE ;
198                }
199
200                return EVAL_PAGE ;
201        }
202
203        /**
204         * タグリブオブジェクトをリリースします。
205         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
206         *
207         * @og.rev 2.0.0.4 (2002/09/27) カスタムタグの release() メソッドを、追加
208         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
209         * @og.rev 3.6.0.0 (2004/09/24) columns 、tableId 、file 削除
210         * @og.rev 3.8.5.2 (2006/05/31) notEquals 、useStop 追加
211         * @og.rev 5.1.9.0 (2010/08/01) READ時のエンコード指定
212         *
213         */
214        @Override
215        protected void release2() {
216                super.release2();
217                fileURL         = HybsSystem.sys( "FILE_URL" );
218                file1           = "";
219                file2           = null;
220                action          = null;
221                rtnCode         = false;
222                notEquals       = false;        // 3.8.5.2 (2006/05/31) 判定結果を反転させて処理します。
223                useStop         = true;         // 3.8.5.2 (2006/05/31) エラー時BODYを処理後に停止(true)するかどうか
224                encode          = null;         // 5.1.9.0 (2010/08/01) READ時のエンコード指定
225        }
226
227        /**
228         * アクションを実行します。
229         * アクションは,指定のアクションコマンドに対応する処理を入力データに
230         * 対して行います。
231         *
232         * @og.rev 3.0.0.0 (2002/12/25) ACTION_LIST のチェックを削除
233         * @og.rev 3.6.0.0 (2004/09/25) ACT_read を追加 , file オブジェクトを移動
234         * @og.rev 3.8.5.2 (2006/05/31) existsLength 追加
235         * @og.rev 4.0.0.0 (2007/11/28) メソッドの戻り値をチェックします。
236         * @og.rev 5.1.9.0 (2010/08/01) READ時のエンコード指定
237         * @og.rev 5.3.6.0 (2011/06/01) ACT_copy 対応
238         * @og.rev 5.7.1.1 (2013/12/13) copy元(file1)のファイルが存在しなければ、エラーにします。
239         *
240         * @param       action アクションコマンド(public static final 宣言されている文字列)
241         *
242         * @return      実行後のデータ
243         */
244        private boolean actionExec( final String action ) throws IOException {
245                String directory = HybsSystem.url2dir( fileURL );
246                File file = new File( StringUtil.urlAppend( directory,file1 ) );
247
248                boolean rtnVal = false;
249                if( action != null ) {
250                        if(      ACT_CANREAD.equalsIgnoreCase(           action ) ) { rtnVal = file.canRead(); }
251                        else if( ACT_CANWRITE.equalsIgnoreCase(          action ) ) { rtnVal = file.canWrite(); }
252                        else if( ACT_CREATENEWFILE.equalsIgnoreCase( action ) ) { rtnVal = file.createNewFile(); }
253                        else if( ACT_DELETE.equalsIgnoreCase(            action ) ) { rtnVal = file.delete(); }
254                        else if( ACT_EXISTS.equalsIgnoreCase(            action ) ) { rtnVal = file.exists(); }
255                        else if( ACT_ISDIRECTORY.equalsIgnoreCase(       action ) ) { rtnVal = file.isDirectory(); }
256                        else if( ACT_ISFILE.equalsIgnoreCase(            action ) ) { rtnVal = file.isFile(); }
257                        else if( ACT_ISHIDDEN.equalsIgnoreCase(          action ) ) { rtnVal = file.isHidden(); }
258                        else if( ACT_MKDIR.equalsIgnoreCase(             action ) ) {
259                                if( file.isDirectory() ) { rtnVal = true; }
260                                else { rtnVal = file.mkdir(); }
261                        }
262                        else if( ACT_MKDIRS.equalsIgnoreCase(            action ) ) { rtnVal = file.mkdirs(); }
263                        else if( ACT_RENAMETO.equalsIgnoreCase(          action ) ) {
264                                if( file2 != null ) {
265                                        File newFile = new File( StringUtil.urlAppend( directory,file2 ) );
266                                        if( newFile.exists() && !newFile.delete() ) {
267                                                String errMsg = "所定のファイルを削除できませんでした。[" + newFile + "]" ;
268                                                throw new RuntimeException( errMsg );
269                                        }
270                                        rtnVal = file.renameTo( newFile );
271                                }
272                        }
273                        // 3.6.0.0 (2004/09/25) ACT_read を追加
274                        else if( ACT_READ.equalsIgnoreCase(                      action ) ) {
275                                if( file.isFile() ) {
276                                        FileString fs = new FileString();
277                                        fs.setFilename( StringUtil.urlAppend( directory,file1 ) );
278                                        if( encode != null ) { fs.setEncode( encode ); } // 5.1.9.0 (2010/08/01) READ時のエンコード指定
279                                        String val = fs.getValue();
280
281                                        jspPrint( nval( getRequestParameter( val ),"" ) );
282                                        rtnVal = true;
283                                }
284                                else {
285                                        String errMsg = "ファイルが存在しないか、ファイルではありません。"
286                                                        + HybsSystem.CR
287                                                        + "action=[" + action + "] , "
288                                                        + "  fileURL=[" + fileURL + "]"
289                                                        + "  directory=[" + directory + "]"
290                                                        + "  file1=[" + file1 + "]" ;
291                                        throw new HybsSystemException( errMsg );
292                                }
293                        }
294                        // 3.8.5.2 (2006/05/31) ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
295                        else if( ACT_EXISTSLENGTH.equalsIgnoreCase( action ) ) {
296                                rtnVal = file.exists() && file.length() > 0L ;
297                        }
298                        // 5.3.6.0 (2011/06/01) ファイルコピー対応
299                        // 6.0.0.1 (2014/04/25) These nested if statements could be combined
300                        else if( ACT_COPY.equalsIgnoreCase( action ) && file2 != null ) {
301                                File newFile = new File( StringUtil.urlAppend( directory,file2 ) );
302                                if( file.isFile() ) {
303                                        // FileUtil.copy 側で、toFile のフォルダを作成します。
304                                        rtnVal = FileUtil.copy( file, newFile );
305                                }
306                                else if( file.isDirectory() ) {
307                                        rtnVal = FileUtil.copyDirectry( file, newFile );
308                                }
309                                // 5.7.1.1 (2013/12/13) copy元(file1)のファイルが存在しなければ、エラーにします。
310                                else if( !file.exists() ) {
311                                        String errMsg = "copy元(file1)のファイルが存在しません。"
312                                                        + HybsSystem.CR
313                                                        + "action=[" + action + "] , "
314                                                        + "  fileURL=[" + fileURL + "]"
315                                                        + "  directory=[" + directory + "]"
316                                                        + "  file1=[" + file1 + "]" 
317                                                        + "  file2=[" + file2 + "]" ;
318                                        throw new HybsSystemException( errMsg );
319                                }
320                        }
321                }
322                else {
323                        String errMsg = "アクションが指定されていません。アクション NULL エラー"
324                                                        + HybsSystem.CR
325                                                        + "  file=[" + file1 + "]" ;
326                        throw new HybsSystemException( errMsg );
327                }
328
329                return rtnVal;
330        }
331
332        /**
333         * 【TAG】アクション(canRead,canWrite,createNewFile,delete,exists,isDirectory,isFile,isHidden,mkdir,mkdirs)を指定します。
334         *
335         * @og.tag
336         * アクションは,HTMLから(get/post)指定されますので,ACT_xxx で設定される
337         * フィールド定数値のいづれかを、指定できます。
338         * 処理の結果が、false の場合は、body 要素を表示して終了します。
339         * useStop 属性と、notEquals 属性によって、上記の振る舞いをけることが可能です。
340         *
341         * canRead          読み込めるかどうかを判定。
342         * canWrite         変更できるかどうか判定。
343         * createNewFile    空の新しいファイルを不可分 (atomic) に生成。(そのファイルがまだ存在しない場合だけ)
344         * delete           ファイルまたはディレクトリを削除。
345         * renameTo         ファイルまたはディレクトリ名を変更。
346         * exists           ファイルが存在するかどうか判定。
347         * isDirectory      ファイルがディレクトリであるかどうか判定。
348         * isFile           ファイルが普通のファイルかどうか判定。
349         * isHidden         ファイルが隠しファイルかどうか判定。
350         * mkdir            ディレクトリを生成。
351         * mkdirs           ディレクトリを複数生成。
352         * read             ファイルを読み込んでjspWriterに出力
353         * existsLength     ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
354         * copy             ファイルまたはディレクトリをコピー(file1 ⇒ file2 にコピー)。
355         *
356         * @og.rev 3.0.0.0 (2002/12/25) ACTION_LIST のチェックを導入
357         * @og.rev 3.5.6.2 (2004/07/05) 文字列の連結にStringBuilderを使用します。
358         *
359         * @param       cmd アクション文字列
360         * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.FileTag.ACT_canRead">アクション定数</a>
361         */
362        public void setAction( final String cmd ) {
363                action = getRequestParameter( cmd );
364
365                if( ! check( action, ACTION_LIST ) ) {
366
367                        StringBuilder errMsg = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
368                        errMsg.append( "指定のアクションは実行できません。アクションエラー" );
369                        errMsg.append( HybsSystem.CR );
370                        errMsg.append( "action=[" ).append( action ).append( "] " );
371                        errMsg.append( HybsSystem.CR );
372
373                        for( int i=0; i<ACTION_LIST.length; i++ ) {
374                                errMsg.append( " | " );
375                                errMsg.append( ACTION_LIST[i] );
376                        }
377                        errMsg.append( " | " );
378                        throw new HybsSystemException( errMsg.toString() );
379                }
380        }
381
382        /**
383         * 【TAG】操作するファイルのディレクトリを指定します
384         *              (初期値:FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。
385         *
386         * @og.tag
387         * この属性で指定されるディレクトリのファイルを操作します。
388         * 指定方法は、通常の fileURL 属性と同様に、先頭が、'/' (UNIX) または、2文字目が、
389         * ":" (Windows)の場合は、指定のURLそのままのディレクトリに、そうでない場合は、
390         * (初期値:システム定数のFILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。
391         *
392         * @og.rev 4.0.0.0 (2005/01/31) urlAppend メソッドの利用
393         * @og.rev 4.0.0.0 (2007/11/20) 指定されたディレクトリ名の最後が"\"or"/"で終わっていない場合に、"/"を付加する。
394         *
395         * @param       url ファイルURL
396         * @see         org.opengion.hayabusa.common.SystemData#FILE_URL
397         */
398        public void setFileURL( final String url ) {
399                String furl = nval( getRequestParameter( url ),null );
400                if( furl != null ) {
401                        char ch = furl.charAt( furl.length()-1 );
402                        if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
403                        fileURL = StringUtil.urlAppend( fileURL,furl );
404                }
405        }
406
407        /**
408         * 【TAG】基準となるファイル名を指定します(コマンドの左辺のファイル名です)。
409         *
410         * @og.tag
411         * コマンドの左辺のファイル名です。
412         *
413         * @param       fname ファイル名1
414         */
415        public void setFile1( final String fname ) {
416                file1 = nval( getRequestParameter( fname ),file1 );
417        }
418
419        /**
420         * 【TAG】処理結果となるファイル名を指定します(コマンドの右辺のファイル名です)。
421         *
422         * @og.tag
423         * コマンドの右辺のファイル名です。
424         *
425         * @param       fname ファイル名2
426         */
427        public void setFile2( final String fname ) {
428                file2 = nval( getRequestParameter( fname ),file2 );
429        }
430
431        /**
432         * 【TAG】判定結果を反転させるかどうか[true/false]を指定します(初期値:false)。
433         *
434         * @og.tag
435         * 通常の判定結果において、不成立(false)の場合に、BODY を実行します。
436         * 通常の処理結果の正反対の処理を行います。
437         * 初期値は、通常 (true 以外)です。
438         *
439         * @og.rev 3.8.5.2 (2006/05/31) 新規追加
440         *
441         * @param   flag  [true:反転する/それ以外:通常]
442         */
443        public void setNotEquals( final String flag ) {
444                notEquals = nval( getRequestParameter( flag ),notEquals );
445        }
446
447        /**
448         * 【TAG】エラー時BODYを処理後に停止するかどうか[true/false]を指定します(初期値:true)。
449         *
450         * @og.tag
451         * 処理結果などに応じて、以下の処理を停止したい場合に、使用します。
452         * 通常は、条件を判定後、false の場合に、BODY部を出力(処理)した後に、
453         * 処理を停止します。(useStop="true")
454         * false を指定すると、判定結果に無関係に、以下の処理を実行します。
455         * 処理は継続したいが、警告表示する場合に、useStop="false" を指定します。
456         * 初期値は、停止する ("true")です。
457         *
458         * @og.rev 3.8.5.2 (2006/05/31) 新規追加
459         *
460         * @param   flag  [true:判定する/それ以外:しない]
461         */
462        public void setUseStop( final String flag ) {
463                useStop = nval( getRequestParameter( flag ),useStop );
464        }
465
466        /**
467         * 【TAG】ファイルを読み込む(action="READ")際のエンコードを指定します(初期値:OS依存文字コード)。
468         *
469         * @og.tag
470         * ファイルを読み込む(action="READ")際のエンコードを指定します。
471         * action="READ"以外場合には、この属性値は利用されません。
472         * 指定しない場合は、OS依存文字コードで読み込まれます。
473         *
474         * @og.rev 5.1.9.0 (2010/08/01) 新規作成
475         *
476         * @param   enc ファイル読み込みのエンコード
477         */
478        public void setEncode( final String enc ) {
479                encode = nval( getRequestParameter( enc ),encode );
480        }
481
482        /**
483         * このオブジェクトの文字列表現を返します。
484         * 基本的にデバッグ目的に使用します。
485         *
486         * @return このクラスの文字列表現
487         */
488        @Override
489        public String toString() {
490                return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
491                                .println( "VERSION"             ,VERSION        )
492                                .println( "fileURL"             ,fileURL        )
493                                .println( "file1"               ,file1          )
494                                .println( "file2"               ,file2          )
495                                .println( "action"              ,action         )
496                                .println( "rtnCode"             ,rtnCode        )
497                                .println( "notEquals"   ,notEquals      )
498                                .println( "useStop"             ,useStop        )
499                                .println( "Other..."    ,getAttributes().getAttribute() )
500                                .fixForm().toString() ;
501        }
502}