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>Create an instance and pass it to
27 * {@link org.apache.maven.shared.utils.io.DirectoryScanner#setScanConductor(ScanConductor)}.
28 * You will get notified about every visited directory and file. You can use the {@link ScanAction}
29 * to control what should happen next.</p>
30 * <p>A ScanConductor might also store own information but users must make sure that the state gets
31 * cleaned between two scan() invocations.</p>
32 *
33 * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
34 *
35 * @deprecated use {@code java.nio.file.Files.walkFileTree()} and related classes
36 */
37 @Deprecated
38 public interface ScanConductor
39 {
40 /**
41 *
42 */
43 enum ScanAction
44 {
45 /**
46 * Abort the whole scanning process. The current file will not
47 * be added anymore.
48 */
49 ABORT,
50
51 /**
52 * Continue the scanning with the next item in the list.
53 */
54 CONTINUE,
55
56 /**
57 * This response is only valid for {@link ScanConductor#visitDirectory(String, java.io.File)}.
58 * Do not recurse into the current directory. The current directory will not be added
59 * and the processing will be continued with the next item in the list.
60 */
61 NO_RECURSE,
62
63 /**
64 * Abort processing the current directory.
65 * The current file will not be added.
66 * The processing will continue it's scan in the parent directory if any.
67 */
68 ABORT_DIRECTORY
69 }
70
71 /**
72 * This method will get invoked for every detected directory.
73 *
74 * @param name the directory name (contains parent folders up to the pwd)
75 * @param directory The directory.
76 * @return the ScanAction to control how to proceed with the scanning
77 */
78 ScanAction visitDirectory( String name, File directory );
79
80 /**
81 * This method will get invoked for every detected file.
82 *
83 * @param name the file name (contains parent folders up to the pwd)
84 * @param file The file.
85 * @return the ScanAction to control how to proceed with the scanning
86 */
87 ScanAction visitFile( String name, File file );
88 }