1 19 20 33 package org.htmlparser.scanners; 34 35 36 import java.util.Hashtable ; 40 41 import org.htmlparser.tags.FrameTag; 42 import org.htmlparser.tags.Tag; 43 import org.htmlparser.tags.data.TagData; 44 import org.htmlparser.util.LinkProcessor; 45 import org.htmlparser.util.ParserException; 46 47 53 public class FrameScanner extends TagScanner 54 { 55 58 public FrameScanner() 59 { 60 super(); 61 } 62 65 public FrameScanner(String filter) 66 { 67 super(filter); 68 } 69 75 public String extractFrameLocn(Tag tag, String url) throws ParserException 76 { 77 try 78 { 79 Hashtable table = tag.getAttributes(); 80 String relativeFrame = (String ) table.get("SRC"); 81 if (relativeFrame == null) 82 return ""; 83 else 84 return (new LinkProcessor()).extract(relativeFrame, url); 85 } 86 catch (Exception e) 87 { 88 String msg; 89 if (tag != null) 90 msg = tag.getText(); 91 else 92 msg = "null"; 93 throw new ParserException( 94 "HTMLFrameScanner.extractFrameLocn() : Error in extracting frame location from tag " 95 + msg, 96 e); 97 } 98 } 99 100 public String extractFrameName(Tag tag, String url) 101 { 102 return tag.getAttribute("NAME"); 103 } 104 105 108 public String [] getID() 109 { 110 String [] ids = new String [1]; 111 ids[0] = "FRAME"; 112 return ids; 113 } 114 115 protected Tag createTag(TagData tagData, Tag tag, String url) 116 throws ParserException 117 { 118 String frameUrl = extractFrameLocn(tag, url); 119 String frameName = extractFrameName(tag, url); 120 121 return new FrameTag(tagData, frameUrl, frameName); 122 } 123 124 } 125 | Popular Tags |