1 24 package org.archive.crawler.deciderules; 25 26 import javax.management.AttributeNotFoundException ; 27 28 import org.archive.crawler.framework.Filter; 29 30 38 public class DecidingFilter extends Filter { 39 40 private static final long serialVersionUID = -7275555425381445477L; 41 public static final String ATTR_DECIDE_RULES = "decide-rules"; 44 45 public DecidingFilter(String name, String description) { 46 this(name); 47 setDescription(description); 48 } 49 50 public DecidingFilter(String name) { 51 super(name, 52 "DecidingFilter. A filter that applies one or " + 53 "more DecideRules " + 54 "to determine whether a URI is accepted (returns true) or " + 55 "rejected (returns false). Only a final decision of " + 56 "ACCEPT returns true from the filter; either REJECT or " + 57 "PASS returns false."); 58 addElementToDefinition( 59 new DecideRuleSequence(ATTR_DECIDE_RULES)); 60 } 61 62 protected DecideRule getDecideRule(Object o) { 63 try { 64 return (DecideRule)getAttribute(o, ATTR_DECIDE_RULES); 65 } catch (AttributeNotFoundException e) { 66 throw new RuntimeException (e); 67 } 68 } 69 70 protected boolean innerAccepts(Object o) { 71 return getDecideRule(o).decisionFor(o) == DecideRule.ACCEPT; 72 } 73 74 78 public void kickUpdate() { 79 getDecideRule(null).kickUpdate(); 82 } 83 } 84 | Popular Tags |