1 24 package org.archive.crawler.settings; 25 26 import java.util.logging.Level ; 27 28 34 public class LegalValueListConstraint extends Constraint { 35 36 private static final long serialVersionUID = -4293290799574408033L; 37 38 44 public LegalValueListConstraint(Level level, String msg) { 45 super(level, msg); 46 } 47 48 54 public LegalValueListConstraint(String msg) { 55 this(Level.WARNING, msg); 56 } 57 58 63 public LegalValueListConstraint(Level level) { 64 this(level, "Value not in legal values list"); 65 } 66 67 72 public LegalValueListConstraint() { 73 this(Level.WARNING); 74 } 75 76 82 public FailedCheck innerCheck(CrawlerSettings settings, ComplexType owner, 83 Type definition, 84 Object value) { 85 FailedCheck res = null; 86 87 Object legalValues[] = definition.getLegalValues(); 90 if (legalValues != null) { 91 boolean found = false; 92 for (int i = 0; i < legalValues.length && !found; i++) { 93 if (legalValues[i].equals(value)) { 94 found = true; 95 } 96 } 97 if (!found) { 98 res = new FailedCheck(settings, owner, definition, value); 99 } 100 } 101 return res; 102 } 103 104 } | Popular Tags |