geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1089940 - in /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter: ClassFilter.java ContainsFilter.java Filters.java PackageFilter.java PatternFilter.java PrefixFilter.java RegexFilter.java SuffixFilter.java
Date Thu, 07 Apr 2011 16:36:14 GMT
Author: dblevins
Date: Thu Apr  7 16:36:14 2011
New Revision: 1089940

URL: http://svn.apache.org/viewvc?rev=1089940&view=rev
Log:
XBEAN-166: Generic Filtering API usable for Archive scanning and more

Added:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java
  (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java
  (contents, props changed)
      - copied, changed from r1085846, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/RegexFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PrefixFilter.java
      - copied, changed from r1085846, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java
  (with props)
Removed:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/RegexFilter.java
Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ClassFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/Filters.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ClassFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ClassFilter.java?rev=1089940&r1=1089939&r2=1089940&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ClassFilter.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ClassFilter.java
Thu Apr  7 16:36:14 2011
@@ -28,6 +28,10 @@ public class ClassFilter implements Filt
         this.name = name;
     }
 
+    public String getName() {
+        return name;
+    }
+
     @Override
     public boolean accept(String name) {
         return this.name.equals(name);

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java?rev=1089940&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java
(added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java
Thu Apr  7 16:36:14 2011
@@ -0,0 +1,54 @@
+/**
+ * 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.xbean.finder.filter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContainsFilter implements Filter {
+
+    private final String token;
+
+    public ContainsFilter(String token) {
+        assert token != null;
+        this.token = token;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    @Override
+    public boolean accept(String name) {
+        return name.contains(token);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        ContainsFilter that = (ContainsFilter) o;
+
+        return token.equals(that.token);
+    }
+
+    @Override
+    public int hashCode() {
+        return token.hashCode();
+    }
+}
\ No newline at end of file

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/ContainsFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/Filters.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/Filters.java?rev=1089940&r1=1089939&r2=1089940&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/Filters.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/Filters.java
Thu Apr  7 16:36:14 2011
@@ -52,10 +52,37 @@ public class Filters {
         return optimize(filters);
     }
 
+    public static Filter prefixes(String... prefixes) {
+        List<Filter> filters = new ArrayList<Filter>();
+        for (String s : prefixes) {
+            filters.add(new PrefixFilter(s));
+        }
+
+        return optimize(filters);
+    }
+
+    public static Filter tokens(String... tokens) {
+        List<Filter> filters = new ArrayList<Filter>();
+        for (String s : tokens) {
+            filters.add(new ContainsFilter(s));
+        }
+
+        return optimize(filters);
+    }
+
+    public static Filter suffixes(String... suffixes) {
+        List<Filter> filters = new ArrayList<Filter>();
+        for (String s : suffixes) {
+            filters.add(new SuffixFilter(s));
+        }
+
+        return optimize(filters);
+    }
+
     public static Filter patterns(String... patterns) {
         List<Filter> filters = new ArrayList<Filter>();
         for (String s : patterns) {
-            filters.add(new RegexFilter(s));
+            filters.add(new PatternFilter(s));
         }
 
         return optimize(filters);

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java?rev=1089940&r1=1089939&r2=1089940&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java
Thu Apr  7 16:36:14 2011
@@ -29,6 +29,10 @@ public class PackageFilter implements Fi
         this.packageName = packageName;
     }
 
+    public String getPackageName() {
+        return packageName;
+    }
+
     @Override
     public boolean accept(String name) {
         return name.startsWith(packageName);

Copied: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java
(from r1085846, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/RegexFilter.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java?p2=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java&p1=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/RegexFilter.java&r1=1085846&r2=1089940&rev=1089940&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/RegexFilter.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java
Thu Apr  7 16:36:14 2011
@@ -21,19 +21,23 @@ import java.util.regex.Pattern;
 /**
  * @version $Rev$ $Date$
  */
-public class RegexFilter implements Filter {
+public class PatternFilter implements Filter {
 
     private final Pattern pattern;
 
-    public RegexFilter(String expression) {
+    public PatternFilter(String expression) {
         this(Pattern.compile(expression));
     }
 
-    public RegexFilter(Pattern pattern) {
+    public PatternFilter(Pattern pattern) {
         assert pattern != null;
         this.pattern = pattern;
     }
 
+    public Pattern getPattern() {
+        return pattern;
+    }
+
     @Override
     public boolean accept(String name) {
         return pattern.matcher(name).matches();
@@ -44,7 +48,7 @@ public class RegexFilter implements Filt
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
-        RegexFilter that = (RegexFilter) o;
+        PatternFilter that = (PatternFilter) o;
 
         return pattern.pattern().equals(that.pattern.pattern());
     }

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PatternFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PrefixFilter.java
(from r1085846, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PrefixFilter.java?p2=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PrefixFilter.java&p1=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java&r1=1085846&r2=1089940&rev=1089940&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PackageFilter.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/PrefixFilter.java
Thu Apr  7 16:36:14 2011
@@ -19,19 +19,22 @@ package org.apache.xbean.finder.filter;
 /**
  * @version $Rev$ $Date$
  */
-public class PackageFilter implements Filter {
+public class PrefixFilter implements Filter {
 
-    private final String packageName;
+    private final String prefix;
 
-    public PackageFilter(String packageName) {
-        assert packageName != null;
-        if (!packageName.endsWith(".")) packageName += ".";
-        this.packageName = packageName;
+    public PrefixFilter(String prefix) {
+        assert prefix != null;
+        this.prefix = prefix;
+    }
+
+    public String getPrefix() {
+        return prefix;
     }
 
     @Override
     public boolean accept(String name) {
-        return name.startsWith(packageName);
+        return name.startsWith(prefix);
     }
 
     @Override
@@ -39,13 +42,13 @@ public class PackageFilter implements Fi
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
-        PackageFilter that = (PackageFilter) o;
+        PrefixFilter that = (PrefixFilter) o;
 
-        return packageName.equals(that.packageName);
+        return prefix.equals(that.prefix);
     }
 
     @Override
     public int hashCode() {
-        return packageName.hashCode();
+        return prefix.hashCode();
     }
 }
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java?rev=1089940&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java
(added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java
Thu Apr  7 16:36:14 2011
@@ -0,0 +1,54 @@
+/**
+ * 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.xbean.finder.filter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SuffixFilter implements Filter {
+
+    private final String suffix;
+
+    public SuffixFilter(String suffix) {
+        assert suffix != null;
+        this.suffix = suffix;
+    }
+
+    public String getSuffix() {
+        return suffix;
+    }
+
+    @Override
+    public boolean accept(String name) {
+        return name.endsWith(suffix);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SuffixFilter that = (SuffixFilter) o;
+
+        return suffix.equals(that.suffix);
+    }
+
+    @Override
+    public int hashCode() {
+        return suffix.hashCode();
+    }
+}
\ No newline at end of file

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/filter/SuffixFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message