1 27 package org.htmlparser.filters; 28 29 import org.htmlparser.Node; 30 import org.htmlparser.NodeFilter; 31 32 35 public class OrFilter implements NodeFilter 36 { 37 40 protected NodeFilter[] mPredicates; 41 42 48 public OrFilter () 49 { 50 setPredicates (null); 51 } 52 53 58 public OrFilter (NodeFilter left, NodeFilter right) 59 { 60 NodeFilter[] predicates; 61 62 predicates = new NodeFilter[2]; 63 predicates[0] = left; 64 predicates[1] = right; 65 setPredicates (predicates); 66 } 67 68 72 public NodeFilter[] getPredicates () 73 { 74 return (mPredicates); 75 } 76 77 81 public void setPredicates (NodeFilter[] predicates) 82 { 83 if (null == predicates) 84 predicates = new NodeFilter[0]; 85 mPredicates = predicates; 86 } 87 88 92 96 public boolean accept (Node node) 97 { 98 boolean ret; 99 100 ret = false; 101 102 for (int i = 0; !ret && (i < mPredicates.length); i++) 103 if (mPredicates[i].accept (node)) 104 ret = true; 105 106 return (ret); 107 } 108 } 109 | Popular Tags |