FileDocCategorySizeDatePackage
Matches.javaAPI DocApache Ant 1.704164Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.condition

Matches

public class Matches extends org.apache.tools.ant.ProjectComponent implements Condition
Simple regular expression condition.
since
Ant 1.7

Fields Summary
private String
string
private boolean
caseSensitive
private boolean
multiLine
private boolean
singleLine
private org.apache.tools.ant.types.RegularExpression
regularExpression
Constructors Summary
Methods Summary
public voidaddRegexp(org.apache.tools.ant.types.RegularExpression regularExpression)
A regular expression. You can use this element to refer to a previously defined regular expression datatype instance

param
regularExpression the regular expression object to be configured as an element

        if (this.regularExpression != null) {
            throw new BuildException(
                "Only one regular expression is allowed.");
        }
        this.regularExpression = regularExpression;
    
public booleaneval()

return
true if the string matches the regular expression pattern
exception
BuildException if the attributes are not set correctly

        if (string == null) {
            throw new BuildException(
                "Parameter string is required in matches.");
        }
        if (regularExpression == null) {
            throw new BuildException("Missing pattern in matches.");
        }
        int options = RegexpMatcher.MATCH_DEFAULT;
        if (!caseSensitive) {
            options = options | RegexpMatcher.MATCH_CASE_INSENSITIVE;
        }
        if (multiLine) {
            options = options | RegexpMatcher.MATCH_MULTILINE;
        }
        if (singleLine) {
            options = options | RegexpMatcher.MATCH_SINGLELINE;
        }
        Regexp regexp = regularExpression.getRegexp(getProject());
        return regexp.matches(string, options);
    
public voidsetCasesensitive(boolean b)
Whether to ignore case or not.

param
b if false, ignore case.
since
Ant 1.7

        caseSensitive = b;
    
public voidsetMultiline(boolean b)
Whether to match should be multiline.

param
b the value to set.

        multiLine = b;
    
public voidsetPattern(java.lang.String pattern)
Set the regular expression to match against

param
pattern the regular expression pattern

        if (regularExpression != null) {
            throw new BuildException(
                "Only one regular expression is allowed.");
        }
        regularExpression = new RegularExpression();
        regularExpression.setPattern(pattern);
    
public voidsetSingleLine(boolean b)
Whether to treat input as singleline ('.' matches newline). Corresponsds to java.util.regex.Pattern.DOTALL.

param
b the value to set.

        singleLine = b;
    
public voidsetString(java.lang.String string)
Set the string

param
string the string to match


                  
        
        this.string = string;