org.apache.anteater.test.matchers
Class Regexp

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.anteater.test.BaseTask
                    |
                    +--org.apache.anteater.test.ContentHandlerTask
                          |
                          +--org.apache.anteater.test.MatcherTest
                                |
                                +--org.apache.anteater.test.matchers.Regexp
All Implemented Interfaces:
Groupable, ObjectModel, org.apache.tools.ant.TaskContainer

public class Regexp
extends MatcherTest

Validates content against a regular expression.

Since:
27 December, 2001
Version:
$Revision: 1.13 $ $Date: 2002/10/23 16:55:50 $
Author:
Jeff Turner

Field Summary
protected  int _group
           
protected  boolean _ignoreCase
           
protected  Boolean _ignoreSpaces
           
protected  boolean _ignoreTags
           
protected  boolean _mustMatch
           
protected  String _pattern
           
protected  Boolean _singleLine
           
protected static String FALSE_MESSAGE
           
protected static String TRUE_MESSAGE
           
 
Fields inherited from class org.apache.anteater.test.MatcherTest
logger, matcher, objectModel, property
 
Fields inherited from class org.apache.anteater.test.ContentHandlerTask
handlerFactory, matcherTests
 
Fields inherited from class org.apache.anteater.test.BaseTask
debug, debugWasSet
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Fields inherited from interface org.apache.anteater.test.ObjectModel
NAMESPACES_KEY, PROPERTIES_KEY
 
Constructor Summary
Regexp()
           
Regexp(String pattern, boolean mustMatch, boolean ignoreCase, boolean singleLine)
           
 
Method Summary
 void addText(String pattern)
          Set the regular expression.
 void setGroup(int num)
          Sets the regexp 'group number' whose match will be returned in the 'assign' variable.
 void setIgnoreCase(boolean ignoreCase)
          A boolean flag indicating whether case in the regexp is significant.
 void setIgnoreSpaces(boolean ignore)
          Set whether whitespace will be ignored when testing.
 void setIgnoreTags(boolean ignore)
          Whether to ignore <tags> when making comparisons.
 void setMustMatch(boolean mustMatch)
          A boolean flag indicating whether the specified regexp must or mustn't match for the test to have passed.
 void setPattern(String pattern)
          Set the regular expression.
 void setSingleLine(boolean singleLine)
          Whether .* matches newlines (\n).
 String toString()
           
 boolean validate()
          Return true if this instance matches against the matchOn object of the matcher.
 
Methods inherited from class org.apache.anteater.test.MatcherTest
getMatchOn, getResult, getText, setAssign, setLogger, setMatcher, setObjectModel, setPropertyValue
 
Methods inherited from class org.apache.anteater.test.ContentHandlerTask
addTask, execute
 
Methods inherited from class org.apache.anteater.test.BaseTask
debug, getDebug, getGroup, print, println, resolveContentURL, setDebug, setGroup, setGroup
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_pattern

protected String _pattern

_mustMatch

protected boolean _mustMatch

_ignoreCase

protected boolean _ignoreCase

_singleLine

protected Boolean _singleLine

_ignoreSpaces

protected Boolean _ignoreSpaces

_ignoreTags

protected boolean _ignoreTags

_group

protected int _group

TRUE_MESSAGE

protected static final String TRUE_MESSAGE
See Also:
Constant Field Values

FALSE_MESSAGE

protected static final String FALSE_MESSAGE
See Also:
Constant Field Values
Constructor Detail

Regexp

public Regexp()

Regexp

public Regexp(String pattern,
              boolean mustMatch,
              boolean ignoreCase,
              boolean singleLine)
Method Detail

setPattern

public void setPattern(String pattern)
Set the regular expression.


addText

public void addText(String pattern)
Set the regular expression.

Overrides:
addText in class MatcherTest

toString

public String toString()
Overrides:
toString in class Object

setMustMatch

public void setMustMatch(boolean mustMatch)
A boolean flag indicating whether the specified regexp must or mustn't match for the test to have passed. The default is true; the regexp must match.


setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)
A boolean flag indicating whether case in the regexp is significant. The default is false; case is insignificant.


setIgnoreSpaces

public void setIgnoreSpaces(boolean ignore)
Set whether whitespace will be ignored when testing. Useful when whitespace differences are incidental, eg linefeed differences. Defaults to false, ie whitespace is significant.


setIgnoreTags

public void setIgnoreTags(boolean ignore)
Whether to ignore <tags> when making comparisons. Tags are effectively stripped from the context before matching against the regexp. Useful in conjunction with ignoreSpaces for validating visible content in a browser. Defaults to false, ie tags are not ignored. Currently unimplemented


setGroup

public void setGroup(int num)
Sets the regexp 'group number' whose match will be returned in the 'assign' variable. Defaults to 0, ie if the text matches, it will all be returned in the 'assign' variable.

For example, if the text we're matching is 'name: Joe Bloggs':


setSingleLine

public void setSingleLine(boolean singleLine)
Whether .* matches newlines (\n). The default is true, so for example, <html>.*<body> will match if there is a newline between the html and body tags.


validate

public boolean validate()
                 throws org.apache.tools.ant.BuildException
Description copied from class: MatcherTest
Return true if this instance matches against the matchOn object of the matcher.

Specified by:
validate in class MatcherTest
Returns:
a boolean value
org.apache.tools.ant.BuildException


Ant Functional Tester -- see Project home page for details