100 |
* array given will be put into the output list if it matches one |
* array given will be put into the output list if it matches one |
101 |
* or more of the wildcards added to this PackageMatcher before. |
* or more of the wildcards added to this PackageMatcher before. |
102 |
*/ |
*/ |
103 |
public SortedSet match(PackageDoc[] packageDocs) |
public SortedSet filter(PackageDoc[] packageDocs) |
104 |
{ |
{ |
105 |
SortedSet result = new TreeSet(); |
SortedSet result = new TreeSet(); |
106 |
for (int i=0; i<packageDocs.length; ++i) { |
for (int i=0; i<packageDocs.length; ++i) { |
107 |
PackageDoc packageDoc = packageDocs[i]; |
if (match(packageDocs[i])) { |
108 |
Iterator it = patterns.iterator(); |
result.add(packageDocs[i]); |
|
while (it.hasNext()) { |
|
|
Pattern pattern = (Pattern)it.next(); |
|
|
Matcher matcher = pattern.matcher(packageDoc.name()); |
|
|
if (matcher.matches()) { |
|
|
result.add(packageDoc); |
|
|
break; |
|
|
} |
|
109 |
} |
} |
110 |
} |
} |
111 |
return result; |
return result; |
112 |
} |
} |
113 |
|
|
114 |
|
/** |
115 |
|
* Return true when the given PackageDoc matches one or more of |
116 |
|
* the wildcard added to this PackageMatcher before. |
117 |
|
*/ |
118 |
|
public boolean match(PackageDoc packageDoc) |
119 |
|
{ |
120 |
|
Iterator it = patterns.iterator(); |
121 |
|
while (it.hasNext()) { |
122 |
|
Pattern pattern = (Pattern)it.next(); |
123 |
|
Matcher matcher = pattern.matcher(packageDoc.name()); |
124 |
|
if (matcher.matches()) { |
125 |
|
break; |
126 |
|
} |
127 |
|
} |
128 |
|
return false; |
129 |
|
} |
130 |
} |
} |