Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/tags AppletTag.java,1.31,1.32 BaseHrefTag.java,1.26,1
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1:/tmp/cvs-serv26197/tags Modified Files: AppletTag.java BaseHrefTag.java BodyTag.java Bullet.java BulletList.java CompositeTag.java Div.java DoctypeTag.java FormTag.java FrameSetTag.java FrameTag.java HeadTag.java Html.java ImageTag.java InputTag.java JspTag.java LabelTag.java LinkTag.java MetaTag.java OptionTag.java ScriptTag.java SelectTag.java Span.java StyleTag.java TableColumn.java TableRow.java TableTag.java Tag.java TextareaTag.java TitleTag.java Log Message: Removed lexer level AbstractNode. Removed data package from parser level tags. Separated tag creation from recursion in NodeFactory interface. Index: AppletTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/AppletTag.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** AppletTag.java 18 Oct 2003 20:50:37 -0000 1.31 --- AppletTag.java 20 Oct 2003 01:28:03 -0000 1.32 *************** *** 36,41 **** import org.htmlparser.StringNode; import org.htmlparser.lexer.nodes.Attribute; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; --- 36,39 ---- *************** *** 48,59 **** public class AppletTag extends CompositeTag { ! /** ! * Create a new AppletTag with the dats given. ! * @param tagData The data for this tag. ! * @param compositeTagData The data for this composite tag. ! */ ! public AppletTag (TagData tagData,CompositeTagData compositeTagData) { ! super(tagData,compositeTagData); } --- 46,52 ---- public class AppletTag extends CompositeTag { ! public AppletTag () { ! setTagName ("APPLET"); } Index: BaseHrefTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/BaseHrefTag.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** BaseHrefTag.java 22 Sep 2003 02:40:01 -0000 1.26 --- BaseHrefTag.java 20 Oct 2003 01:28:03 -0000 1.27 *************** *** 30,60 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.TagData; /** ! * @author Somik Raha ! * ! * To change this generated comment edit the template variable "typecomment": ! * Window>Preferences>Java>Templates. ! * To enable and disable the creation of type comments go to ! * Window>Preferences>Java>Code Generation. */ ! public class BaseHrefTag extends Tag { ! private String baseUrl; ! ! public BaseHrefTag(TagData tagData, String baseUrl) { ! super(tagData); ! this.baseUrl = baseUrl; } ! public String getBaseUrl() { ! return baseUrl; } ! public void setBaseUrl(String baseUrl) { ! this.baseUrl = baseUrl; } ! public String toString() { return "BASE TAG\n"+ "--------\n"+ ! "Name : "+baseUrl; } } --- 30,72 ---- package org.htmlparser.tags; ! import org.htmlparser.util.LinkProcessor; /** ! * BaseHrefTag represents an <Base> tag. ! * It extends a basic tag by providing an accessor to the HREF attribute. */ ! public class BaseHrefTag extends Tag ! { ! public BaseHrefTag () ! { ! setTagName ("BASE"); } ! ! /** ! * Get the value of the HREF attribute, if any. ! * @return The HREF value, with the last slash removed, if any. ! */ ! public String getBaseUrl() ! { ! String base; ! ! base = getAttribute ("HREF"); ! if (base != null && base.length() > 0) ! base = LinkProcessor.removeLastSlash (base.trim()); ! base = (null == base) ? "" : base; ! ! return (base); } ! ! public void setBaseUrl (String base) ! { ! setAttribute ("HREF", base); } ! ! public String toString() ! { return "BASE TAG\n"+ "--------\n"+ ! "Name : "+getBaseUrl(); } } Index: BodyTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/BodyTag.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** BodyTag.java 22 Sep 2003 02:40:01 -0000 1.15 --- BodyTag.java 20 Oct 2003 01:28:03 -0000 1.16 *************** *** 29,50 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; - - /** ! * A Body Tag */ public class BodyTag extends CompositeTag { ! public BodyTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData,compositeTagData); } ! public String getBody() { return toPlainTextString(); } ! public String toString() { return "BODY: "+getBody(); } --- 29,50 ---- package org.htmlparser.tags; /** ! * A Body Tag. ! * Primarily a container for child tags. */ public class BodyTag extends CompositeTag { ! public BodyTag () ! { ! setTagName ("BODY"); } ! public String getBody() ! { return toPlainTextString(); } ! public String toString() ! { return "BODY: "+getBody(); } Index: Bullet.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Bullet.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Bullet.java 22 Sep 2003 02:40:01 -0000 1.15 --- Bullet.java 20 Oct 2003 01:28:03 -0000 1.16 *************** *** 29,41 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! ! public class Bullet extends CompositeTag { ! public Bullet(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); } - } --- 29,40 ---- package org.htmlparser.tags; ! /** ! * A bullet tag. ! */ public class Bullet extends CompositeTag { ! public Bullet () ! { ! setTagName ("LI"); } } Index: BulletList.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/BulletList.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** BulletList.java 22 Sep 2003 02:40:01 -0000 1.15 --- BulletList.java 20 Oct 2003 01:28:03 -0000 1.16 *************** *** 29,51 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; - /** ! * @author Somik Raha ! * ! * To change the template for this generated type comment go to ! * Window>Preferences>Java>Code Generation>Code and Comments */ public class BulletList extends CompositeTag { ! public BulletList(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); ! } ! ! public String toString() { ! // TODO Auto-generated method stub ! return "BulletList"; } - } --- 29,41 ---- package org.htmlparser.tags; /** ! * A bullet list tag. ! * Either <UL> or <OL>. */ public class BulletList extends CompositeTag { ! public BulletList () ! { ! setTagName ("UL"); // could be "OL" too } } Index: CompositeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** CompositeTag.java 3 Oct 2003 02:15:19 -0000 1.58 --- CompositeTag.java 20 Oct 2003 01:28:03 -0000 1.59 *************** *** 29,63 **** package org.htmlparser.tags; import org.htmlparser.*; import org.htmlparser.AbstractNode; import org.htmlparser.lexer.nodes.TagNode; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; import org.htmlparser.visitors.NodeVisitor; public abstract class CompositeTag extends Tag { protected TagNode startTag; protected TagNode endTag; ! public CompositeTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData); ! ! // from Tag(TagData) ! // super(tagData.getTagBegin(),tagData.getTagEnd()); ! // this.startLine = tagData.getStartLine(); ! // this.tagContents = new StringBuffer(); ! // this.tagContents.append(tagData.getTagContents()); ! // this.tagLine = tagData.getTagLine(); ! // this.tagLines = new String[] {tagData.getTagLine()}; ! // this.emptyXmlTag = tagData.isEmptyXmlTag(); ! ! ! startTag = compositeTagData.getStartTag(); ! endTag = compositeTagData.getEndTag(); ! setChildren (compositeTagData.getChildren()); } ! /** * Get an iterator over the children of this node. --- 29,55 ---- package org.htmlparser.tags; + import java.util.Vector; import org.htmlparser.*; import org.htmlparser.AbstractNode; + import org.htmlparser.lexer.Page; import org.htmlparser.lexer.nodes.TagNode; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; import org.htmlparser.visitors.NodeVisitor; + /* + * The base class for tags that have an end tag. + * Provided extra accessors for the children above and beyond what the basic + * {@link Tag} provides. Also handles the conversion of it's children for + * the {@link #toHtml toHtml} method. + */ public abstract class CompositeTag extends Tag { protected TagNode startTag; protected TagNode endTag; ! public CompositeTag () ! { } ! /** * Get an iterator over the children of this node. *************** *** 344,353 **** } ! public TagNode getStartTag() { return startTag; } ! public TagNode getEndTag() { return endTag; } --- 336,357 ---- } ! public TagNode getStartTag() ! { return startTag; } ! public void setStartTag (TagNode start) ! { ! startTag = start; ! } ! ! public TagNode getEndTag() ! { return endTag; + } + + public void setEndTag(TagNode end) + { + endTag = end; } Index: Div.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Div.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Div.java 22 Sep 2003 02:40:01 -0000 1.15 --- Div.java 20 Oct 2003 01:28:03 -0000 1.16 *************** *** 29,40 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! ! public class Div extends CompositeTag { ! ! public Div(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); } - } --- 29,40 ---- package org.htmlparser.tags; ! /** ! * A div tag. ! */ ! public class Div extends CompositeTag ! { ! public Div () ! { ! setTagName ("DIV"); } } Index: DoctypeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/DoctypeTag.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** DoctypeTag.java 28 Sep 2003 15:33:58 -0000 1.29 --- DoctypeTag.java 20 Oct 2003 01:28:03 -0000 1.30 *************** *** 30,35 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.TagData; - /** * The HTML Document Declaration Tag can identify <!DOCTYPE> tags. --- 30,33 ---- *************** *** 37,58 **** public class DoctypeTag extends Tag { ! /** ! * The HTMLDoctypeTag is constructed by providing the beginning posn, ending posn ! * and the tag contents. ! * @param tagData The data for this tag. ! */ ! public DoctypeTag(TagData tagData) { ! super(tagData); } /** ! * Print the contents of the remark tag. */ public String toString() { ! return "Doctype Tag : "+getTagContents()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); ! } ! public String toHtml() { ! return "<!DOCTYPE "+getTagContents()+">"; } } --- 35,51 ---- public class DoctypeTag extends Tag { ! public DoctypeTag () { ! setTagName ("!DOCTYPE"); } + /** ! * Print the contents of the document declaration tag. */ public String toString() { ! String guts = toHtml(); ! guts = guts.substring (1, guts.length () - 2); ! return "Doctype Tag : "+guts+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } Index: FormTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/FormTag.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** FormTag.java 22 Sep 2003 02:40:01 -0000 1.34 --- FormTag.java 20 Oct 2003 01:28:03 -0000 1.35 *************** *** 30,48 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; /** - * @author ili - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ - /** * Represents a FORM tag. */ public class FormTag extends CompositeTag --- 30,39 ---- package org.htmlparser.tags; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; /** * Represents a FORM tag. + * @author ili */ public class FormTag extends CompositeTag *************** *** 50,73 **** public static final String POST="POST"; public static final String GET="GET"; - protected String formURL; - protected String formName; - protected String formMethod; - protected NodeList formInputList; - private NodeList textAreaList; ! /** ! * Constructor takes in tagData, compositeTagData, formTagData ! * @param tagData ! * @param compositeTagData ! */ ! public FormTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData,compositeTagData); ! ! this.formURL = compositeTagData.getStartTag().getAttribute("ACTION"); ! this.formName = compositeTagData.getStartTag().getAttribute("NAME"); ! this.formMethod = compositeTagData.getStartTag().getAttribute("METHOD"); ! this.formInputList = compositeTagData.getChildren().searchFor(InputTag.class, true); ! this.textAreaList = compositeTagData.getChildren().searchFor(TextareaTag.class, true); } --- 41,48 ---- public static final String POST="POST"; public static final String GET="GET"; ! public FormTag () { ! setTagName ("FORM"); } *************** *** 78,111 **** public NodeList getFormInputs() { ! return formInputList; } /** * Get the list of text areas. ! * @return Textarea elements in the form */ public NodeList getFormTextareas() { ! return textAreaList; } /** ! * @return String The url of the form */ public String getFormLocation() { ! return formURL; } /** ! * Returns the method of the form ! * @return String The method of the form (GET if nothing is specified) */ ! public String getFormMethod() { ! if(formMethod==null) ! { ! formMethod = "GET"; ! } ! return formMethod; } --- 53,100 ---- public NodeList getFormInputs() { ! return (getChildren().searchFor(InputTag.class, true)); } /** * Get the list of text areas. ! * @return Textarea elements in the form. */ public NodeList getFormTextareas() { ! return (getChildren().searchFor(TextareaTag.class, true)); } /** ! * Get the value of the action attribute. ! * @return The submit url of the form. */ public String getFormLocation() { ! return (getAttribute("ACTION")); } /** ! * Set the form location. Modification of this element will cause the HTML rendering ! * to change as well (in a call to toHTML()). ! * @param url The new FORM location */ ! public void setFormLocation(String url) ! { ! setAttribute ("ACTION", url); ! } ! ! /** ! * Returns the method of the form, GET or POST. ! * @return String The method of the form (GET if nothing is specified). ! */ ! public String getFormMethod() ! { ! String ret; ! ! ret = getAttribute("METHOD"); ! if (null == ret) ! ret = GET; ! ! return (ret); } *************** *** 115,154 **** * @return Tag The input tag corresponding to the name provided */ ! public InputTag getInputTag(String name) { ! InputTag inputTag=null; ! boolean found=false; ! for (SimpleNodeIterator e = formInputList.elements();e.hasMoreNodes() && !found;) { inputTag = (InputTag)e.nextNode(); ! String inputTagName = inputTag.getAttribute("NAME"); ! if (inputTagName!=null && inputTagName.equalsIgnoreCase(name)) { found=true; - } } if (found) ! return inputTag; else return null; } /** * @return String The name of the form */ ! public String getFormName() { ! return formName; ! } ! ! /** ! * Set the form location. Modification of this element will cause the HTML rendering ! * to change as well (in a call to toHTML()). ! * @param formURL The new FORM location ! */ ! public void setFormLocation(String formURL) { ! setAttribute ("ACTION", formURL); ! this.formURL = formURL; ! } ! ! /** ! * @return String The contents of the FormTag ! */ ! public String toString() { ! return "FORM TAG : Form at "+formURL+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } --- 104,135 ---- * @return Tag The input tag corresponding to the name provided */ ! public InputTag getInputTag (String name) ! { ! InputTag inputTag; ! boolean found; ! String inputTagName; ! ! inputTag = null; ! found = false; ! for (SimpleNodeIterator e = getFormInputs().elements();e.hasMoreNodes() && !found;) ! { inputTag = (InputTag)e.nextNode(); ! inputTagName = inputTag.getAttribute("NAME"); ! if (inputTagName!=null && inputTagName.equalsIgnoreCase(name)) found=true; } if (found) ! return (inputTag); ! else ! return (null); } /** + * Get the value of the name attribute. * @return String The name of the form */ ! public String getFormName() ! { ! return (getAttribute("NAME")); } *************** *** 157,175 **** * @param name Name of the textarea tag to be found within the form */ ! public TextareaTag getTextAreaTag(String name) { TextareaTag textareaTag=null; boolean found = false; ! for (SimpleNodeIterator e=textAreaList.elements();e.hasMoreNodes() && !found;) { textareaTag = (TextareaTag)e.nextNode(); String textAreaName = textareaTag.getAttribute("NAME"); ! if (textAreaName!=null && textAreaName.equals(name)) { found = true; - } } if (found) ! return textareaTag; else ! return null; } } --- 138,164 ---- * @param name Name of the textarea tag to be found within the form */ ! public TextareaTag getTextAreaTag(String name) ! { TextareaTag textareaTag=null; boolean found = false; ! for (SimpleNodeIterator e=getFormTextareas ().elements();e.hasMoreNodes() && !found;) ! { textareaTag = (TextareaTag)e.nextNode(); String textAreaName = textareaTag.getAttribute("NAME"); ! if (textAreaName!=null && textAreaName.equals(name)) found = true; } if (found) ! return (textareaTag); else ! return (null); } + /** + * @return A textual representation of the form tag. + */ + public String toString() + { + return "FORM TAG : Form at "+getFormLocation()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); + } } Index: FrameSetTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/FrameSetTag.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** FrameSetTag.java 3 Oct 2003 02:15:20 -0000 1.27 --- FrameSetTag.java 20 Oct 2003 01:28:03 -0000 1.28 *************** *** 30,85 **** import org.htmlparser.Node; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; /** ! * Identifies an frame tag */ public class FrameSetTag extends CompositeTag { ! /** ! * The URL where the image is stored. ! */ ! protected String frameURL; ! protected String frameName; ! protected NodeList frames; ! public FrameSetTag(TagData tagData,CompositeTagData compositeTagData) { ! super(tagData,compositeTagData); ! this.frames = compositeTagData.getChildren(); } /** ! * Returns the location of the frame */ ! public String getFrameLocation() { ! return frameURL; ! } ! ! public String getFrameName() { ! return frameName; } /** ! * Print the contents of the HTMLImageNode */ ! public String toString() { ! return "FRAME TAG : Image at "+frameURL+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } /** ! * Returns the frames. ! * @return Vector */ ! public NodeList getFrames() { ! return frames; ! } ! ! public FrameTag getFrame(String frameName) { ! boolean found = false; Node node; ! FrameTag frameTag=null; ! for (SimpleNodeIterator e=frames.elements();e.hasMoreNodes() && !found;) { node = e.nextNode(); --- 30,78 ---- import org.htmlparser.Node; import org.htmlparser.util.NodeList; import org.htmlparser.util.SimpleNodeIterator; /** ! * Identifies an frame set tag. */ public class FrameSetTag extends CompositeTag { ! public FrameSetTag () ! { ! setTagName ("FRAMESET"); } /** ! * Print the contents of the FrameSetTag */ ! public String toString() ! { ! return "FRAMESET TAG : begins at : "+elementBegin()+"; ends at : "+elementEnd(); } /** ! * Returns the frames. ! * @return The children of this tag. */ ! public NodeList getFrames() ! { ! return (getChildren()); } /** ! * Gets a frame by name. ! * @param ! * @return The specified frame or <code>null</code> if it wasn't found. */ ! public FrameTag getFrame(String name) ! { ! boolean found; Node node; ! FrameTag frameTag; ! ! found = false; ! name = name.toUpperCase (); ! frameTag = null; ! for (SimpleNodeIterator e=getFrames().elements();e.hasMoreNodes() && !found;) { node = e.nextNode(); *************** *** 87,103 **** { frameTag = (FrameTag)node; ! if (frameTag.getFrameName().toUpperCase().equals(frameName.toUpperCase())) found = true; } } if (found) ! return frameTag; else return null; } /** ! * Sets the frames. * @param frames The frames to set */ ! public void setFrames(NodeList frames) { ! this.frames = frames; } } --- 80,100 ---- { frameTag = (FrameTag)node; ! if (frameTag.getFrameName().toUpperCase().equals(name)) found = true; } } if (found) ! return (frameTag); ! else ! return (null); } + /** ! * Sets the frames (children of this tag). * @param frames The frames to set */ ! public void setFrames(NodeList frames) ! { ! setChildren (frames); } } Index: FrameTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/FrameTag.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** FrameTag.java 22 Sep 2003 02:40:01 -0000 1.26 --- FrameTag.java 20 Oct 2003 01:28:03 -0000 1.27 *************** *** 29,63 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.TagData; /** ! * Identifies an frame tag */ public class FrameTag extends Tag { ! /** ! * The URL where the image is stored. ! */ ! protected String frameURL; ! protected String frameName; ! public FrameTag(TagData tagData, String frameURL,String frameName) { ! super(tagData); ! this.frameURL = frameURL; ! this.frameName = frameName; } /** ! * Returns the location of the image */ ! public String getFrameLocation() { ! return frameURL; } ! public String getFrameName() { ! return frameName; } /** ! * Print the contents of the HTMLFrameTag */ ! public String toString() { ! return "FRAME TAG : Image at "+frameURL+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } --- 29,68 ---- package org.htmlparser.tags; ! import org.htmlparser.util.LinkProcessor; /** ! * Identifies a frame tag */ public class FrameTag extends Tag { ! public FrameTag () ! { ! setTagName ("FRAME"); } + /** ! * Returns the location of the frames. ! * TODO: handle base url? */ ! public String getFrameLocation() ! { ! String relativeFrame = getAttribute ("SRC"); ! if (relativeFrame==null) ! return ""; ! else ! return (new LinkProcessor()).extract(relativeFrame, getPage ().getUrl ()); } ! ! public String getFrameName() ! { ! return (getAttribute ("NAME")); } + /** ! * Print the contents of the FrameTag. */ ! public String toString() ! { ! return "FRAME TAG : Frame " +getFrameName() + " at "+getFrameLocation()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } Index: HeadTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/HeadTag.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** HeadTag.java 22 Sep 2003 02:40:01 -0000 1.15 --- HeadTag.java 20 Oct 2003 01:28:03 -0000 1.16 *************** *** 32,45 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! ! public class HeadTag extends CompositeTag { ! public HeadTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); } ! public String toString() { return "HEAD: " + super.toString(); } --- 32,48 ---- package org.htmlparser.tags; ! /** ! * A head tag. ! */ ! public class HeadTag extends CompositeTag ! { ! public HeadTag () ! { ! setTagName ("HEAD"); } ! public String toString() ! { return "HEAD: " + super.toString(); } Index: Html.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Html.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Html.java 22 Sep 2003 02:40:01 -0000 1.27 --- Html.java 20 Oct 2003 01:28:03 -0000 1.28 *************** *** 29,40 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! ! public class Html extends CompositeTag { ! public Html(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); } - } --- 29,41 ---- package org.htmlparser.tags; ! /** ! * A html tag. ! */ ! public class Html extends CompositeTag ! { ! public Html () ! { ! setTagName ("HTML"); } } Index: ImageTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ImageTag.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ImageTag.java 28 Sep 2003 19:30:04 -0000 1.29 --- ImageTag.java 20 Oct 2003 01:28:03 -0000 1.30 *************** *** 29,58 **** package org.htmlparser.tags; import org.htmlparser.lexer.nodes.TagNode; ! import org.htmlparser.tags.data.TagData; import org.htmlparser.visitors.NodeVisitor; /** ! * Identifies an image tag */ public class ImageTag extends Tag { public static final String IMAGE_TAG_FILTER="-i"; /** ! * The URL where the image is stored. */ protected String imageURL; /** ! * Constructor creates an HTMLImageNode object, which stores the location ! * where the image is to be found. ! * @param tagData Specifies character position and content of the tag. ! * @param imageURL Location of the image. ! */ ! public ImageTag(TagData tagData,String imageURL) { ! super(tagData); ! this.imageURL = imageURL; } /** * Returns the location of the image --- 29,164 ---- package org.htmlparser.tags; + import java.util.Vector; + import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.lexer.nodes.TagNode; ! import org.htmlparser.util.ParserException; ! import org.htmlparser.util.ParserUtils; import org.htmlparser.visitors.NodeVisitor; /** ! * Identifies an image tag. */ public class ImageTag extends Tag { public static final String IMAGE_TAG_FILTER="-i"; + /** ! * Holds the set value of the SRC attribute, since this can differ ! * from the attribute value due to relative references resolved by ! * the scanner. */ protected String imageURL; + public ImageTag () + { + setTagName ("IMG"); + imageURL = null; + } + /** ! * Extract the location of the image ! * Given the tag (with attributes), and the url of the html page in which ! * this tag exists, perform best effort to extract the 'intended' URL. ! * Attempts to handle such attributes as: ! * <pre> ! * <IMG SRC=http://www.redgreen.com> - normal ! * <IMG SRC =http://www.redgreen.com> - space between attribute name and equals sign ! * <IMG SRC= http://www.redgreen.com> - space between equals sign and attribute value ! * <IMG SRC = http://www.redgreen.com> - space both sides of equals sign ! * </pre> ! * @param tag The tag with the 'SRC' attribute. ! * @param url URL of web page being parsed. ! */ ! public String extractImageLocn () { ! Vector attributes; ! int size; ! Attribute attribute; ! String string; ! String data; ! int state; ! String name; ! String ret; ! ! // TODO: move this logic into the lexer? ! ! ret = ""; ! state = 0; ! attributes = getAttributesEx (); ! size = attributes.size (); ! for (int i = 0; (i < size) && (state < 3); i++) ! { ! attribute = (Attribute)attributes.elementAt (i); ! string = attribute.getName (); ! data = attribute.getValue (); ! switch (state) ! { ! case 0: // looking for 'src' ! if (null != string) ! { ! name = string.toUpperCase (); ! if (name.equals ("SRC")) ! { ! state = 1; ! if (null != data) ! { ! if ("".equals (data)) ! state = 2; // empty attribute, SRC= ! else ! { ! ret = data; ! i = size; // exit fast ! } ! } ! ! } ! else if (name.startsWith ("SRC")) ! { ! // missing equals sign ! ret = string.substring (3); ! state = 0; // go back to searching for SRC ! // because, maybe we found SRCXXX ! // where XXX isn't a URL ! } ! } ! break; ! case 1: // looking for equals sign ! if (null != string) ! { ! if (string.startsWith ("=")) ! { ! state = 2; ! if (1 < string.length ()) ! { ! ret = string.substring (1); ! state = 0; // keep looking ? ! } ! else if (null != data) ! { ! ret = string.substring (1); ! state = 0; // keep looking ? ! } ! } ! } ! break; ! case 2: // looking for a valueless attribute that could be a relative or absolute URL ! if (null != string) ! { ! if (null == data) ! ret = string; ! state = 0; // only check first non-whitespace item ! // not every valid attribute after an equals ! } ! break; ! default: ! throw new IllegalStateException ("we're not supposed to in state " + state); ! } ! } ! ret = ParserUtils.removeChars (ret, '\n'); ! ret = ParserUtils.removeChars (ret, '\r'); ! ! return (ret); } + /** * Returns the location of the image *************** *** 60,72 **** public String getImageURL() { ! return imageURL; } public String toString() { ! return "IMAGE TAG : Image at "+imageURL+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } ! public void setImageURL(String imageURL) { ! this.imageURL = imageURL; setAttribute ("SRC", imageURL); } --- 166,182 ---- public String getImageURL() { ! if (null == imageURL) ! imageURL = extractImageLocn (); ! return (imageURL); } + public String toString() { ! return "IMAGE TAG : Image at " + getImageURL () +"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } ! public void setImageURL (String url) ! { ! imageURL = url; setAttribute ("SRC", imageURL); } Index: InputTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/InputTag.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** InputTag.java 22 Sep 2003 02:40:01 -0000 1.27 --- InputTag.java 20 Oct 2003 01:28:03 -0000 1.28 *************** *** 29,39 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.TagData; import org.htmlparser.util.ParserUtils; public class InputTag extends Tag { ! public InputTag(TagData tagData) { ! super(tagData); } --- 29,42 ---- package org.htmlparser.tags; import org.htmlparser.util.ParserUtils; + /** + * An input tag in a form. + */ public class InputTag extends Tag { ! public InputTag () ! { ! setTagName ("INPUT"); } Index: JspTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/JspTag.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** JspTag.java 6 Oct 2003 01:43:28 -0000 1.31 --- JspTag.java 20 Oct 2003 01:28:03 -0000 1.32 *************** *** 29,33 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.TagData; /** --- 29,34 ---- package org.htmlparser.tags; ! import org.htmlparser.Node; ! import org.htmlparser.util.SimpleNodeIterator; /** *************** *** 36,59 **** public class JspTag extends Tag { ! /** ! * The JspTag is constructed by providing the beginning posn, ending posn ! * and the tag contents. ! * @param tagData The data for this tag. ! */ ! public JspTag(TagData tagData) { ! super(tagData); ! } ! ! public String toHtml() { ! return "<"+getTagContents()+">"; } /** ! * Print the contents of the remark tag. */ public String toString() { ! return "JSP/ASP Tag : "+getTagContents()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } --- 37,53 ---- public class JspTag extends Tag { ! public JspTag () { ! setTagName ("%"); } /** ! * Print the contents of the jsp tag. */ public String toString() { ! String guts = toHtml(); ! guts = guts.substring (1, guts.length () - 2); ! return "JSP/ASP Tag : "+guts+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } Index: LabelTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/LabelTag.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** LabelTag.java 22 Sep 2003 02:40:01 -0000 1.28 --- LabelTag.java 20 Oct 2003 01:28:03 -0000 1.29 *************** *** 32,49 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! ! public class LabelTag extends CompositeTag { ! ! public LabelTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); } ! public String getLabel() { return toPlainTextString(); } ! public String toString() { return "LABEL: "+getLabel(); } --- 32,52 ---- package org.htmlparser.tags; ! /** ! * A label tag. ! */ ! public class LabelTag extends CompositeTag ! { ! public LabelTag () ! { ! setTagName ("LABEL"); } ! public String getLabel() ! { return toPlainTextString(); } ! public String toString() ! { return "LABEL: "+getLabel(); } Index: LinkTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/LinkTag.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** LinkTag.java 28 Sep 2003 19:30:04 -0000 1.36 --- LinkTag.java 20 Oct 2003 01:28:03 -0000 1.37 *************** *** 31,41 **** import org.htmlparser.Node; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.LinkData; ! import org.htmlparser.tags.data.TagData; import org.htmlparser.util.SimpleNodeIterator; import org.htmlparser.visitors.NodeVisitor; /** ! * Identifies a link tag */ public class LinkTag extends CompositeTag --- 31,42 ---- import org.htmlparser.Node; ! import org.htmlparser.scanners.LinkScanner; ! import org.htmlparser.util.LinkProcessor; ! import org.htmlparser.util.ParserUtils; import org.htmlparser.util.SimpleNodeIterator; import org.htmlparser.visitors.NodeVisitor; + /** ! * Identifies a link tag. */ public class LinkTag extends CompositeTag *************** *** 45,63 **** * The URL where the link points to */ ! protected String link; /** ! * The text of of the link element */ ! protected String linkText; /** ! * The accesskey existing inside this link. */ - protected String accessKey; - private boolean mailLink; private boolean javascriptLink; - /** ! * Constructor creates an HTMLLinkNode object, which basically stores the location * where the link points to, and the text it contains. * <p> --- 46,63 ---- * The URL where the link points to */ ! protected String mLink; ! /** ! * Set to true when the link was a mailto: URL. */ ! private boolean mailLink; ! /** ! * Set to true when the link was a javascript: URL. */ private boolean javascriptLink; /** ! * Constructor creates an LinkNode object, which basically stores the location * where the link points to, and the text it contains. * <p> *************** *** 77,82 **** * } * </pre> ! * There is another mechanism available that allows for uniform extraction of images. You could do this to ! * get all images from a web page : * <pre> * Node node; --- 77,82 ---- * } * </pre> ! * There is another mechanism available that allows for uniform extraction ! * of images. You could do this to get all images from a web page : * <pre> * Node node; *************** *** 88,118 **** * </pre> * The link tag processes all its contents in collectInto(). - * @param tagData The data relating to the tag. - * @param compositeTagData The data regarding the composite structure of the tag. - * @param linkData The data specific to the link tag. * @see #linkData() */ ! public LinkTag(TagData tagData,CompositeTagData compositeTagData,LinkData linkData) { ! super(tagData,compositeTagData); ! this.link = linkData.getLink(); ! this.linkText = linkData.getLinkText(); ! this.accessKey = linkData.getAccessKey(); ! this.mailLink = linkData.isMailLink(); ! this.javascriptLink = linkData.isJavascriptLink(); } /** ! * Returns the accesskey element if any inside this link tag ! */ public String getAccessKey() { ! return accessKey; } /** ! * Returns the url as a string, to which this link points */ public String getLink() { ! return link; } /** * Returns the text contained inside this link tag --- 88,138 ---- * </pre> * The link tag processes all its contents in collectInto(). * @see #linkData() */ ! public LinkTag () ! { ! setTagName ("A"); } + /** ! * Returns the accesskey attribute value, if any. ! */ public String getAccessKey() { ! return (getAttribute("ACCESSKEY")); } + /** ! * Returns the url as a string, to which this link points. ! * This string has had the "mailto:" and "javascript:" protocol stripped ! * off the front (if those predicates return <code>true</code>) but not ! * for other protocols. Don't ask me why, it's a legacy thing. */ public String getLink() { ! if (null == mLink) ! { ! mailLink=false; ! javascriptLink = false; ! mLink = extractLink (); ! ! int mailto = mLink.indexOf("mailto"); ! if (mailto==0) ! { ! // yes it is ! mailto = mLink.indexOf(":"); ! mLink = mLink.substring(mailto+1); ! mailLink = true; ! } ! int javascript = mLink.indexOf("javascript:"); ! if (javascript == 0) ! { ! mLink = mLink.substring(11); // this magic number is "javascript:".length() ! javascriptLink = true; ! } ! } ! return (mLink); } + /** * Returns the text contained inside this link tag *************** *** 120,125 **** public String getLinkText() { ! return linkText; } /** * Return the text contained in this linkinode --- 140,146 ---- public String getLinkText() { ! return (getChildren().toString()); } + /** * Return the text contained in this linkinode *************** *** 130,139 **** return toHtml(); } /** * Is this a mail address * @return boolean true/false */ ! public boolean isMailLink() { ! return mailLink; } --- 151,163 ---- return toHtml(); } + /** * Is this a mail address * @return boolean true/false */ ! public boolean isMailLink() ! { ! getLink (); // force an evaluation of the booleans ! return (mailLink); } *************** *** 142,147 **** * @return flag indicating if the link is a javascript code */ ! public boolean isJavascriptLink() { ! return javascriptLink; } --- 166,173 ---- * @return flag indicating if the link is a javascript code */ ! public boolean isJavascriptLink() ! { ! getLink (); // force an evaluation of the booleans ! return (javascriptLink); } *************** *** 152,156 **** */ public boolean isFTPLink() { ! return link.indexOf("ftp://")==0; } --- 178,182 ---- */ public boolean isFTPLink() { ! return getLink ().indexOf("ftp://")==0; } *************** *** 160,164 **** */ public boolean isIRCLink() { ! return link.indexOf("irc://")==0; } --- 186,190 ---- */ public boolean isIRCLink() { ! return getLink ().indexOf("irc://")==0; } *************** *** 178,184 **** * @return flag indicating if this link is an HTTPS link */ ! public boolean isHTTPSLink() { ! return link.indexOf("https://")==0; ! } /** --- 204,210 ---- * @return flag indicating if this link is an HTTPS link */ ! public boolean isHTTPSLink() { ! return getLink ().indexOf("https://")==0; ! } /** *************** *** 187,193 **** * @return flag indicating if this link is an HTTP link or one of its variations (HTTPS, etc.) */ ! public boolean isHTTPLikeLink() { ! return isHTTPLink() || isHTTPSLink(); ! } --- 213,219 ---- * @return flag indicating if this link is an HTTP link or one of its variations (HTTPS, etc.) */ ! public boolean isHTTPLikeLink() { ! return isHTTPLink() || isHTTPSLink(); ! } *************** *** 197,201 **** * @param newMailLink boolean */ ! public void setMailLink(boolean newMailLink) { mailLink = newMailLink; } --- 223,228 ---- * @param newMailLink boolean */ ! public void setMailLink(boolean newMailLink) ! { mailLink = newMailLink; } *************** *** 206,210 **** * @param newJavascriptLink flag indicating if the link is a javascript code */ ! public void setJavascriptLink(boolean newJavascriptLink) { javascriptLink = newJavascriptLink; } --- 233,238 ---- * @param newJavascriptLink flag indicating if the link is a javascript code */ ! public void setJavascriptLink(boolean newJavascriptLink) ! { javascriptLink = newJavascriptLink; } *************** *** 216,222 **** { StringBuffer sb = new StringBuffer(); ! sb.append("Link to : "+link + "; titled : "+linkText+"; begins at : "+elementBegin()+"; ends at : "+elementEnd()+ ", AccessKey="); ! if (accessKey==null) sb.append("null\n"); ! else sb.append(accessKey+"\n"); if (children()!=null) { --- 244,252 ---- { StringBuffer sb = new StringBuffer(); ! sb.append("Link to : "+ getLink() + "; titled : "+getLinkText ()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd()+ ", AccessKey="); ! if (getAccessKey ()==null) ! sb.append("null\n"); ! else ! sb.append(getAccessKey ()+"\n"); if (children()!=null) { *************** *** 237,242 **** } ! public void setLink(String link) { ! this.link = link; setAttribute ("HREF", link); } --- 267,273 ---- } ! public void setLink(String link) ! { ! mLink = link; setAttribute ("HREF", link); } *************** *** 262,265 **** --- 293,312 ---- visitor.visitLinkTag (this); super.accept (visitor); + } + + /** + * Extract the link from the HREF attribute. + * The URL of the actual html page is also provided. + */ + public String extractLink () + { + String relativeLink = getAttribute ("HREF"); + if (relativeLink!=null) + { + relativeLink = ParserUtils.removeChars(relativeLink,'\n'); + relativeLink = ParserUtils.removeChars(relativeLink,'\r'); + } + LinkProcessor processor = ((LinkScanner)getThisScanner ()).processor; + return (processor.extract(relativeLink,getPage ().getUrl ())); } } Index: MetaTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/MetaTag.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** MetaTag.java 22 Sep 2003 02:40:01 -0000 1.27 --- MetaTag.java 20 Oct 2003 01:28:03 -0000 1.28 *************** *** 29,71 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.TagData; /** * A Meta Tag */ ! public class MetaTag extends Tag { ! private String metaTagName; ! private String metaTagContents; ! private String httpEquiv; ! public MetaTag(TagData tagData, String httpEquiv, String metaTagName,String metaTagContents) { ! super(tagData); ! this.httpEquiv = httpEquiv; ! this.metaTagName = metaTagName; ! this.metaTagContents = metaTagContents; } ! public String getHttpEquiv() { ! return httpEquiv; } ! public String getMetaContent() { ! return metaTagContents; } ! public String getMetaTagName() { ! return metaTagName; } ! public void setHttpEquiv(String httpEquiv) { ! this.httpEquiv = httpEquiv; } ! public void setMetaTagContents(String metaTagContents) { ! this.metaTagContents = metaTagContents; } ! public void setMetaTagName(String metaTagName) { ! this.metaTagName = metaTagName; } ! public String toString() { return "META TAG\n"+ "--------\n"+ "Http-Equiv : "+getHttpEquiv()+"\n"+ ! "Name : "+metaTagName+"\n"+ ! "Contents : "+metaTagContents+"\n"; } } --- 29,97 ---- package org.htmlparser.tags; ! import org.htmlparser.lexer.nodes.Attribute; /** * A Meta Tag */ ! public class MetaTag extends Tag ! { ! ! public MetaTag () ! { ! setTagName ("META"); } ! ! public String getHttpEquiv () ! { ! return (getAttribute ("HTTP-EQUIV")); } ! ! public String getMetaContent () ! { ! return (getAttribute ("CONTENT")); } ! ! public String getMetaTagName () ! { ! return (getAttribute ("NAME")); } ! ! public void setHttpEquiv(String httpEquiv) ! { ! Attribute equiv; ! equiv = getAttributeEx ("HTTP-EQUIV"); ! if (null != equiv) ! equiv.setValue (httpEquiv); ! else ! getAttributesEx ().add (new Attribute ("HTTP-EQUIV", httpEquiv)); } ! ! public void setMetaTagContents(String metaTagContents) ! { ! Attribute content; ! content = getAttributeEx ("CONTENT"); ! if (null != content) ! content.setValue (metaTagContents); ! else ! getAttributesEx ().add (new Attribute ("CONTENT", metaTagContents)); } ! ! public void setMetaTagName(String metaTagName) ! { ! Attribute name; ! name = getAttributeEx ("NAME"); ! if (null != name) ! name.setValue (metaTagName); ! else ! getAttributesEx ().add (new Attribute ("NAME", metaTagName)); } ! ! public String toString() ! { return "META TAG\n"+ "--------\n"+ "Http-Equiv : "+getHttpEquiv()+"\n"+ ! "Name : "+ getMetaTagName() +"\n"+ ! "Contents : "+getMetaContent()+"\n"; } } Index: OptionTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/OptionTag.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** OptionTag.java 22 Sep 2003 02:40:01 -0000 1.30 --- OptionTag.java 20 Oct 2003 01:28:03 -0000 1.31 *************** *** 29,60 **** package org.htmlparser.tags; ! import org.htmlparser.tags.data.CompositeTagData; ! import org.htmlparser.tags.data.TagData; ! public class OptionTag extends CompositeTag { ! private String value; ! ! public OptionTag(TagData tagData, CompositeTagData compositeTagData) { ! super(tagData, compositeTagData); ! this.value = (String)this.getAttribute("VALUE"); } ! public String getValue() { ! return this.value; } ! public void setValue(String value) { ! this.value = value; this.setAttribute("VALUE",value); } ! public String getOptionText() { return toPlainTextString(); } ! public String toString() { ! String output = "OPTION VALUE: " + value + " TEXT: "+getOptionText()+"\n"; return output; } --- 29,69 ---- package org.htmlparser.tags; ! /** ! * An option tag within a form. ! */ public class OptionTag extends CompositeTag { ! public OptionTag () { ! setTagName ("OPTION"); } ! /** ! * Get the value of the value attribute. ! */ ! public String getValue() ! { ! return (getAttribute("VALUE")); } ! /** ! * Set the value of the value attribute. ! */ ! public void setValue(String value) ! { this.setAttribute("VALUE",value); } ! /** ! * Get the text of this optin. ! */ ! public String getOptionText() ! { return toPlainTextString(); } ! public String toString() ! { ! String output = "OPTION VALUE: " + getValue() + " TEXT: " + getOptionText()+"\n"; return output; } Index: ScriptTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ScriptTag.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ScriptTag.java 22 Sep 2003 02:40:01 -0000 1.28 --- ScriptTag.java 20 Oct 2003 01:28:03 -0000 1.29 *************** *** 29,84 **** package org.htmlparser.tags; - import org.htmlparser.tags.data.CompositeTagData; - import org.htmlparser.tags.data.TagData; - /** ! * A HTMLScriptTag represents a JavaScript node */ ! public class ScriptTag extends CompositeTag { ! private java.lang.String language; ! private java.lang.String type; ! private String scriptCode; /** ! * The HTMLScriptTag is constructed by providing the beginning posn, ending posn ! * and the tag contents. ! * @param tagData The data for this tag. ! * @param compositeTagData The data for this composite tag. */ ! public ScriptTag(TagData tagData,CompositeTagData compositeTagData) { ! super(tagData,compositeTagData); ! this.scriptCode = getChildrenHTML(); ! this.language = getAttribute("LANGUAGE"); ! this.type = getAttribute("TYPE"); } ! public java.lang.String getLanguage() { ! return language; } ! public java.lang.String getScriptCode() { ! return scriptCode; } - public java.lang.String getType() { - return type; - } /** ! * Set the language of the javascript tag ! * @param newLanguage java.lang.String */ ! public void setLanguage(java.lang.String newLanguage) { ! language = newLanguage; } /** ! * Set the type of the javascript node ! * @param newType java.lang.String */ ! public void setType(java.lang.String newType) { ! type = newType; } /** ! * Print the contents of the javascript node */ public String toString() --- 29,86 ---- package org.htmlparser.tags; /** ! * A script tag. */ ! public class ScriptTag extends CompositeTag ! { ! public ScriptTag () ! { ! setTagName ("SCRIPT"); ! } ! /** ! * Get the language attribute value. */ ! public String getLanguage() { ! return (getAttribute("LANGUAGE")); } ! /** ! * Get the contents of the tag's children. ! */ ! public String getScriptCode() ! { ! return (getChildrenHTML ()); } ! /** ! * Get the type attribute value. ! */ ! public String getType() ! { ! return (getAttribute("TYPE")); } /** ! * Set the language of the script tag. ! * @param language The new language value. */ ! public void setLanguage (String language) ! { ! setAttribute ("LANGUAGE", language); } + /** ! * Set the type of the script tag. ! * @param type The new type value. */ ! public void setType (String type) ! { ! setAttribute ("TYPE", type); } /** ! * Print the contents of the script tag. */ public String toString() *************** *** 86,95 **** StringBuffer sb = new StringBuffer(); sb.append("Script Node : \n"); ! if (language!=null && type!=null) ! if (language.length()!=0 || type.length()!=0... [truncated message content] |