001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2; 018 019/** 020 * Selects what to traverse a file hierarchy. 021 * 022 * @see Selectors 023 */ 024public interface FileSelector { 025 026 /** 027 * Tests if a file or folder should be selected. This method is called in depthwise order (that is, it is 028 * called for the children of a folder before it is called for the folder itself). 029 * 030 * @param fileInfo the file or folder to select. 031 * @return true if the file should be selected. 032 * @throws Exception if an error occurs. 033 */ 034 boolean includeFile(FileSelectInfo fileInfo) throws Exception; 035 036 /** 037 * Tests whether a folder should be traversed. If this method returns true, {@link #includeFile} is called for 038 * each of the children of the folder, and each of the child folders is recursively traversed. 039 * <p> 040 * This method is called on a folder before {@link #includeFile} is called. 041 * </p> 042 * 043 * @param fileInfo the file or folder to select. 044 * @return true if the folder should be traversed. 045 * @throws Exception if an error occurs. 046 * @since 2.10.0 047 */ 048 default boolean traverseDescendants(final FileSelectInfo fileInfo) throws Exception { 049 return traverseDescendents(fileInfo); 050 } 051 052 /** 053 * Tests whether a folder should be traversed. If this method returns true, {@link #includeFile} is called for 054 * each of the children of the folder, and each of the child folders is recursively traversed. 055 * <p> 056 * This method is called on a folder before {@link #includeFile} is called. 057 * </p> 058 * 059 * @param fileInfo the file or folder to select. 060 * @return true if the folder should be traversed. 061 * @throws Exception if an error occurs. 062 * @deprecated Use {@link #traverseDescendants(FileSelectInfo)}. 063 */ 064 @Deprecated 065 boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception; 066}