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 * This interface is used to select files when traversing a file hierarchy.
021 *
022 * @see Selectors
023 */
024public interface FileSelector {
025    /**
026     * Determines if a file or folder should be selected. This method is called in depthwise order (that is, it is
027     * called for the children of a folder before it is called for the folder itself).
028     *
029     * @param fileInfo the file or folder to select.
030     * @return true if the file should be selected.
031     * @throws Exception if an error occurs.
032     */
033    boolean includeFile(FileSelectInfo fileInfo) throws Exception;
034
035    /**
036     * Determines whether a folder should be traversed. If this method returns true, {@link #includeFile} is called for
037     * each of the children of the folder, and each of the child folders is recursively traversed.
038     * <p>
039     * This method is called on a folder before {@link #includeFile} is called.
040     *
041     * @param fileInfo the file or folder to select.
042     * @return true if the folder should be traversed.
043     * @throws Exception if an error occurs.
044     */
045    boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception;
046}