
fitnesse.wiki.search.SuiteSpecificationMatchFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
The newest version!
package fitnesse.wiki.search;
import fitnesse.components.TraversalListener;
import fitnesse.wiki.WikiPage;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SuiteSpecificationMatchFinder extends WikiPageFinder {
private String titleRegEx;
private String contentRegEx;
public SuiteSpecificationMatchFinder(String titleRegEx, String contentRegEx, TraversalListener super WikiPage> observer) {
super(observer);
this.titleRegEx = titleRegEx;
this.contentRegEx = contentRegEx;
}
@Override
protected boolean pageMatches(WikiPage page) {
if(!nullOrEmpty(titleRegEx) && !nullOrEmpty(contentRegEx))
return patternMatches(titleRegEx, page.getName()) && patternMatches(contentRegEx,page.getData().getContent());
else{
return patternMatches(titleRegEx, page.getName()) || patternMatches(contentRegEx,page.getData().getContent());
}
}
private boolean patternMatches(String regEx, String subject) {
if (!nullOrEmpty(regEx)){
Pattern pattern = Pattern.compile(regEx, Pattern.DOTALL);
Matcher matcher = pattern.matcher(subject);
if(matcher.find())
return true;
}
return false;
}
private boolean nullOrEmpty(String regEx) {
return regEx == null || regEx.equals("");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy