1 16 package dom.traversal; 17 18 19 import org.w3c.dom.Node ; 20 import org.w3c.dom.traversal.NodeFilter; 21 22 26 public class NameNodeFilter implements NodeFilter { 27 28 String fName; 29 boolean fMatch = true; 30 31 34 public void setName(String name) { 35 this.fName = name; 36 } 37 38 40 public String getName() { 41 return this.fName; 42 } 43 44 52 public void setMatch(boolean match) { 53 this.fMatch = match; 54 } 55 56 57 public boolean getMatch() { 58 return this.fMatch; 59 } 60 61 62 public short acceptNode(Node n) { 63 64 if (fName == null || fMatch && n.getNodeName().equals(fName) 65 || !fMatch && !n.getNodeName().equals(fName)) 66 return FILTER_ACCEPT; 67 else 68 return FILTER_REJECT; 69 } 70 } 71 | Popular Tags |