View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.creadur.tentacles.filter;
20  
21  import java.io.File;
22  import java.io.FileFilter;
23  
24  public class Filters {
25  
26      private final FilesOnlyFilter filesOnly;
27      private final LicenseFilter licensesOnly;
28      private final NoticeFilter noticesOnly;
29      private final LegalFilter legalOnly;
30  
31      public Filters() {
32          this.filesOnly = new FilesOnlyFilter();
33          this.licensesOnly = new LicenseFilter();
34          this.noticesOnly = new NoticeFilter();
35          this.legalOnly = new LegalFilter();
36      }
37  
38      public FileFilter filesOnly() {
39          return this.filesOnly;
40      }
41  
42      public FileFilter licensesOnly() {
43          return this.licensesOnly;
44      }
45  
46      public FileFilter noticesOnly() {
47          return this.noticesOnly;
48      }
49  
50      public FileFilter legalOnly() {
51          return this.legalOnly;
52      }
53  
54      public FileFilter licensesDeclaredIn(final File contents) {
55          return new AndFilter(new DeclaredFilter(contents), new LicenseFilter());
56  
57      }
58  
59      public FileFilter noticesDeclaredIn(final File contents) {
60          return new AndFilter(new DeclaredFilter(contents), new NoticeFilter());
61      }
62  
63      public FileFilter legalDocumentsUndeclaredIn(final File contents) {
64          return new AndFilter(new NotFilter(new DeclaredFilter(contents)),
65                  new LegalFilter());
66      }
67  
68      public FileFilter legalDocumentsDeclaredIn(final File contents) {
69          return new AndFilter(new DeclaredFilter(contents), new LegalFilter());
70      }
71  
72      public FileFilter archivesInPath(final String repositoryPathNameFilter) {
73          return new IsArchiveInPathFilter(repositoryPathNameFilter);
74      }
75  }