1 19 20 33 package org.htmlparser.scanners; 34 35 import org.htmlparser.tags.BaseHrefTag; 36 import org.htmlparser.tags.Tag; 37 import org.htmlparser.tags.data.TagData; 38 import org.htmlparser.util.LinkProcessor; 39 import org.htmlparser.util.ParserException; 40 41 public class BaseHrefScanner extends TagScanner 42 { 43 private LinkProcessor processor; 44 45 public BaseHrefScanner() 46 { 47 super(); 48 } 49 50 public BaseHrefScanner(String filter, LinkProcessor processor) 51 { 52 super(filter); 53 this.processor = processor; 54 } 55 56 public String [] getID() 57 { 58 String [] ids = new String [1]; 59 ids[0] = "BASE"; 60 return ids; 61 } 62 63 protected Tag createTag(TagData tagData, Tag tag, String url) 64 throws ParserException 65 { 66 String baseUrl = (String ) tag.getAttribute("HREF"); 67 String absoluteBaseUrl = ""; 68 if (baseUrl != null && baseUrl.length() > 0) 69 { 70 absoluteBaseUrl = LinkProcessor.removeLastSlash(baseUrl.trim()); 71 processor.setBaseUrl(absoluteBaseUrl); 72 } 73 return new BaseHrefTag(tagData, absoluteBaseUrl); 74 } 75 } 76 | Popular Tags |