com.crawljax.condition.RegexCondition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crawljax Show documentation
Show all versions of crawljax Show documentation
Crawling Ajax applications through dynamic analysis and
reconstruction of the UI state changes. Crawljax is based on a
method which dynamically builds a `state-flow graph' modeling
the various navigation paths and states within an Ajax
application.
The newest version!
package com.crawljax.condition;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.jcip.annotations.Immutable;
import com.crawljax.browser.EmbeddedBrowser;
/**
* Condition that returns true iff experssion occurs in the dom.
*
* @author [email protected] (Danny Roest)
* @version $Id$
*/
@Immutable
public class RegexCondition extends AbstractCondition {
private final String expression;
/**
* @param expression
* the regular expression.
*/
public RegexCondition(String expression) {
this.expression = expression;
}
@Override
public boolean check(EmbeddedBrowser browser) {
String dom = browser.getDom();
Pattern p = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(dom);
return m.find();
}
}