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