1 27 package org.htmlparser.visitors; 28 29 import java.util.Locale ; 30 import org.htmlparser.tags.LinkTag; 31 32 import org.htmlparser.Tag; 33 34 public class LinkFindingVisitor extends NodeVisitor 35 { 36 private String linkTextToFind; 37 private int count; 38 private Locale locale; 39 40 public LinkFindingVisitor (String linkTextToFind) 41 { 42 this (linkTextToFind, null); 43 } 44 45 public LinkFindingVisitor (String linkTextToFind, Locale locale) 46 { 47 count = 0; 48 this.locale = (null == locale) ? Locale.ENGLISH : locale; 49 this.linkTextToFind = linkTextToFind.toUpperCase (this.locale); 50 } 51 52 public void visitTag(Tag tag) 53 { 54 if (tag instanceof LinkTag) 55 if (-1 != ((LinkTag)tag).getLinkText ().toUpperCase (locale).indexOf (linkTextToFind)) 56 count++; 57 } 58 59 public boolean linkTextFound() 60 { 61 return (0 != count); 62 } 63 64 public int getCount() 65 { 66 return (count); 67 } 68 69 } 70 | Popular Tags |