org.apache.tools.ant.util.regexp

Class Jdk14RegexpMatcher

Implemented Interfaces:
RegexpMatcher
Known Direct Subclasses:
Jdk14RegexpRegexp

public class Jdk14RegexpMatcher
extends java.lang.Object
implements RegexpMatcher

Implementation of RegexpMatcher for the built-in regexp matcher of JDK 1.4. UNIX_LINES option is enabled as a default.

Fields inherited from interface org.apache.tools.ant.util.regexp.RegexpMatcher

MATCH_CASE_INSENSITIVE, MATCH_DEFAULT, MATCH_MULTILINE, MATCH_SINGLELINE

Constructor Summary

Jdk14RegexpMatcher()
Constructor for JakartaOroRegexp

Method Summary

protected Pattern
getCompiledPattern(int options)
Get a compiled representation of the regexp pattern
protected int
getCompilerOptions(int options)
Convert the generic options to the regex compiler specific options.
Vector
getGroups(String argument)
Returns a Vector of matched groups found in the argument using default options.
Vector
getGroups(String input, int options)
Returns a Vector of matched groups found in the argument.
String
getPattern()
Get a String representation of the regexp pattern
boolean
matches(String argument)
Does the given argument match the pattern using default options?
boolean
matches(String input, int options)
Does the given argument match the pattern?
void
setPattern(String pattern)
Set the regexp pattern from the String description.

Constructor Details

Jdk14RegexpMatcher

public Jdk14RegexpMatcher()
Constructor for JakartaOroRegexp

Method Details

getCompiledPattern

protected Pattern getCompiledPattern(int options)
            throws BuildException
Get a compiled representation of the regexp pattern

Parameters:
options - the options

Returns:
the compiled pattern

Throws:
BuildException - on error


getCompilerOptions

protected int getCompilerOptions(int options)
Convert the generic options to the regex compiler specific options.

Parameters:
options - the generic options

Returns:
the specific options


getGroups

public Vector getGroups(String argument)
            throws BuildException
Returns a Vector of matched groups found in the argument using default options.

Group 0 will be the full match, the rest are the parenthesized subexpressions.

Specified by:
getGroups in interface RegexpMatcher

Parameters:
argument - the string to match against

Returns:
the vector of groups

Throws:
BuildException - on error


getGroups

public Vector getGroups(String input,
                        int options)
            throws BuildException
Returns a Vector of matched groups found in the argument.

Group 0 will be the full match, the rest are the parenthesized subexpressions.

Specified by:
getGroups in interface RegexpMatcher

Parameters:
input - the string to match against
options - the regex options to use

Returns:
the vector of groups

Throws:
BuildException - on error


getPattern

public String getPattern()
Get a String representation of the regexp pattern
Specified by:
getPattern in interface RegexpMatcher

Returns:
the pattern


matches

public boolean matches(String argument)
            throws BuildException
Does the given argument match the pattern using default options?
Specified by:
matches in interface RegexpMatcher

Parameters:
argument - the string to match against

Returns:
true if the pattern matches

Throws:
BuildException - on error


matches

public boolean matches(String input,
                       int options)
            throws BuildException
Does the given argument match the pattern?
Specified by:
matches in interface RegexpMatcher

Parameters:
input - the string to match against
options - the regex options to use

Returns:
true if the pattern matches

Throws:
BuildException - on error


setPattern

public void setPattern(String pattern)
Set the regexp pattern from the String description.
Specified by:
setPattern in interface RegexpMatcher

Parameters:
pattern - the pattern to match


Copyright B) 2000-2005 Apache Software Foundation. All Rights Reserved.