Package org.apache.ivy.plugins.matcher

Examples of org.apache.ivy.plugins.matcher.Matcher


   * @param matcher
   * @return
   */
  public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher) {
    List ret = new ArrayList();
    Matcher orgMatcher = matcher.getMatcher(criteria.getOrganisation());
    Matcher modMatcher = matcher.getMatcher(criteria.getName());
    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])) {
            ret.add(new ModuleId(orgs[i], mods[j]));
          }
        }
      }
    }
View Full Code Here


   * @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]));
                  }
                }
              }
            }
View Full Code Here

            if (fromNamespace != null) {
                org = NameSpaceHelper.transform(pattern.getModuleId(), fromNamespace.getFromSystemTransformer()).getOrganisation();
            }
            modules.addAll(Arrays.asList(resolver.listModules(new OrganisationEntry(resolver, org))));                   
        } else {
            Matcher orgMatcher = matcher.getMatcher(pattern.getOrganisation());
            for (int i = 0; i < orgs.length; i++) {
                String org = orgs[i].getOrganisation();
                String systemOrg = org;
                if (fromNamespace != null) {
                    systemOrg = NameSpaceHelper.transformOrganisation(org, fromNamespace.getToSystemTransformer());
                }
                if (orgMatcher.matches(systemOrg)) {
                    modules.addAll(Arrays.asList(resolver.listModules(new OrganisationEntry(resolver, org))));                   
                }
            }
        }               
        Message.debug("found " + modules.size() + " modules for "+pattern.getOrganisation()+" on " + resolverName);
View Full Code Here

  public IvyEventFilter(String event, String filterExpression, PatternMatcher matcher) {
    _matcher = matcher == null ? ExactPatternMatcher.INSTANCE : matcher;
    if (event == null) {
      _nameFilter = NoFilter.INSTANCE;
    } else {
      final Matcher eventNameMatcher = _matcher.getMatcher(event);
      _nameFilter = new Filter() {
        public boolean accept(Object o) {
          IvyEvent e = (IvyEvent) o;
          return eventNameMatcher.matches(e.getName());
        }
      };
    }
    _attFilter = filterExpression == null  || filterExpression.trim().length() == 0 ?
        NoFilter.INSTANCE
View Full Code Here

   
    if (matches != null) {
      Iterator it = matches.iterator();
      while (!accept && it.hasNext()) {
        Match match = (Match) it.next();
        Matcher matcher = match.getPatternMatcher(askedMrid);
        accept = matcher.matches(foundMrid.getRevision());
      }
    }
   
    return accept;
  }
View Full Code Here

            return result;
        }
       
        tokenSet.remove(token);

        Matcher matcher = null;
        Object criteriaForToken = criteria.get(token);
        if (criteriaForToken instanceof Matcher) {
            matcher = (Matcher) criteriaForToken;
        }

        String[] values = listTokenValues(partiallyResolvedPattern, token);
        if (values == null) {
            return result;
        }

        List vals = new ArrayList(Arrays.asList(values));
        filterNames(vals);
       
        for (Iterator it = vals.iterator(); it.hasNext();) {
            String value = (String) it.next();
            if ((matcher != null) && !matcher.matches(value)) {
                continue;
            }
           
            tokenValues.put(token, value);
            String moreResolvedPattern = IvyPatternHelper.substituteTokens(
View Full Code Here

        if (revMatches != null) {
            Iterator it = revMatches.iterator();
            while (!accept && it.hasNext()) {
                Match match = (Match) it.next();
                Matcher matcher = match.getPatternMatcher(askedMrid);
                accept = matcher.matches(foundMrid.getRevision());
            }
        }

        return accept;
    }
View Full Code Here

            return result;
        }
       
        tokenSet.remove(token);

        Matcher matcher = null;
        Object criteriaForToken = criteria.get(token);
        if (criteriaForToken instanceof Matcher) {
            matcher = (Matcher) criteriaForToken;
        }

        String[] values = listTokenValues(partiallyResolvedPattern, token);
        if (values == null) {
            return result;
        }

        List vals = new ArrayList(Arrays.asList(values));
        filterNames(vals);
       
        for (Iterator it = vals.iterator(); it.hasNext();) {
            String value = (String) it.next();
            if ((matcher != null) && !matcher.matches(value)) {
                continue;
            }
           
            tokenValues.put(token, value);
            String moreResolvedPattern = IvyPatternHelper.substituteTokens(
View Full Code Here

    public IvyEventFilter(String event, String filterExpression, PatternMatcher matcher) {
        this.matcher = matcher == null ? ExactPatternMatcher.INSTANCE : matcher;
        if (event == null) {
            nameFilter = NoFilter.INSTANCE;
        } else {
            final Matcher eventNameMatcher = this.matcher.getMatcher(event);
            nameFilter = new Filter() {
                public boolean accept(Object o) {
                    IvyEvent e = (IvyEvent) o;
                    return eventNameMatcher.matches(e.getName());
                }
            };
        }
        attFilter = filterExpression == null || filterExpression.trim().length() == 0
                ? NoFilter.INSTANCE : parseExpression(filterExpression);
View Full Code Here

            PatternMatcher patternMatcher, String expression, Map criteria, String key) {
        if (expression == null) {
            return;
        }
       
        Matcher matcher = patternMatcher.getMatcher(expression);
        if (matcher.isExact()) {
            criteria.put(key, expression);
        } else {
            criteria.put(key, matcher);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ivy.plugins.matcher.Matcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.