001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.fukurou.process;
017    
018    import org.opengion.fukurou.util.Argument;
019    import org.opengion.fukurou.util.HybsFileFilter;
020    import org.opengion.fukurou.util.LogWriter;
021    
022    import java.io.File;
023    import java.util.Map ;
024    import java.util.LinkedHashMap ;
025    import java.util.Stack;
026    
027    /**
028     * Process_FileSearch は、指定ã?フォルãƒ?»¥下ã?ファイルをä¸?¦§する、FirstProcess
029     * インターフェースと、ChainProcess インターフェースの実è£?‚¯ラスですã?
030     *
031     * æŒ?®šã?条件に合è?するファイルを検索しã?LineModel のサブクラスであるã€?
032     * FileLineModel オブジェクトを作æ?して、下流に渡しますã?
033     * FileLineModel オブジェクトには、ファイル属æ?(Level,File,Length,Modify)
034     * が設定されますã?
035     *
036     * 引数æ–?­—å?中にスペã?スを含ã‚??合ã?、ダブルコーãƒ??ション("") で括って下さã�??
037     * 引数æ–?­—å?の ã€?』ã?前後には、スペã?スは挟めません。å¿?�šã€?key=value の様に
038     * 繋げてくださいã€?
039     *
040     * @og.formSample
041     *  Process_FileSearch -start=d:/ -suffix=jsp
042     *
043     *     -start=開始フォルãƒ?      ?š検索を開始するフォルãƒ?
044     *   [ -prefix=接頭è¾?        ]  ?šFile?¥?¥?¥?¥,View?¥?¥?¥?¥,など、指定ã?接頭辞で始まるファイルを検索
045     *   [ -unprefix=不接頭è¾?    ]  ?šFile?¥?¥?¥?¥,View?¥?¥?¥?¥,など、指定ã?接頭辞で始まらなã�?ƒ•ァイルを検索
046     *   [ -suffix=接尾è¾?        ]  ??txt,.java,.jsp.... など、指定ã?接尾辞で終わるファイルを検索
047     *   [ -unsuffix=不接尾è¾?    ]  ??txt,.java,.jsp.... など、指定ã?接尾辞で終わらなã�?ƒ•ァイルを検索
048     *   [ -instr=部åˆ?–‡字å?      ]  ?šファイル名とä¸??する部åˆ?–‡字å?を指å®?
049     *   [ -uninstr=不部åˆ?–‡字å?  ]  ?šファイル名とä¸??しな部åˆ?–‡字å?を指å®?
050     *   [ -equals=ä¸??           ]  ?šファイル名とä¸??するæ–?­—å?(大æ–?­—小文字ã?区別しなã�?を指å®?
051     *   [ -notequals=不ä¸??      ]  ?šファイル名とä¸??しなã�?–‡字å?(大æ–?­—小文字ã?区別しなã�?を指å®?
052     *   [ -match=正規表現        ]  ?šファイル名とä¸??する正規表現を指å®?
053     *   [ -unmatch=正規表現      ]  ?šファイル名とä¸??しなã�?­£規表現を指å®?
054     *   [ -modify=YYYYMMDD       ]  ?š指定日付け以降に変更されたファイルを検索
055     *             YYYYMMDD   : YYYYMMDD 形式でのæŒ?®š日の 00:00:00 を基準時刻
056     *             TODAY      : 実行日の 00:00:00 を基準時刻
057     *             YESTERDAY  : 実行日前日の 00:00:00 を基準時刻
058     *             LAST_WEEK  : 実行日の先é?(7日å‰? 00:00:00 を基準時刻
059     *             MONTH      : 実行月の 1日 00:00:00 を基準時刻
060     *             LAST_MONTH : 実行前月ã? 同日 00:00:00 を基準時刻
061     *             LAST_YEAR  : 実行前年の 同月同日 00:00:00 を基準時刻
062     *   [ -useDIR=[false/true]   ]  ?š判定をファイルã�?�‘でなくã?ãƒ?‚£レクトリでも行うかどã�?�‹を指å®?初期値:false)
063     *   [ -larger=サイズ(KByte)  ]  ?šファイルの大きさが指定ã??«バイト数より大きいファイルを検索
064     *   [ -smaller=サイズ(KByte) ]  ?šファイルの大きさが指定ã??«バイト数より小さã�?ƒ•ァイルを検索
065     *   [ -maxLevel=æœ?¤§階層数   ]  ?šディレクトリの階層を下がる最大数(初期値:256)
066     *   [ -useLineCnt=行数計ç®?  ]  ?šファイルの行数をカウントするかどã�?�‹を指å®?初期値:false)
067     *   [ -inPath=入力å?通パス   ]  ?šBIKO作æ?用のファイルパスから削除する部åˆ?æ–?­—数のみ)
068     *   [ -outPath=出力追åŠ?ƒ‘ス  ]  ?šBIKO作æ?用のファイルパスに追åŠ?�™る部åˆ?
069     *   [ -display=[false/true]  ]  ?štrueは、検索状況を表示しまã�?初期値:false)
070     *
071     * @version  4.0
072     * @author   Kazuhiko Hasegawa
073     * @since    JDK5.0,
074     */
075    public class Process_FileSearch extends AbstractProcess
076                                                                    implements FirstProcess , ChainProcess {
077    
078            private Stack<FileListStack>      dirs            = null;
079            private File                    file            = null;
080            private HybsFileFilter  filter          = null;
081            private FileLineModel   newData         = null;
082            private int                             level           = 1;
083    
084            private String                  startDir        = null;
085            private int                             maxLevel        = 256;
086            private boolean                 display         = false;        // 表示しなã�?
087            private int                             inCount         = 0;
088            private int                             outCount        = 0;
089            private int                             inPathLen       = 0;            // 4.2.3.0 (2008/05/26) BIKOæ¬?”¨
090            private String                  outPath         = null;         // 4.3.1.1 (2008/08/23) BIKOæ¬?”¨
091    
092            private static final Map<String,String> mustProparty   ;          // ?»プロパティ?½å¿??チェãƒ?‚¯用 Map
093            private static final Map<String,String> usableProparty ;          // ?»プロパティ?½整合æ?チェãƒ?‚¯ Map
094    
095            static {
096                    mustProparty = new LinkedHashMap<String,String>();
097                    mustProparty.put( "start",      "検索を開始するフォルãƒ?å¿??)" );
098    
099                    usableProparty = new LinkedHashMap<String,String>();
100                    usableProparty.put( "prefix",   "File?¥?¥?¥?¥,View?¥?¥?¥?¥,など、指定ã?接頭辞で始まるファイルを検索" );
101                    usableProparty.put( "unprefix", "File?¥?¥?¥?¥,View?¥?¥?¥?¥,など、指定ã?接頭辞で始まらなã�?ƒ•ァイルを検索" );
102                    usableProparty.put( "suffix",   ".txt,.java,.jsp.... など、指定ã?接尾辞で終わるファイルを検索" );
103                    usableProparty.put( "unsuffix", ".txt,.java,.jsp.... など、指定ã?接尾辞で終わらなã�?ƒ•ァイルを検索" );
104                    usableProparty.put( "instr",    "ファイル名とä¸??する部åˆ?–‡字å?を指å®? );
105                    usableProparty.put( "uninstr",  "ファイル名とä¸??しなã�?ƒ¨åˆ?–‡字å?を指å®? );
106                    usableProparty.put( "equals",   "ファイル名とä¸??するæ–?­—å?(大æ–?­—小文字ã?区別しなã�?を指å®? );
107                    usableProparty.put( "notequals",        "ファイル名とä¸??しなã�?–‡字å?(大æ–?­—小文字ã?区別しなã�?を指å®? );
108                    usableProparty.put( "match",    "ファイル名とä¸??する正規表現を指å®? );
109                    usableProparty.put( "unmatch",  "ファイル名とä¸??しなã�?­£規表現を指å®? );
110                    usableProparty.put( "modify",   "æŒ?®š日付け以降に変更されたファイルを検索" +
111                                            CR + "YYYYMMDD   : YYYYMMDD 形式でのæŒ?®š日の 00:00:00 を基準時刻" +
112                                            CR + "TODAY      : 実行日の 00:00:00 を基準時刻" +
113                                            CR + "YESTERDAY  : 実行日前日の 00:00:00 を基準時刻" +
114                                            CR + "LAST_WEEK  : 実行日の先é?(7日å‰? 00:00:00 を基準時刻" +
115                                            CR + "MONTH      : 実行月の 1日 00:00:00 を基準時刻" +
116                                            CR + "LAST_MONTH : 実行前月ã? 同日 00:00:00 を基準時刻" +
117                                            CR + "LAST_YEAR  : 実行前年の 同月同日 00:00:00 を基準時刻"
118                    );
119                    usableProparty.put( "useDIR"    ,"判定をファイルã�?�‘でなくã?ãƒ?‚£レクトリでも行うかどã�?�‹を指å®?初期値:false)" );
120                    usableProparty.put( "larger"    ,"ファイルの大きさが指定ã??«バイト数より大きいファイルを検索" );
121                    usableProparty.put( "smaller"   ,"ファイルの大きさが指定ã??«バイト数より小さã�?ƒ•ァイルを検索" );
122                    usableProparty.put( "maxLevel"  ,"ãƒ?‚£レクトリの階層を下がる最大数(初期値:256)" );
123                    usableProparty.put( "useLineCnt","ファイルの行数をカウントするかどã�?�‹を指å®?初期値:false)" );
124                    usableProparty.put( "inPath"    ,"BIKO作æ?用のファイルパスから削除する部åˆ?æ–?­—数のみ)" );
125                    usableProparty.put( "outPath"   ,"BIKO作æ?用のファイルパスに追åŠ?�™る部åˆ? );
126                    usableProparty.put( "display"   ,"trueは、検索状況を表示しまã�?初期値:false)" );
127            }
128    
129            /**
130             * ãƒ?ƒ•ォルトコンストラクターã€?
131             * こã?クラスは、動çš?½œæ?されますã?ãƒ?ƒ•ォルトコンストラクターでã€?
132             * super クラスに対して、å¿?¦�な初期化を行っておきますã?
133             *
134             */
135            public Process_FileSearch() {
136                    super( "org.opengion.fukurou.process.Process_FileSearch",mustProparty,usableProparty );
137            }
138    
139            /**
140             * プロセスの初期化を行いますã?初めにä¸?º¦ã�?�‘、呼び出されますã?
141             * 初期処ç�?ファイルオープンã€?¼¤?¢オープンç­?に使用しますã?
142             *
143             * @og.rev 4.2.2.0 (2008/05/10) 行数カウントã?使用有無
144             * @og.rev 4.3.1.1 (2008/08/23) BIKO æ¬?�«outPath 属æ?を追åŠ?�—ますã?
145             * @og.rev 5.1.2.0 (2010/01/01) useDIR 属æ?を追åŠ?�—ますã?
146             *
147             * @param   paramProcess ãƒ??タベã?スの接続å?æƒ??などを持ってã�?‚‹オブジェクãƒ?
148             */
149            public void init( final ParamProcess paramProcess ) {
150                    Argument arg = getArgument();
151    
152                    startDir                = arg.getProparty("start" );
153    
154                    String inPath   = arg.getProparty("inPath");
155                    if( inPath != null ) { inPathLen = inPath.length(); }
156    
157                    String prefix   = arg.getProparty("prefix");
158                    String unprefix = arg.getProparty("unprefix");          // 5.1.2.0 (2010/01/01) 追åŠ?
159                    String suffix   = arg.getProparty("suffix");
160                    String unsuffix = arg.getProparty("unsuffix");          // 5.1.2.0 (2010/01/01) 追åŠ?
161                    String instr    = arg.getProparty("instr");
162                    String uninstr  = arg.getProparty("uninstr");           // 5.1.2.0 (2010/01/01) 追åŠ?
163                    String equals   = arg.getProparty("equals");
164                    String notequals= arg.getProparty("notequals");         // 5.1.2.0 (2010/01/01) 追åŠ?
165                    String match    = arg.getProparty("match");
166                    String unmatch  = arg.getProparty("unmatch");
167                    String modify   = arg.getProparty("modify");
168                    String larger   = arg.getProparty("larger");
169                    String smaller  = arg.getProparty("smaller");
170                    maxLevel                = arg.getProparty("maxLevel",maxLevel);
171                    outPath                 = arg.getProparty("outPath");
172                    // 4.2.2.0 (2008/05/10) 行数カウントã?使用有無
173                    boolean useLineCnt = arg.getProparty( "useLineCnt",false );
174    
175                    // 5.1.2.0 (2010/01/01) 判定をãƒ?‚£レクトリでも行うかどã�?�‹
176                    boolean useDIR = arg.getProparty( "useDIR",false );
177    
178                    display = arg.getProparty("display",display);
179                    if( display ) { println( startDir ); }          // 4.0.0 (2005/01/31)
180    
181                    // 5.1.2.0 (2010/01/01) 反転処ç�??引数追åŠ?
182                    filter = new HybsFileFilter( useDIR );  // 5.1.2.0 (2010/01/01) 判定をãƒ?‚£レクトリでも行うかどã�?�‹
183                    filter.startsWith( prefix   , false);
184                    filter.startsWith( unprefix , true );
185                    filter.endsWith( suffix   , false);
186                    filter.endsWith( unsuffix , true );
187                    filter.instr( instr   , false);
188                    filter.instr( uninstr , true );
189                    filter.fileEquals( equals   , false);
190                    filter.fileEquals( notequals , true );
191                    filter.matches( match   , false);
192                    filter.matches( unmatch , true );
193    //              filter.unMatches( unmatch );                    // 5.1.2.0 (2010/01/01) 反転処ç�??、matches の 反転引数で対å¿?
194                    filter.lastModified( modify );
195                    if( larger  != null ) { filter.isLarger( Integer.parseInt( larger ) ); }
196                    if( smaller != null ) { filter.isSmaller( Integer.parseInt( smaller ) ); }
197    
198                    File tempFile = new File( startDir );
199                    if( tempFile.isDirectory() ) {
200                            dirs = new Stack<FileListStack>();
201                            File[] fileList = tempFile.listFiles( filter );
202                            dirs.push( new FileListStack( fileList, level ) );
203                    }
204                    else {
205                            dirs = new Stack<FileListStack>();
206                            File[] fileList = new File[] { tempFile };
207                            dirs.push( new FileListStack( fileList, level ) );
208                    }
209    
210    //              newData = new FileLineModel();
211                    newData = new FileLineModel( useLineCnt );      // 4.2.2.0 (2008/05/10)
212            }
213    
214            /**
215             * こã?ãƒ??タの処ç�?�«おいて、次の処ç�?�Œ出来るかどã�?�‹を問ã�?�ˆわせますã?
216             * こã?呼び出し1回毎に、次のãƒ??タを取得する準備を行いますã?
217             *
218             * @og.rev 5.3.8.0 (2011/08/01) 処ç�?¸­の状態を表示するための println を追åŠ?
219             *
220             * @return      処ç�?�§きる:true / 処ç�?�§きなã�?false
221             */
222            public boolean next() {
223                    while( !dirs.empty() ) {
224                            FileListStack fStack = dirs.pop();
225    
226                            level = fStack.getLevel();
227                            if( level > maxLevel ) { continue; }
228    
229                            File[] fileList = fStack.getFileList();
230                            if( fileList == null ) { continue; }
231    
232                            int address = fStack.getAddress();
233                            for( ; address < fileList.length; address++ ) {
234                                    inCount++ ;
235                                    if( fileList[address].isDirectory() ) {
236                                            if( display ) { println( fileList[address].getAbsolutePath() ); }               // 5.3.8.0 (2011/08/01)
237                                            File[] newList = fileList[address].listFiles( filter );
238                                            dirs.push( new FileListStack( newList,level+1) );
239                                    }
240                                    else {
241                                            file = fileList[address];
242                                            fStack.setAddress( address+1 );
243                                            dirs.push( fStack );
244                                            return true;
245                                    }
246                            }
247                    }
248                    return false;
249            }
250    
251            /**
252             * æœ??にã€?行データである LineModel を作æ?しまã�?
253             * FirstProcess は、次ã€?�¨処ç�?‚’チェインしてã�?��æœ??の行データã‚?
254             * 作æ?して、後続ã? ChainProcess クラスに処ç�?ƒ‡ータを渡しますã?
255             *
256             * @og.rev 4.2.3.0 (2008/05/26) BIKO æ¬?�«展開ファイル名を記述しますã?
257             * @og.rev 4.3.1.1 (2008/08/23) BIKO æ¬?�«outPath 属æ?を追åŠ?�—ますã?
258             *
259             * @param       rowNo   処ç�?¸­の行番号
260             *
261             * @return      処ç�?¤‰換後ã?LineModel
262             */
263            public LineModel makeLineModel( final int rowNo ) {
264                    outCount++ ;
265                    newData.setFileVals( level,file );
266    
267                    // 4.3.1.1 (2008/08/23)
268                    String biko = null;
269                    // 4.2.3.0 (2008/05/26) BIKO æ¬?¿½åŠ?
270                    if( inPathLen > 0 ) {
271                            biko = file.getAbsolutePath().substring( inPathLen );
272    //                      newData.setBiko( biko );
273                    }
274    
275                    if( outPath != null ) {
276                            if( biko == null ) {
277                                    biko = outPath + file.getName() ;
278                            }
279                            else {
280                                    biko = outPath + biko ;
281                            }
282                    }
283                    if( biko != null ) {
284                            newData.setBiko( biko );
285                    }
286    
287                    newData.setRowNo( rowNo );
288    
289    //              if( display ) { println( newData.dataLine() ); }                // 5.1.2.0 (2010/01/01) display の条件変更
290    
291                    return newData;
292            }
293    
294            /**
295             * 引数の LineModel をå?ç�?�™るメソãƒ?ƒ‰ですã?
296             * 変換処ç�?¾Œã? LineModel を返しますã?
297             * 後続å?ç�?‚’行わなã�??å�?ãƒ??タのフィルタリングを行う場å�?はã€?
298             * null ãƒ??タを返しますã?つまりã?null ãƒ??タは、後続å?ç�?‚’行わなã�?
299             * フラグの代わりにも使用してã�?�¾すã?
300             * なおã?変換処ç�?¾Œã? LineModel と、オリジナルの LineModel がã?
301             * 同ä¸?�‹、コピã?(クローン)かã?、各処ç�?ƒ¡ソãƒ?ƒ‰å†?�§決めてã�?�¾すã?
302             * ドキュメントに明記されてã�?�ªã�??合ã?、副作用が問題になるå?合ã?ã€?
303             * å�??ç�?�”とに自åˆ?�§コピã?(クローン)して下さã�??
304             *
305             * @param       data    オリジナルのLineModel
306             *
307             * @return      処ç�?¤‰換後ã?LineModel
308             */
309            public LineModel action( final LineModel data ) {
310                    LineModel rtn = null;
311    
312                    final FileLineModel fileData ;
313                    if( data instanceof FileLineModel ) {
314                            fileData = (FileLineModel)data ;
315                    }
316                    else {
317                            String errMsg = "ãƒ??タã�?FileLineModel オブジェクトではありませんã€? + CR ;
318                            throw new RuntimeException( errMsg );
319                    }
320    
321                    File inFile = fileData.getFile() ;
322                    File[] fileList = inFile.listFiles( filter );
323    
324                    if( fileList != null && fileList.length > 0 ) {
325                            rtn = data;
326                    }
327    
328                    if( display && rtn != null ) { println( rtn.dataLine() ); }             // 5.1.2.0 (2010/01/01) display の条件変更
329                    return rtn ;
330            }
331    
332            /**
333             * プロセスの終äº?‚’行いますã?æœ?¾Œにä¸?º¦ã�?�‘、呼び出されますã?
334             * 終äº??ç�?ファイルクローズã€?¼¤?¢クローズç­?に使用しますã?
335             *
336             * @param   isOK トã?タルで、OKã�?�£たかどã�?�‹[true:成功/false:失敗]
337             */
338            public void end( final boolean isOK ) {
339                    dirs            = null;
340                    file            = null;
341                    filter          = null;
342                    newData         = null;
343            }
344    
345            /**
346             * プロセスの処ç�?µ�果のレポã?ト表現を返しますã?
347             * 処ç�??ログラãƒ?��、å?力件数、å?力件数などのæƒ??ですã?
348             * こã?æ–?­—å?をそのまま、標準å?力に出すことで、結果レポã?トと出来るよã�?�ª
349             * 形式で出してくださいã€?
350             *
351             * @return   処ç�?µ�果のレポã?ãƒ?
352             */
353            public String report() {
354                    String report = "[" + getClass().getName() + "]" + CR
355                                    + TAB + "Start Folder : " + startDir  + CR
356                                    + TAB + "Search Count : " + inCount   + CR
357                                    + TAB + "Output Count : " + outCount ;
358    
359                    return report ;
360            }
361    
362            /**
363             * こã?クラスの使用方法を返しますã?
364             *
365             * @return      こã?クラスの使用方æ³?
366             */
367            public String usage() {
368                    StringBuilder buf = new StringBuilder();
369    
370                    buf.append( "Process_FileSearch は、指定ã?フォルãƒ?»¥下ã?ファイルをä¸?¦§する、FirstProcess"      ).append( CR );
371                    buf.append( "インターフェースと、ChainProcess インターフェースの実è£?‚¯ラスですã?"                    ).append( CR );
372                    buf.append( CR );
373                    buf.append( "æŒ?®šã?条件に合è?するファイルを検索しã?ファイル属æ?(Level,File,Length,Modify)"     ).append( CR );
374                    buf.append( "をå?に、LineModelを作æ?しã?下流に渡しますã?"                                                                      ).append( CR );
375                    buf.append( CR );
376                    buf.append( "引数æ–?­—å?中に空白を含ã‚??合ã?、ダブルコーãƒ??ション(\"\") で括って下さã�??" ).append( CR );
377                    buf.append( "引数æ–?­—å?の ã€?』ã?前後には、空白は挟めません。å¿?�šã€?key=value の様に"             ).append( CR );
378                    buf.append( "繋げてくださいã€?                                                                                                                              ).append( CR );
379                    buf.append( CR );
380                    buf.append( "  -start=開始フォルãƒ?      ?š検索を開始するフォルãƒ?                                                        ").append( CR );
381                    buf.append( "[ -prefix=接頭è¾?        ]"                                                                                                 ).append( CR );
382                    buf.append( "[ -unprefix=不接頭è¾?    ]"                                                                                                  ).append( CR );
383                    buf.append( "[ -suffix=接尾è¾?        ]"                                                                                                 ).append( CR );
384                    buf.append( "[ -unsuffix=不接尾è¾?    ]"                                                                                                  ).append( CR );
385                    buf.append( "[ -instr=部åˆ?–‡字å?      ]"                                                                                                  ).append( CR );
386                    buf.append( "[ -uninstr=不部åˆ?–‡字å?  ]"                                                                                                   ).append( CR );
387                    buf.append( "[ -equals=�?           ]"                                                                                                 ).append( CR );
388                    buf.append( "[ -notequals=不ä¸??      ]"                                                                                                 ).append( CR );
389                    buf.append( "[ -match=正規表現        ]"                                                                                                        ).append( CR );
390                    buf.append( "[ -unmatch=正規表現      ]"                                                                                                        ).append( CR );
391                    buf.append( "[ -modify=YYYYMMDD       ]  ?š指定日付け以降に変更されたファイルを検索"           ).append( CR );
392                    buf.append( "          YYYYMMDD   : YYYYMMDD 形式でのæŒ?®š日の 00:00:00 を基準時刻"                  ).append( CR );
393                    buf.append( "          TODAY      : 実行日の 00:00:00 を基準時刻                 "                 ).append( CR );
394                    buf.append( "          YESTERDAY  : 実行日前日の 00:00:00 を基準時刻             "                  ).append( CR );
395                    buf.append( "          LAST_WEEK  : 実行日の先é?(7日å‰? 00:00:00 を基準時刻      "                   ).append( CR );
396                    buf.append( "          MONTH      : 実行月の 1日 00:00:00 を基準時刻             "                 ).append( CR );
397                    buf.append( "          LAST_MONTH : 実行前月ã? 同日 00:00:00 を基準時刻          "                   ).append( CR );
398                    buf.append( "          LAST_YEAR  : 実行前年の 同月同日 00:00:00 を基準時刻      "                   ).append( CR );
399                    buf.append( "[ -useDIR=[false/true]   ]  ??                                                                                             ).append( CR );
400                    buf.append( "[ -larger=サイズ(KByte)  ]  ??                                                                                             ).append( CR );
401                    buf.append( "[ -smaller=サイズ(KByte) ]  ??                                                                                             ).append( CR );
402                    buf.append( "[ -maxLevel=æœ?¤§階層数   ]  ??                                                                                             ).append( CR );
403                    buf.append( "[ -useLineCnt=行数計ç®?  ]  ??                                                                                               ).append( CR );
404                    buf.append( "[ -inPath=入力å?通パス   ]  ??                                                                                               ).append( CR );
405                    buf.append( "[ -outPath=出力追åŠ?ƒ‘ス  ]  ??                                                                                              ).append( CR );
406                    buf.append( "[ -display=[false/true]  ]  ??                                                                                             ).append( CR );
407                    buf.append( CR ).append( CR );
408                    buf.append( getArgument().usage() ).append( CR );
409    
410                    return buf.toString();
411            }
412    
413            /**
414             * こã?クラスは、main メソãƒ?ƒ‰から実行できませんã€?
415             *
416             * @param       args    コマンド引数配å?
417             */
418            public static void main( final String[] args ) {
419                    LogWriter.log( new Process_FileSearch().usage() );
420            }
421    
422            /**
423             * こã?クラスはファイルをスタãƒ?‚¯を使用して展開する場合ã?
424             * 個ã?の状態を保持する為のクラスですã?
425             *
426             * @version  4.0
427             * @author   Kazuhiko Hasegawa
428             * @since    JDK5.0,
429             */
430            private static final class FileListStack {
431                    private int address ;
432                    private final File[] files;
433                    private final int level;
434    
435                    /**
436                     * コンストラクター
437                     * 初期値を設定しますã?
438                     * ファイルの配å?につã�?�¦は、コピã?せずそã?ままå†?ƒ¨配å?にセãƒ?ƒˆしてã�?�¾すã?
439                     *
440                     * @param files File[] ファイルの配å?(ファイルリスãƒ?
441                     * @param       level   レベル(æŒ?®šã?startフォルãƒ?�‹らã?階層数)
442                     */
443                    FileListStack( final File[] files,final int level ) {
444                            this.files   = files;
445                            this.address = 0;
446                            this.level   = level;
447                    }
448    
449                    /**
450                     * ファイルリストã?アドレスを設定しますã?
451                     * スタãƒ?‚¯から取り出した後ã?配å?を前回ã?続きからサーチするå?合に使用しますã?
452                     *
453                     * @param       address ファイルリストã?アドレス
454                     */
455                    void setAddress( final int address ) {
456                            this.address = address;
457                    }
458    
459                    /**
460                     * ファイルリストã?アドレスを取りå?しますã?
461                     *
462                     * @return      ファイルリストã?アドレス
463                     */
464                    int getAddress() {
465                            return address;
466                    }
467    
468                    /**
469                     * ファイルリストを取り出しますã?
470                     * ファイルの配å?につã�?�¦は、コピã?せずそã?ままå†?ƒ¨配å?を返してã�?�¾すã?
471                     *
472                     * @return File[] ファイルリスãƒ?
473                     */
474                    File[] getFileList() {
475                            return files;
476                    }
477    
478                    /**
479                     * 階層レベルを取りå?しますã?
480                     *
481                     * @return      レベル
482                     */
483                    int getLevel() {
484                            return level;
485                    }
486            }
487    }