1 27 package org.htmlparser.filters; 28 29 import org.htmlparser.Node; 30 import org.htmlparser.NodeFilter; 31 32 35 public class AndFilter 36 implements 37 NodeFilter 38 { 39 42 protected NodeFilter[] mPredicates; 43 44 50 public AndFilter () 51 { 52 setPredicates (null); 53 } 54 55 60 public AndFilter (NodeFilter left, NodeFilter right) 61 { 62 NodeFilter[] predicates; 63 64 predicates = new NodeFilter[2]; 65 predicates[0] = left; 66 predicates[1] = right; 67 setPredicates (predicates); 68 } 69 70 74 public NodeFilter[] getPredicates () 75 { 76 return (mPredicates); 77 } 78 79 83 public void setPredicates (NodeFilter[] predicates) 84 { 85 if (null == predicates) 86 predicates = new NodeFilter[0]; 87 mPredicates = predicates; 88 } 89 90 94 98 public boolean accept (Node node) 99 { 100 boolean ret; 101 102 ret = true; 103 104 for (int i = 0; ret && (i < mPredicates.length); i++) 105 if (!mPredicates[i].accept (node)) 106 ret = false; 107 108 return (ret); 109 } 110 } 111 | Popular Tags |