View Javadoc
1   package org.codehaus.plexus.archiver.util;
2   
3   import java.io.InputStream;
4   import java.util.List;
5   import org.codehaus.plexus.archiver.ArchiveFileFilter;
6   import org.codehaus.plexus.archiver.Archiver;
7   import org.codehaus.plexus.components.io.fileselectors.FileSelector;
8   import org.codehaus.plexus.logging.Logger;
9   
10  /**
11   * @deprecated Use {@link FileSelector} and {@link Archiver#addFileSet}.
12   */
13  @Deprecated
14  public class FilterSupport
15  {
16  
17      private final List<ArchiveFileFilter> filters;
18  
19      private final Logger logger;
20  
21      public FilterSupport( List<ArchiveFileFilter> filters, Logger logger )
22      {
23          this.filters = filters;
24          this.logger = logger;
25      }
26  
27      public boolean include( InputStream dataStream, String entryName )
28      {
29          boolean included = true;
30  
31          if ( filters != null && !filters.isEmpty() )
32          {
33              for ( ArchiveFileFilter filter : filters )
34              {
35                  included = filter.include( dataStream, entryName );
36  
37                  if ( !included )
38                  {
39                      if ( logger.isDebugEnabled() )
40                      {
41                          logger.debug( "Entry: \'" + entryName + "\' excluded by filter: "
42                                            + filter.getClass().getName() );
43  
44                      }
45  
46                      break;
47                  }
48              }
49          }
50  
51          return included;
52      }
53  
54  }