1 package org.codehaus.mojo.clirr;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import net.sf.clirr.core.ClassFilter;
20 import org.apache.bcel.classfile.JavaClass;
21 import org.codehaus.plexus.util.SelectorUtils;
22
23
24
25
26
27
28 public class ClirrClassFilter
29 implements ClassFilter
30 {
31 private final String[] excludes;
32
33 private final String[] includes;
34
35 private boolean alwaysTrue;
36
37 public ClirrClassFilter( String[] includes, String[] excludes )
38 {
39 if ( excludes == null || excludes.length == 0 )
40 {
41 this.excludes = null;
42 }
43 else
44 {
45 this.excludes = (String[]) excludes.clone();
46 }
47
48 if ( includes == null || includes.length == 0 )
49 {
50 this.includes = new String[]{"**"};
51
52 if ( excludes == null )
53 {
54 alwaysTrue = true;
55 }
56 }
57 else
58 {
59 this.includes = (String[]) includes.clone();
60 }
61 }
62
63 public boolean isSelected( JavaClass javaClass )
64 {
65 boolean result = false;
66 if ( alwaysTrue )
67 {
68 result = true;
69 }
70 else
71 {
72 String path = javaClass.getClassName().replace( '.', '/' );
73 for ( int i = 0; i < includes.length && !result; i++ )
74 {
75 result = SelectorUtils.matchPath( includes[i], path );
76 }
77
78 if ( excludes != null )
79 {
80 for ( int i = 0; i < excludes.length && result; i++ )
81 {
82 result = !SelectorUtils.matchPath( excludes[i], path );
83 }
84 }
85 }
86
87 return result;
88 }
89 }