001    package railo.commons.res.io.filter;
002    
003    import railo.commons.io.res.Resource;
004    import railo.commons.io.res.filter.ResourceFilter;
005    
006    /**
007     * A FileFilter providing conditional AND logic across a list of file filters. 
008     * This filter returns true if all filters in the list return true. 
009     * Otherwise, it returns false. Checking of the file filter list stops when the first filter returns false. 
010     */
011    public final class AndFileFilter implements ResourceFilter {
012        
013        private ResourceFilter[] filters;
014    
015        /**
016         * @param filters
017         */
018        public AndFileFilter(ResourceFilter[] filters) {
019            this.filters=filters;
020        }
021    
022        /**
023         *
024         * @see railo.commons.io.res.filter.ResourceFilter#accept(railo.commons.io.res.Resource)
025         */
026        public boolean accept(Resource res) {
027            for(int i=0;i<filters.length;i++) {
028                if(!filters[i].accept(res)) return false;
029            }
030            return true;
031        }
032    }