Package org.apache.tools.ant.util.regexp

Examples of org.apache.tools.ant.util.regexp.Regexp


        }
        if (regularExpression == null) {
            throw new BuildException("Missing pattern in matches.");
        }
        int options = RegexpUtil.asOptions(caseSensitive, multiLine, singleLine);
        Regexp regexp = regularExpression.getRegexp(getProject());
        return regexp.matches(string, options);
    }
View Full Code Here


    if (match == null) {
      throw new BuildException( "Missing match in setregex" );
    }
    RegularExpression regularExpression = new RegularExpression();
    regularExpression.setPattern( match );
    Regexp regexp = regularExpression.getRegexp( getProject() );
    if (!regexp.matches( input, Regexp.MATCH_SINGLELINE )) {
      return;
    }
    String substituted = regexp.substitute( input, value, Regexp.MATCH_SINGLELINE );
    getProject().setProperty( property, substituted );
  }
View Full Code Here

        if (! caseSensitive)
            options |= Regexp.MATCH_CASE_INSENSITIVE;
        if (global)
            options |= Regexp.REPLACE_ALL;

        Regexp sregex = regexp.getRegexp(project);

        String output = null;

        if (sregex.matches(input, options))
            output = sregex.substitute(input,
                    replace.getExpression(getProject()),
                    options);

        if (output == null)
            output = defaultValue;
View Full Code Here

    {
        int options = 0;
        if (! caseSensitive)
            options |= Regexp.MATCH_CASE_INSENSITIVE;

        Regexp sregex = regexp.getRegexp(project);

        String output = select;
        Vector groups = sregex.getGroups(input, options);

        if (groups != null && groups.size() > 0)
        {
            output = RegexUtil.select(select, groups);
        }
View Full Code Here

        int options = 0;
        if (!caseSensitive)
            options |= Regexp.MATCH_CASE_INSENSITIVE;

        Regexp regex = match.getRegexp(project);
        Hashtable props = project.getProperties();
        Enumeration e = props.keys();
        StringBuffer buf = new StringBuffer();
        int cnt = 0;

        Vector used = new Vector();

        while (e.hasMoreElements())
        {
            String key = (String) (e.nextElement());
            if (regex.matches(key, options))
            {
                String output = select;
                Vector groups = regex.getGroups(key, options);
                int sz = groups.size();
                for (int i = 0; i < sz; i++)
                {
                    String s = (String) (groups.elementAt(i));

                    RegularExpression result = null;
                    result = new RegularExpression();
                    result.setPattern("\\\\" + i);
                    Regexp sregex = result.getRegexp(project);
                    output = sregex.substitute(output, s, Regexp.MATCH_DEFAULT);
                }

                if (!(distinct && used.contains(output)))
                {
                    used.addElement(output);
View Full Code Here

    protected String doReplace(RegularExpression r,
                               Substitution s,
                               String input,
                               int options) {
        String res = input;
        Regexp regexp = r.getRegexp(getProject());

        if (regexp.matches(input, options)) {
            log("Found match; substituting", Project.MSG_DEBUG);
            res = regexp.substitute(input, s.getExpression(getProject()),
                                    options);
        }

        return res;
    }
View Full Code Here

    protected String doReplace(RegularExpression r,
                               Substitution s,
                               String input,
                               int options) {
        String res = input;
        Regexp regexp = r.getRegexp(getProject());

        if (regexp.matches(input, options)) {
            res = regexp.substitute(input, s.getExpression(getProject()),
                                    options);
        }

        return res;
    }
View Full Code Here

            while (line != null) {
                for (int i = 0; i < regexpsSize; i++) {
                    RegularExpression regexp = (RegularExpression)
                                                        regexps.elementAt(i);
                    Regexp re = regexp.getRegexp(getProject());
                    boolean matches = re.matches(line);
                    if (!matches) {
                        line = null;
                        break;
                    }
                }
View Full Code Here

            while (line != null) {
                for (int i = 0; i < regexpsSize; i++) {
                    RegularExpression regexp = (RegularExpression)
                                                        regexps.elementAt(i);
                    Regexp re = regexp.getRegexp(getProject());
                    boolean matches = re.matches(line);
                    if (!matches) {
                        line = null;
                        break;
                    }
                }
View Full Code Here

    protected String doReplace(RegularExpression r,
                               Substitution s,
                               String input,
                               int options) {
        String res = input;
        Regexp regexp = r.getRegexp(getProject());

        if (regexp.matches(input, options)) {
            res = regexp.substitute(input, s.getExpression(getProject()),
                                    options);
        }

        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.util.regexp.Regexp

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.