| 1 25 package org.archive.crawler.settings.refinements; 26 27 import java.util.ArrayList ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 import java.util.ListIterator ; 31 32 import org.archive.crawler.settings.CrawlerSettings; 33 import org.archive.net.UURI; 34 35 36 43 public class Refinement { 44 private final CrawlerSettings owner; 45 private String description; 46 private String operator = "Admin"; 47 private String organization = ""; 48 private String audience = ""; 49 private String reference; 50 private List <Criteria> criteria = new ArrayList <Criteria>(); 51 52 53 60 public Refinement(CrawlerSettings owner, String reference) { 61 this.owner = owner; 62 this.reference = reference; 63 owner.addRefinement(this); 64 } 65 66 73 public Refinement(CrawlerSettings owner, String reference, String descr) { 74 this(owner, reference); 75 this.description = descr; 76 } 77 78 85 public boolean isWithinRefinementBounds(UURI uri) { 86 if (uri == null || uri == null) { 87 return false; 88 } 89 for (Iterator it = criteria.iterator(); it.hasNext();) { 90 if (!((Criteria) it.next()).isWithinRefinementBounds(uri)) { 91 return false; 92 } 93 } 94 return true; 95 } 96 97 102 public String getDescription() { 103 return description; 104 } 105 106 111 public void setDescription(String description) { 112 this.description = description; 113 } 114 115 121 public ListIterator criteriaIterator() { 122 return criteria.listIterator(); 123 } 124 125 130 public void addCriteria(Criteria criterion) { 131 if (!criteria.contains(criterion)) { 132 criteria.add(criterion); 133 } 134 } 135 136 141 public String getReference() { 142 return reference; 143 } 144 145 150 public void setReference(String reference) { 151 this.reference = reference; 152 } 153 154 159 public CrawlerSettings getSettings() { 160 String parentScope = owner.getScope() == null ? "" : owner.getScope(); 161 CrawlerSettings settings = owner.getSettingsHandler() 162 .getOrCreateSettingsObject(parentScope, getReference()); 163 settings.setDescription((getDescription())); 164 return settings; 165 } 166 167 public boolean equals(Object o) { 168 if (this == o 169 || (o instanceof Refinement && this.reference 170 .equals(((Refinement) o).reference))) { 171 return true; 172 } 173 return false; 174 } 175 176 179 public String getAudience() { 180 return this.audience; 181 } 182 185 public void setAudience(String audience) { 186 this.audience = audience; 187 } 188 191 public String getOperator() { 192 return this.operator; 193 } 194 197 public void setOperator(String operator) { 198 this.operator = operator; 199 } 200 203 public String getOrganization() { 204 return this.organization; 205 } 206 209 public void setOrganization(String organization) { 210 this.organization = organization; 211 } 212 } 213 | Popular Tags |