1 27 package org.htmlparser.visitors; 28 29 import org.htmlparser.Node; 30 import org.htmlparser.Tag; 31 import org.htmlparser.util.NodeList; 32 33 public class ObjectFindingVisitor extends NodeVisitor { 34 private Class classTypeToFind; 35 private NodeList tags; 36 37 public ObjectFindingVisitor(Class classTypeToFind) { 38 this(classTypeToFind,true); 39 } 40 41 public ObjectFindingVisitor(Class classTypeToFind,boolean recurse) { 42 super(recurse, true); 43 this.classTypeToFind = classTypeToFind; 44 this.tags = new NodeList(); 45 } 46 47 public int getCount() { 48 return (tags.size ()); 49 } 50 51 public void visitTag(Tag tag) { 52 if (tag.getClass().equals(classTypeToFind)) 53 tags.add(tag); 54 } 55 56 public Node[] getTags() { 57 return tags.toNodeArray(); 58 } 59 } 60 | Popular Tags |