1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.vfs2;
18
19 /**
20 * Selects what to traverse a file hierarchy.
21 *
22 * @see Selectors
23 */
24 public interface FileSelector {
25
26 /**
27 * Tests if a file or folder should be selected. This method is called in depthwise order (that is, it is
28 * called for the children of a folder before it is called for the folder itself).
29 *
30 * @param fileInfo the file or folder to select.
31 * @return true if the file should be selected.
32 * @throws Exception if an error occurs.
33 */
34 boolean includeFile(FileSelectInfo fileInfo) throws Exception;
35
36 /**
37 * Tests whether a folder should be traversed. If this method returns true, {@link #includeFile} is called for
38 * each of the children of the folder, and each of the child folders is recursively traversed.
39 * <p>
40 * This method is called on a folder before {@link #includeFile} is called.
41 * </p>
42 *
43 * @param fileInfo the file or folder to select.
44 * @return true if the folder should be traversed.
45 * @throws Exception if an error occurs.
46 * @since 2.10.0
47 */
48 default boolean traverseDescendants(final FileSelectInfo fileInfo) throws Exception {
49 return traverseDescendents(fileInfo);
50 }
51
52 /**
53 * Tests whether a folder should be traversed. If this method returns true, {@link #includeFile} is called for
54 * each of the children of the folder, and each of the child folders is recursively traversed.
55 * <p>
56 * This method is called on a folder before {@link #includeFile} is called.
57 * </p>
58 *
59 * @param fileInfo the file or folder to select.
60 * @return true if the folder should be traversed.
61 * @throws Exception if an error occurs.
62 * @deprecated Use {@link #traverseDescendants(FileSelectInfo)}.
63 */
64 @Deprecated
65 boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception;
66 }