View Javadoc
1   package org.apache.maven.shared.utils.io;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  /**
25   * <p>Visitor pattern for the DirectoryScanner. A ScanConductor controls the scanning process.</p>
26   * <p/>
27   * <p>Create an instance and pass it to
28   * {@link org.apache.maven.shared.utils.io.DirectoryScanner#setScanConductor(ScanConductor)}.
29   * You will get notified about every visited directory and file. You can use the {@link ScanAction}
30   * to control what should happen next.</p>
31   * <p/>
32   * <p>A ScanConductor might also store own information but users must make sure that the state gets
33   * cleaned between two scan() invocations.</p>
34   *
35   * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
36   * 
37   * @deprecated use {@code java.nio.file.Files.walkFileTree()} and related classes
38   */
39  @Deprecated
40  public interface ScanConductor
41  {
42      /**
43       * 
44       */
45      enum ScanAction
46      {
47          /**
48           * Abort the whole scanning process. The current file will not
49           * be added anymore.
50           */
51          ABORT,
52  
53          /**
54           * Continue the scanning with the next item in the list.
55           */
56          CONTINUE,
57  
58          /**
59           * This response is only valid for {@link ScanConductor#visitDirectory(String, java.io.File)}.
60           * Do not recurse into the current directory. The current directory will not be added
61           * and the processing will be continued with the next item in the list.
62           */
63          NO_RECURSE,
64  
65          /**
66           * Abort processing the current directory.
67           * The current file will not be added.
68           * The processing will continue it's scan in the parent directory if any.
69           */
70          ABORT_DIRECTORY
71      }
72  
73      /**
74       * This method will get invoked for every detected directory.
75       *
76       * @param name      the directory name (contains parent folders up to the pwd)
77       * @param directory The directory.
78       * @return the ScanAction to control how to proceed with the scanning
79       */
80      ScanAction visitDirectory( String name, File directory );
81  
82      /**
83       * This method will get invoked for every detected file.
84       *
85       * @param name the file name (contains parent folders up to the pwd)
86       * @param file The file.
87       * @return the ScanAction to control how to proceed with the scanning
88       */
89      ScanAction visitFile( String name, File file );
90  }