creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1462909 - in /creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles: ./ filter/
Date Sun, 31 Mar 2013 10:20:06 GMT
Author: rdonkin
Date: Sun Mar 31 10:20:05 2013
New Revision: 1462909

URL: http://svn.apache.org/r1462909
Log:
Repackage filters, introducing factory

Added:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/AndFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Filters.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/DeclaredFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/DeclaredFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/FilesOnlyFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FilesOnlyFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java
  (with props)
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/IsArchiveInPathFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/IsArchiveInPath.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LegalFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LegalFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LicenseFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NotFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NotFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NoticeFilter.java
      - copied, changed from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NoticeFilter.java
Removed:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/DeclaredFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FilesOnlyFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Filters.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/IsArchiveInPath.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LegalFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NotFilter.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NoticeFilter.java
Modified:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1462909&r1=1462908&r2=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java Sun Mar 31
10:20:05 2013
@@ -36,6 +36,7 @@ import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
+import org.apache.creadur.tentacles.filter.Filters;
 import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -69,6 +70,7 @@ public class Main {
     private final IOSystem ioSystem;
     private final TentaclesResources tentaclesResources;
     private final Templates templates;
+    private final Filters filters;
 
     public Main(final String... args) throws Exception {
         this(new Configuration(args), Platform.aPlatform());
@@ -88,6 +90,7 @@ public class Main {
         this.fileSystem = platform.getFileSystem();
         this.ioSystem = platform.getIoSystem();
         this.tentaclesResources = platform.getTentaclesResources();
+        this.filters = new Filters();
         this.templates = templates;
 
         this.local =
@@ -122,7 +125,8 @@ public class Main {
         prepare();
 
         final List<File> jars =
-                this.fileSystem.collect(this.repository, new FilesOnlyFilter());
+                this.fileSystem.collect(this.repository,
+                        this.filters.filesOnly());
 
         final List<Archive> archives = new ArrayList<Archive>();
         for (final File file : jars) {
@@ -156,7 +160,7 @@ public class Main {
         for (final Archive archive : archives) {
             final List<File> files =
                     this.fileSystem.collect(contents(archive.getFile()),
-                            new LicenseFilter());
+                            this.filters.licensesOnly());
             for (final File file : files) {
                 final License license = new License(this.ioSystem.slurp(file));
 
@@ -205,8 +209,8 @@ public class Main {
 
         final File contents = contents(archive.getFile());
         final List<File> files =
-                this.fileSystem.collect(contents, new Filters(
-                        new DeclaredFilter(contents), new LicenseFilter()));
+                this.fileSystem.collect(contents,
+                        this.filters.licensesIn(contents));
 
         for (final File file : files) {
 
@@ -243,8 +247,8 @@ public class Main {
 
             final File contents = contents(archive.getFile());
             final List<File> files =
-                    this.fileSystem.collect(contents, new Filters(
-                            new DeclaredFilter(contents), new NoticeFilter()));
+                    this.fileSystem.collect(contents,
+                            this.filters.noticesIn(contents));
 
             for (final File file : files) {
 
@@ -281,7 +285,7 @@ public class Main {
         for (final Archive archive : archives) {
             final List<File> files =
                     this.fileSystem.collect(contents(archive.getFile()),
-                            new NoticeFilter());
+                            this.filters.noticesOnly());
             for (final File file : files) {
                 final Notice notice = new Notice(this.ioSystem.slurp(file));
 
@@ -304,7 +308,7 @@ public class Main {
 
     private List<URI> allNoticeFiles() {
         final List<File> legal =
-                this.fileSystem.collect(this.content, new LegalFilter());
+                this.fileSystem.collect(this.content, this.filters.legalOnly());
         for (final File file : legal) {
             log.info("Legal " + file);
         }
@@ -337,9 +341,8 @@ public class Main {
             final File file =
                     new File(this.configuration.getStagingRepositoryURI());
             final List<File> collect =
-                    this.fileSystem.collect(
-                            file,
-                            new IsArchiveInPath(this.configuration
+                    this.fileSystem.collect(file, this.filters
+                            .archiveInPath(this.configuration
                                     .getFileRepositoryPathNameFilter()));
 
             for (final File f : collect) {
@@ -630,9 +633,8 @@ public class Main {
         private Map<URI, URI> mapOther() {
             final File jarContents = contents(this.file);
             final List<File> legal =
-                    Main.this.fileSystem.collect(jarContents, new Filters(
-                            new NotFilter(new DeclaredFilter(jarContents)),
-                            new LegalFilter()));
+                    Main.this.fileSystem.collect(jarContents, Main.this.filters
+                            .undeclaredLegalDocumentsIn(jarContents));
 
             final Map<URI, URI> map = new LinkedHashMap<URI, URI>();
             for (final File file : legal) {
@@ -648,10 +650,8 @@ public class Main {
         private Map<URI, URI> map() {
             final File jarContents = contents(this.file);
             final List<File> legal =
-                    Main.this.fileSystem
-                            .collect(jarContents, new Filters(
-                                    new DeclaredFilter(jarContents),
-                                    new LegalFilter()));
+                    Main.this.fileSystem.collect(jarContents, Main.this.filters
+                            .declaredLegalDocumentsIn(jarContents));
 
             final Map<URI, URI> map = new LinkedHashMap<URI, URI>();
             for (final File file : legal) {

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/AndFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Filters.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/AndFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/AndFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Filters.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Filters.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/AndFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,18 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 import java.util.ArrayList;
 import java.util.List;
 
-class Filters implements FileFilter {
+final class AndFilter implements FileFilter {
 
     List<FileFilter> filters = new ArrayList<FileFilter>();
 
-    Filters(final FileFilter... filters) {
+    AndFilter(final FileFilter... filters) {
         for (final FileFilter filter : filters) {
             this.filters.add(filter);
         }

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/DeclaredFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/DeclaredFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/DeclaredFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/DeclaredFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/DeclaredFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/DeclaredFilter.java
(original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/DeclaredFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-class DeclaredFilter implements FileFilter {
+final class DeclaredFilter implements FileFilter {
     private final File file;
 
     DeclaredFilter(final File file) {

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/FilesOnlyFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FilesOnlyFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/FilesOnlyFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/FilesOnlyFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FilesOnlyFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FilesOnlyFilter.java
(original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/FilesOnlyFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;

Added: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java?rev=1462909&view=auto
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java
(added)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java
Sun Mar 31 10:20:05 2013
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.tentacles.filter;
+
+import java.io.File;
+import java.io.FileFilter;
+
+public class Filters {
+
+    private final FilesOnlyFilter filesOnly;
+    private final LicenseFilter licensesOnly;
+    private final NoticeFilter noticesOnly;
+    private final LegalFilter legalOnly;
+
+    public Filters() {
+        this.filesOnly = new FilesOnlyFilter();
+        this.licensesOnly = new LicenseFilter();
+        this.noticesOnly = new NoticeFilter();
+        this.legalOnly = new LegalFilter();
+    }
+
+    public FileFilter filesOnly() {
+        return this.filesOnly;
+    }
+
+    public FileFilter licensesOnly() {
+        return this.licensesOnly;
+    }
+
+    public FileFilter noticesOnly() {
+        return this.noticesOnly;
+    }
+
+    public FileFilter legalOnly() {
+        return this.legalOnly;
+    }
+
+    public FileFilter licensesIn(final File contents) {
+        return new AndFilter(new DeclaredFilter(contents), new LicenseFilter());
+
+    }
+
+    public FileFilter noticesIn(final File contents) {
+        return new AndFilter(new DeclaredFilter(contents), new NoticeFilter());
+    }
+
+    public FileFilter undeclaredLegalDocumentsIn(final File contents) {
+        return new AndFilter(new NotFilter(new DeclaredFilter(contents)),
+                new LegalFilter());
+    }
+
+    public FileFilter declaredLegalDocumentsIn(final File contents) {
+        return new AndFilter(new DeclaredFilter(contents), new LegalFilter());
+    }
+
+    public FileFilter archiveInPath(final String repositoryPathNameFilter) {
+        return new IsArchiveInPathFilter(repositoryPathNameFilter);
+    }
+}

Propchange: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/Filters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/IsArchiveInPathFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/IsArchiveInPath.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/IsArchiveInPathFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/IsArchiveInPathFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/IsArchiveInPath.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/IsArchiveInPath.java
(original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/IsArchiveInPathFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,16 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-final class IsArchiveInPath implements FileFilter {
+final class IsArchiveInPathFilter implements FileFilter {
 
     private final String pathNameFilter;
 
-    IsArchiveInPath(final String pathNameFilter) {
+    IsArchiveInPathFilter(final String pathNameFilter) {
         super();
         this.pathNameFilter = pathNameFilter;
     }

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LegalFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LegalFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LegalFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LegalFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LegalFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LegalFilter.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LegalFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-class LegalFilter implements FileFilter {
+final class LegalFilter implements FileFilter {
 
     private static final NoticeFilter notice = new NoticeFilter();
     private static final LicenseFilter license = new LicenseFilter();

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LicenseFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LicenseFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LicenseFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseFilter.java
(original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/LicenseFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-class LicenseFilter implements FileFilter {
+final class LicenseFilter implements FileFilter {
     @Override
     public boolean accept(final File pathname) {
         final String name = pathname.getName().toLowerCase();

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NotFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NotFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NotFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NotFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NotFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NotFilter.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NotFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-class NotFilter implements FileFilter {
+final class NotFilter implements FileFilter {
     private final FileFilter filter;
 
     NotFilter(final FileFilter filter) {

Copied: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NoticeFilter.java
(from r1462905, creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NoticeFilter.java)
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NoticeFilter.java?p2=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NoticeFilter.java&p1=creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NoticeFilter.java&r1=1462905&r2=1462909&rev=1462909&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NoticeFilter.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/filter/NoticeFilter.java
Sun Mar 31 10:20:05 2013
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.creadur.tentacles;
+package org.apache.creadur.tentacles.filter;
 
 import java.io.File;
 import java.io.FileFilter;
 
-class NoticeFilter implements FileFilter {
+final class NoticeFilter implements FileFilter {
     @Override
     public boolean accept(final File pathname) {
         final String name = pathname.getName().toLowerCase();



Mime
View raw message