[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags BaseHrefTag.java,1.28,1.29 FormTag.java,1.36,1.3
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-10-29 03:31:30
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1:/tmp/cvs-serv12839/src/org/htmlparser/tags Modified Files: BaseHrefTag.java FormTag.java ImageTag.java LinkTag.java Log Message: Move LinkProcess out of scanners and into Page, untangling A, IMG and BASE scanners. Move form action determination to tag. The scanners have no special actions on behalf of tags anymore. Index: BaseHrefTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/BaseHrefTag.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** BaseHrefTag.java 26 Oct 2003 19:46:22 -0000 1.28 --- BaseHrefTag.java 29 Oct 2003 03:31:17 -0000 1.29 *************** *** 30,33 **** --- 30,34 ---- package org.htmlparser.tags; + import java.util.Vector; import org.htmlparser.util.LinkProcessor; *************** *** 69,72 **** --- 70,85 ---- "--------\n"+ "Name : "+getBaseUrl(); + } + + /** + * Override this because we need a trigger to set the base HREF on the page. + * NOTE: setting of the attributes is the last thing done on the tag + * after creation. + * @param attribs The new BASE tag attributes. + */ + public void setAttributesEx (Vector attribs) + { + super.setAttributesEx (attribs); + getPage ().getLinkProcessor ().setBaseUrl (getBaseUrl ()); } } Index: FormTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/FormTag.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** FormTag.java 26 Oct 2003 19:46:23 -0000 1.36 --- FormTag.java 29 Oct 2003 03:31:17 -0000 1.37 *************** *** 31,34 **** --- 31,35 ---- import org.htmlparser.util.NodeList; + import org.htmlparser.util.ParserException; import org.htmlparser.util.SimpleNodeIterator; *************** *** 161,164 **** --- 162,200 ---- { return "FORM TAG : Form at "+getFormLocation()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); + } + + /** + * Extract the location of the image, given the tag, and the url + * of the html page in which this tag exists. + * @param tag The form tag with the 'ACTION' attribute. + * @param url URL of web page being parsed. + */ + public String extractFormLocn(String url)// throws ParserException + { + String formURL; + + formURL = getAttribute("ACTION"); + if (null == formURL) + return ""; + else + return (getPage ().getLinkProcessor ().extract (formURL, url)); + } + + /** + * Override this because we need a trigger to set the ACTION attribute. + * NOTE: setting of the children is the last thing done on the tag + * after creation. + * @param children The new list of children this node contains. + */ + public void setChildren (NodeList children) + { + String url; + + super.setChildren (children); + + // ... is it true that without an ACTION the default is to send it back to the same page? + url = extractFormLocn(getPage ().getUrl ()); + if (null != url && 0 < url.length()) + setAttribute ("ACTION",url); } } Index: ImageTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ImageTag.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ImageTag.java 26 Oct 2003 19:46:24 -0000 1.31 --- ImageTag.java 29 Oct 2003 03:31:17 -0000 1.32 *************** *** 195,197 **** --- 195,212 ---- } + /** + * Override this because we need a trigger to set the image URL. + * Need to update the imageURL string in the this tag, + * but not the SRC attribute so toHtml() outputs the right thing. + * NOTE: setting of the attributes is the last thing done on the tag + * after creation. + * @param attribs The new IMG tag attributes. + */ + public void setAttributesEx (Vector attribs) + { + String src; + + super.setAttributesEx (attribs); + imageURL = getPage ().getLinkProcessor ().extract (getImageURL (), getPage().getUrl ()); + } } Index: LinkTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/LinkTag.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** LinkTag.java 26 Oct 2003 19:46:24 -0000 1.38 --- LinkTag.java 29 Oct 2003 03:31:17 -0000 1.39 *************** *** 32,36 **** import org.htmlparser.Node; import org.htmlparser.scanners.LinkScanner; - import org.htmlparser.util.LinkProcessor; import org.htmlparser.util.ParserUtils; import org.htmlparser.util.SimpleNodeIterator; --- 32,35 ---- *************** *** 307,312 **** relativeLink = ParserUtils.removeChars(relativeLink,'\r'); } ! LinkProcessor processor = ((LinkScanner)getThisScanner ()).processor; ! return (processor.extract(relativeLink,getPage ().getUrl ())); } } --- 306,310 ---- relativeLink = ParserUtils.removeChars(relativeLink,'\r'); } ! return (getPage ().getLinkProcessor ().extract (relativeLink, getPage ().getUrl ())); } } |