1 24 package org.archive.crawler.deciderules; 25 26 27 import javax.management.AttributeNotFoundException ; 28 29 import org.archive.crawler.framework.CrawlScope; 30 31 36 public class DecidingScope extends CrawlScope { 37 38 private static final long serialVersionUID = -2942787757512964906L; 39 40 public static final String ATTR_DECIDE_RULES = "decide-rules"; 43 44 public DecidingScope(String name) { 45 super(name); 46 setDescription( 47 "DecidingScope. A Scope that applies one or " + 48 "more DecideRules to determine whether a URI is accepted " + 49 "or rejected (returns false)."); 50 addElementToDefinition(new DecideRuleSequence( 51 ATTR_DECIDE_RULES)); 52 } 53 54 protected DecideRule getDecideRule(Object o) { 55 try { 56 return (DecideRule)getAttribute(o, ATTR_DECIDE_RULES); 57 } catch (AttributeNotFoundException e) { 58 throw new RuntimeException (e); 59 } 60 } 61 62 protected boolean innerAccepts(Object o) { 63 return getDecideRule(o).decisionFor(o).equals(DecideRule.ACCEPT); 67 } 68 69 73 public void kickUpdate() { 74 super.kickUpdate(); 75 getDecideRule(null).kickUpdate(); 78 } 79 } 80 | Popular Tags |