* @param matcher
* @return
*/
public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher) {
List ret = new ArrayList();
Matcher orgMatcher = matcher.getMatcher(criteria.getOrganisation());
Matcher modMatcher = matcher.getMatcher(criteria.getName());
Matcher branchMatcher = matcher.getMatcher(criteria.getBranch());
Matcher revMatcher = matcher.getMatcher(criteria.getRevision());
Map tokenValues = new HashMap();
String[] orgs = listTokenValues(IvyPatternHelper.ORGANISATION_KEY, tokenValues);
for (int i = 0; i < orgs.length; i++) {
if (orgMatcher.matches(orgs[i])) {
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, orgs[i]);
String[] mods = listTokenValues(IvyPatternHelper.MODULE_KEY, tokenValues);
for (int j = 0; j < mods.length; j++) {
if (modMatcher.matches(mods[j])) {
tokenValues.put(IvyPatternHelper.MODULE_KEY, mods[j]);
String[] branches = listTokenValues(IvyPatternHelper.BRANCH_KEY,
tokenValues);
if (branches == null || branches.length == 0) {
branches = new String[] {settings.getDefaultBranch(new ModuleId(
orgs[i], mods[j]))};
}
for (int k = 0; k < branches.length; k++) {
if (branches[k] == null || branchMatcher.matches(branches[k])) {
tokenValues.put(IvyPatternHelper.BRANCH_KEY, tokenValues);
String[] revs = listTokenValues(IvyPatternHelper.REVISION_KEY,
tokenValues);
for (int l = 0; l < revs.length; l++) {
if (revMatcher.matches(revs[l])) {
ret.add(ModuleRevisionId.newInstance(orgs[i], mods[j],
branches[k], revs[l]));
}
}
tokenValues.remove(IvyPatternHelper.REVISION_KEY);