- for (Iterator i = root.elementIterator(ELEM_PROGRAM); i.hasNext(); ) {
- Element program = (Element)i.next();
- String pattern = ".*" + program.element(ELEM_PATTERN).getText() + ".*";
- conditions.add(new ProgramNameMatcher(pattern));
+ for (Iterator i = root.elementIterator(ELEM_PROGRAM); i.hasNext();) {
+ Element program = (Element) i.next();
+
+ Element actionElem = program.element(ELEM_ACTION);
+ ProgramAction action = new RecordProgramAction();
+ if (actionElem != null) {
+ if (actionElem.getText().equals(ACTION_NOTIFY)) {
+ action = new InterestingProgramAction("");
+ }
+ }
+ List<Condition<Program>> regexConditions =
+ new ArrayList<Condition<Program>>();
+ for (Iterator j = program.elementIterator(ELEM_PATTERN); j.hasNext(); ) {
+ Element patternElem = (Element)j.next();
+ String fieldName = "name";
+ Attribute fieldAttribute = patternElem.attribute("field");
+ if ( fieldAttribute != null ) {
+ fieldName = fieldAttribute.getText();
+ }
+ String pattern = ".*(" + patternElem.getText()
+ + ").*";
+ regexConditions.add(new PropertyRegexCondition<Program>(fieldName, pattern, true));
+ }
+ Condition<Program> condition = new AndCondition<Program>(regexConditions);
+ filters.add(new ProgramFilter(condition, action));