import org.wamblee.conditions.AndCondition;
import org.wamblee.conditions.Condition;
import org.wamblee.conditions.PropertyRegexCondition;
-import org.wamblee.crawler.kiss.ProgramFilter.ProgramAction;
/**
* Parse the configuration of desired programs.
private static final String ELEM_PATTERN = "match";
private static final String ELEM_ACTION = "action";
+
+ private static final String ELEM_CATEGORY = "category";
private static final String ACTION_NOTIFY = "notify";
for (Iterator i = root.elementIterator(ELEM_PROGRAM); i.hasNext();) {
Element program = (Element) i.next();
+ Element categoryElem = program.element(ELEM_CATEGORY);
+ String category = "";
+ if ( categoryElem != null ) {
+ category = categoryElem.getText().trim();
+ }
+
Element actionElem = program.element(ELEM_ACTION);
- ProgramAction action = ProgramAction.RECORD;
+ ProgramAction action = new RecordProgramAction();
if (actionElem != null) {
if (actionElem.getText().equals(ACTION_NOTIFY)) {
- action = ProgramAction.NOTIFY;
+ action = new InterestingProgramAction(category);
}
}
+
List<Condition<Program>> regexConditions =
new ArrayList<Condition<Program>>();
for (Iterator j = program.elementIterator(ELEM_PATTERN); j.hasNext(); ) {
if ( fieldAttribute != null ) {
fieldName = fieldAttribute.getText();
}
- String pattern = ".*" + patternElem.getText()
- + ".*";
+ String pattern = ".*(" + patternElem.getText()
+ + ").*";
regexConditions.add(new PropertyRegexCondition<Program>(fieldName, pattern, true));
}
Condition<Program> condition = new AndCondition<Program>(regexConditions);