[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags AppletTag.java,1.29,1.30 CompositeTag.java,1.55,
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1:/tmp/cvs-serv30684/tags Modified Files: AppletTag.java CompositeTag.java DoctypeTag.java ImageTag.java JspTag.java StyleTag.java Tag.java Removed Files: EndTag.java Log Message: Lexer Integration Removed old Parser classes. Removed EndTag, this class was replaced by a call to the new isEndTag() method on the Tag class The StringNode, RemarkNode and tags.Tag class now derive from their lexeme counterparts in lexer.nodes instead of the other way around. The beginnings of a node factory interface are included. This was added so the lexer could return 'visitable' nodes to the parser. The parser acts as it's own node factory, as does the Lexer. The node count for parsing goes up in most cases because every whitespace (i.e. newline) now counts as a StringNode. This has whacked out a lot of the tests that were expecting fewer nodes or a certain type of node at a particular index. Attributes now maintain their order and case. The count of attributes also went up because whitespace is maintained within tags too. The storage in a Vector means the element 0 Attribute is actually the name of the tag, rather than having the $TAGNAME entry in a HashTable. Index: AppletTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/AppletTag.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** AppletTag.java 23 Sep 2003 03:41:33 -0000 1.29 --- AppletTag.java 28 Sep 2003 15:33:58 -0000 1.30 *************** *** 190,195 **** paramValue = (String)newAppletParams.get (paramName); s = "PARAM VALUE=\"" + paramValue + "\" NAME=\"" + paramName + "\""; ! tagData = new TagData (0, 0, 0, 0, s, s, "", false); // what, no URL? ! kids.add (new Tag (tagData)); } --- 190,196 ---- paramValue = (String)newAppletParams.get (paramName); s = "PARAM VALUE=\"" + paramValue + "\" NAME=\"" + paramName + "\""; ! throw new IllegalStateException ("not implemented"); ! // tagData = new TagData (0, 0, 0, 0, s, s, "", false); // what, no URL? ! // kids.add (new Tag (tagData)); } Index: CompositeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** CompositeTag.java 22 Sep 2003 02:40:01 -0000 1.55 --- CompositeTag.java 28 Sep 2003 15:33:58 -0000 1.56 *************** *** 31,34 **** --- 31,35 ---- 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; *************** *** 38,47 **** public abstract class CompositeTag extends Tag { ! protected Tag startTag, endTag; public CompositeTag(TagData tagData, CompositeTagData compositeTagData) { super(tagData); ! this.startTag = compositeTagData.getStartTag(); ! this.endTag = compositeTagData.getEndTag(); setChildren (compositeTagData.getChildren()); } --- 39,60 ---- 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()); } *************** *** 149,156 **** for (SimpleNodeIterator e = children();e.hasMoreNodes() && !found;) { node = (Node)e.nextNode(); ! if (node instanceof Tag) { tag = (Tag)node; String nameAttribute = tag.getAttribute("NAME"); ! if (nameAttribute!=null && nameAttribute.equals(name)) found=true; } } --- 162,170 ---- for (SimpleNodeIterator e = children();e.hasMoreNodes() && !found;) { node = (Node)e.nextNode(); ! if (node instanceof TagNode) { tag = (Tag)node; String nameAttribute = tag.getAttribute("NAME"); ! if (nameAttribute!=null && nameAttribute.equals(name)) ! found=true; } } *************** *** 271,287 **** } ! public void collectInto(NodeList collectionList, String filter) { ! super.collectInto(collectionList, filter); Node node; ! for (SimpleNodeIterator e = children();e.hasMoreNodes();) { ! node = e.nextNode(); ! node.collectInto(collectionList,filter); } } ! public void collectInto(NodeList collectionList, Class nodeType) { ! super.collectInto(collectionList,nodeType); ! for (SimpleNodeIterator e = children();e.hasMoreNodes();) { ! e.nextNode().collectInto(collectionList,nodeType); } } --- 285,309 ---- } ! public void collectInto (NodeList collectionList, String filter) ! { Node node; ! ! super.collectInto (collectionList, filter); ! for (SimpleNodeIterator e = children(); e.hasMoreNodes ();) ! { ! node = e.nextNode (); ! node.collectInto (collectionList, filter); } } ! public void collectInto (NodeList collectionList, Class nodeType) ! { ! Node node; ! ! super.collectInto (collectionList,nodeType); ! for (SimpleNodeIterator e = children(); e.hasMoreNodes (); ) ! { ! node = e.nextNode (); ! node.collectInto (collectionList, nodeType); } } *************** *** 296,299 **** --- 318,331 ---- } + /** + * Handle a visitor. + * <em>NOTE: This currently defers to accept(NodeVisitor), but eventually + * subclasses of Node should be overriding accept(Object) directly.</em> + * @param visitor The <code>NodeVisitor</code> object. + */ + public void accept(Object visitor) { + accept ((NodeVisitor)visitor); + } + public void accept(NodeVisitor visitor) { if (visitor.shouldRecurseChildren()) { *************** *** 314,322 **** } ! public Tag getStartTag() { return startTag; } ! public Tag getEndTag() { return endTag; } --- 346,354 ---- } ! public TagNode getStartTag() { return startTag; } ! public TagNode getEndTag() { return endTag; } Index: DoctypeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/DoctypeTag.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** DoctypeTag.java 22 Sep 2003 02:40:01 -0000 1.28 --- DoctypeTag.java 28 Sep 2003 15:33:58 -0000 1.29 *************** *** 51,58 **** public String toString() { ! return "Doctype Tag : "+tagContents+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } public String toHtml() { ! return "<!DOCTYPE "+tagContents+">"; } } --- 51,58 ---- public String toString() { ! return "Doctype Tag : "+getTagContents()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } public String toHtml() { ! return "<!DOCTYPE "+getTagContents()+">"; } } Index: ImageTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ImageTag.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ImageTag.java 22 Sep 2003 02:40:01 -0000 1.27 --- ImageTag.java 28 Sep 2003 15:33:58 -0000 1.28 *************** *** 29,32 **** --- 29,33 ---- package org.htmlparser.tags; + import org.htmlparser.lexer.nodes.TagNode; import org.htmlparser.tags.data.TagData; import org.htmlparser.visitors.NodeVisitor; Index: JspTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/JspTag.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** JspTag.java 22 Sep 2003 02:40:01 -0000 1.29 --- JspTag.java 28 Sep 2003 15:33:58 -0000 1.30 *************** *** 47,51 **** public String toHtml() { ! return "<%"+tagContents+"%>"; } --- 47,51 ---- public String toHtml() { ! return "<%"+getTagContents()+"%>"; } *************** *** 55,59 **** public String toString() { ! return "JSP/ASP Tag : "+tagContents+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } --- 55,59 ---- public String toString() { ! return "JSP/ASP Tag : "+getTagContents()+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); } } Index: StyleTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/StyleTag.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** StyleTag.java 22 Sep 2003 02:40:01 -0000 1.27 --- StyleTag.java 28 Sep 2003 15:33:58 -0000 1.28 *************** *** 62,66 **** sb.append("Code\n"); sb.append("****\n"); ! sb.append(tagContents+"\n"); return sb.toString(); } --- 62,66 ---- sb.append("Code\n"); sb.append("****\n"); ! sb.append(getTagContents ()+"\n"); return sb.toString(); } Index: Tag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Tag.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Tag.java 22 Sep 2003 02:40:02 -0000 1.48 --- Tag.java 28 Sep 2003 15:33:58 -0000 1.49 *************** *** 33,42 **** import java.util.Hashtable; import java.util.Map; import org.htmlparser.AbstractNode; ! import org.htmlparser.NodeReader; ! import org.htmlparser.parserHelper.AttributeParser; import org.htmlparser.parserHelper.SpecialHashtable; - import org.htmlparser.parserHelper.TagParser; import org.htmlparser.scanners.TagScanner; import org.htmlparser.tags.data.TagData; --- 33,42 ---- import java.util.Hashtable; import java.util.Map; + import java.util.Vector; import org.htmlparser.AbstractNode; ! import org.htmlparser.lexer.Page; ! import org.htmlparser.lexer.nodes.TagNode; import org.htmlparser.parserHelper.SpecialHashtable; import org.htmlparser.scanners.TagScanner; import org.htmlparser.tags.data.TagData; *************** *** 44,47 **** --- 44,48 ---- import org.htmlparser.util.ParserException; import org.htmlparser.visitors.NodeVisitor; + /** * Tag represents a generic tag. This class allows users to register specific *************** *** 49,282 **** * scanners to run over the text, and identify. It can be used to dynamically * configure a parser. - * @author Kaarle Kaila 23.10.2001 */ ! public class Tag extends AbstractNode { ! public static final String TYPE = "TAG"; ! /** ! * Constant used as value for the value of the tag name ! * in parseParameters (Kaarle Kaila 3.8.2001) ! */ ! public final static String TAGNAME = "$<TAGNAME>$"; ! public final static String EMPTYTAG = "$<EMPTYTAG>$"; ! public final static String NULLVALUE = "$<NULL>$"; ! public final static String NOTHING = "$<NOTHING>$"; ! private final static String EMPTY_STRING=""; ! ! private static TagParser tagParser; ! /** ! * Tag contents will have the contents of the comment tag. ! */ ! protected StringBuffer tagContents; ! private boolean emptyXmlTag = false; ! /** ! * tag parameters parsed into this hashtable ! * not implemented yet ! * added by Kaarle Kaila 23.10.2001 ! */ ! protected SpecialHashtable _attributes=null; ! ! /** ! * Scanner associated with this tag (useful for extraction of filtering data from a ! * HTML node) ! */ ! protected TagScanner thisScanner=null; ! private java.lang.String tagLine; ! ! /** ! * The combined text of all the lines spanned by this tag ! */ ! private String[] tagLines; ! ! /** ! * The line number on which this tag starts ! */ ! private int startLine; ! ! /** ! * Set of tags that breaks the flow. ! */ ! protected static HashSet breakTags; ! static ! { ! breakTags = new HashSet (30); ! breakTags.add ("BLOCKQUOTE"); ! breakTags.add ("BODY"); ! breakTags.add ("BR"); ! breakTags.add ("CENTER"); ! breakTags.add ("DD"); ! breakTags.add ("DIR"); ! breakTags.add ("DIV"); ! breakTags.add ("DL"); ! breakTags.add ("DT"); ! breakTags.add ("FORM"); ! breakTags.add ("H1"); ! breakTags.add ("H2"); ! breakTags.add ("H3"); ! breakTags.add ("H4"); ! breakTags.add ("H5"); ! breakTags.add ("H6"); ! breakTags.add ("HEAD"); ! breakTags.add ("HR"); ! breakTags.add ("HTML"); ! breakTags.add ("ISINDEX"); ! breakTags.add ("LI"); ! breakTags.add ("MENU"); ! breakTags.add ("NOFRAMES"); ! breakTags.add ("OL"); ! breakTags.add ("P"); ! breakTags.add ("PRE"); ! breakTags.add ("TD"); ! breakTags.add ("TH"); ! breakTags.add ("TITLE"); ! breakTags.add ("UL"); ! } ! /** ! * Set the Tag with the beginning posn, ending posn and tag contents (in ! * a tagData object. ! * @param tagData The data for this tag ! */ ! public Tag(TagData 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(); ! } ! ! public void append(char ch) { ! tagContents.append(ch); ! } ! ! public void append(String ch) { ! tagContents.append(ch); ! } ! ! /** ! * Locate the tag withing the input string, by parsing from the given position ! * @param reader HTML reader to be provided so as to allow reading of next line ! * @param input Input String ! * @param position Position to start parsing from ! */ ! public static Tag find(NodeReader reader,String input,int position) { ! return tagParser.find(reader,input,position); ! } ! ! /** ! * This method is not to be called by any scanner or tag. It is ! * an expensive method, hence it has been made private. However, ! * there might be some circumstances when a scanner wishes to force ! * parsing of attributes over and above what has already been parsed. ! * To make the choice clear - we have a method - redoParseAttributes(), ! * which can be used. ! * @return Hashtable ! */ ! private SpecialHashtable parseAttributes(){ ! return (SpecialHashtable)(new AttributeParser()).parseAttributes(getText ()); } ! /** ! * In case the tag is parsed at the scan method this will return value of a ! * parameter not implemented yet ! * @param name of parameter ! */ ! public String getAttribute(String name) { ! SpecialHashtable ht; ! Object ret; ! ! ht = getAttributesEx(); ! ret = ht.getRaw(name.toUpperCase()); ! if (null != ret) ! { ! ret = ((String[])ret)[1]; ! if (Tag.NULLVALUE == ret) ! ret = null; ! else if (Tag.NOTHING == ret) ! ret = ""; ! } ! ! return ((String)ret); ! } ! ! /** ! * Set attribute with given key, value pair. ! * @param key ! * @param value ! */ ! public void setAttribute(String key, String value) { ! _attributes.put(key.toUpperCase (), new String[] {key, value}); ! } ! ! /** ! * In case the tag is parsed at the scan method this will return value of a ! * parameter not implemented yet ! * @param name of parameter ! * @deprecated use getAttribute instead ! */ ! public String getParameter(String name){ ! return ((String[])getAttributesEx().get(name.toUpperCase()))[1]; ! } ! ! /** ! * Gets the attributes in the tag. ! * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), ! * and the second element being the value. ! * @return Returns a special hashtable of attributes in two element String arrays. ! */ ! public SpecialHashtable getAttributesEx() { ! if (_attributes == null) ! _attributes = parseAttributes(); ! return _attributes; } ! /** ! * Gets the attributes in the tag. ! * @return Returns a Hashtable of attributes ! */ ! public Hashtable getAttributes() { ! Hashtable ret; ! ! ret = new SpecialHashtable (); ! for (Enumeration e = getAttributesEx ().keys(); e.hasMoreElements(); ) ! { ! String key = (String)e.nextElement (); ! ret.put (key, ((String[])getAttributesEx().getRaw(key))[1]); ! } ! ! return (ret); ! } ! ! public String getTagName(){ ! return getParameter(TAGNAME); ! } ! ! /** ! * Returns the line where the tag was found ! * @return java.lang.String ! */ ! public String getTagLine() { ! return tagLine; ! } ! ! /** ! * Returns the combined text of all the lines spanned by this tag ! * @return java.lang.String ! */ ! public String[] getTagLines() { ! return tagLines; ! } ! ! /** ! * Return the text contained in this tag ! */ ! public String getText() { ! return tagContents.toString(); } --- 50,76 ---- * scanners to run over the text, and identify. It can be used to dynamically * configure a parser. */ ! public class Tag extends TagNode { ! TagScanner mScanner; ! TagData mData; ! public Tag (TagNode node, TagScanner scanner) { ! super (node.getPage (), node.getTagBegin (), node.getTagEnd (), node.getAttributesEx ()); ! mScanner = scanner; } ! public Tag (Page page, int start, int end, Vector attributes) { ! super (page, start, end, attributes); ! mScanner = null; } ! public Tag (TagData data) { ! super (data.getPage (), data.getTagBegin (), data.getTagEnd (), data.getAttributes ()); ! mData = data; ! mScanner = null; } *************** *** 286,543 **** public TagScanner getThisScanner() { ! return thisScanner; ! } ! ! /** ! * Extract the first word from the given string. ! * Words are delimited by whitespace or equals signs. ! * @param s The string to get the word from. ! * @return The first word. ! */ ! public static String extractWord (String s) ! { ! int length; ! boolean parse; ! char ch; ! StringBuffer ret; ! ! length = s.length (); ! ret = new StringBuffer (length); ! parse = true; ! for (int i = 0; i < length && parse; i++) ! { ! ch = s.charAt (i); ! if (Character.isWhitespace (ch) || ch == '=') ! parse = false; ! else ! ret.append (Character.toUpperCase (ch)); ! } ! ! return (ret.toString ()); ! } ! ! /** ! * Scan the tag to see using the registered scanners, and attempt identification. ! * @param url URL at which HTML page is located ! * @param reader The NodeReader that is to be used for reading the url ! */ ! public AbstractNode scan(Map scanners,String url,NodeReader reader) throws ParserException ! { ! if (tagContents.length()==0) return this; ! try { ! boolean found=false; ! AbstractNode retVal=null; ! // Find the first word in the scanners ! String firstWord = extractWord(tagContents.toString()); ! // Now, get the scanner associated with this. ! TagScanner scanner = (TagScanner)scanners.get(firstWord); ! ! // Now do a deep check ! if (scanner != null && ! scanner.evaluate( ! tagContents.toString(), ! reader.getPreviousOpenScanner() ! ) ! ) ! { ! found=true; ! TagScanner save; ! save = reader.getPreviousOpenScanner (); ! reader.setPreviousOpenScanner(scanner); ! retVal=scanner.createScannedNode(this,url,reader,tagLine); ! reader.setPreviousOpenScanner(save); ! } ! ! if (!found) return this; ! else { ! return retVal; ! } ! } ! catch (Exception e) { ! String errorMsg; ! if (tagContents!=null) errorMsg = tagContents.toString(); else errorMsg="null"; ! throw new ParserException("Tag.scan() : Error while scanning tag, tag contents = "+errorMsg+", tagLine = "+tagLine,e); ! } ! } ! ! /** ! * Sets the attributes. ! * @param attributes The attribute collection to set. ! */ ! public void setAttributes(Hashtable attributes) ! { ! SpecialHashtable att = new SpecialHashtable (); ! for (Enumeration e = attributes.keys (); e.hasMoreElements (); ) ! { ! String key = (String)e.nextElement (); ! att.put (key, new String[] { key, (String)attributes.get (key)}); ! } ! this._attributes = att; ! } ! ! /** ! * Sets the attributes. ! * NOTE: Values of the extended hashtable are two element arrays of String, ! * with the first element being the original name (not uppercased), ! * and the second element being the value. ! * @param attributes The attribute collection to set. ! */ ! public void setAttributesEx (SpecialHashtable attributes) ! { ! _attributes = attributes; ! } ! ! /** ! * Sets the tagBegin. ! * @param tagBegin The starting position of the tag. ! */ ! public void setTagBegin(int tagBegin) { ! this.nodeBegin = tagBegin; ! } ! ! /** ! * Gets the tagBegin. ! * @return The nstarting position of the tag. ! */ ! public int getTagBegin() { ! return (nodeBegin); ! } ! ! /** ! * Sets the tagEnd. ! * @param tagEnd The ending position of the tag. ! */ ! public void setTagEnd(int tagEnd) { ! this.nodeEnd = tagEnd; ! } ! ! /** ! * Gets the tagEnd. ! * @return The ending position of the tag. ! */ ! public int getTagEnd() { ! return (nodeEnd); ! } ! ! /** ! * Gets the line number on which this tag starts. ! * @return the start line number ! */ ! public int getTagStartLine() { ! return startLine; ! } ! ! /** ! * Gets the line number on which this tag ends. ! * @return the end line number ! */ ! public int getTagEndLine() { ! return startLine + tagLines.length - 1; ! } ! ! public void setTagLine(java.lang.String newTagLine) { ! tagLine = newTagLine; ! ! // Note: Incur the overhead of resizing each time (versus ! // preallocating a larger array), since the average tag ! // generally doesn't span multiple lines ! String[] newTagLines = new String[tagLines.length + 1]; ! for (int i = 0; i < tagLines.length; i++) ! newTagLines[i] = tagLines[i]; ! newTagLines[tagLines.length] = newTagLine; ! tagLines = newTagLines; ! } ! ! public void setText(String text) { ! tagContents = new StringBuffer(text); } public void setThisScanner(TagScanner scanner) { ! thisScanner = scanner; ! } ! ! public String toPlainTextString() { ! return EMPTY_STRING; ! } ! ! /** ! * A call to a tag's toHTML() method will render it in HTML ! * Most tags that do not have children and inherit from Tag, ! * do not need to override toHTML(). ! * @see org.htmlparser.Node#toHtml() ! */ ! public String toHtml() ! { ! StringBuffer ret; ! String key; ! String value[]; ! String empty; ! ! ret = new StringBuffer (); ! value = (String[])(getAttributesEx().getRaw (TAGNAME)); ! ret.append ("<"); ! ret.append (value[1]); ! empty = null; ! for (Enumeration e = getAttributesEx ().keys(); e.hasMoreElements(); ) ! { ! key = (String)e.nextElement (); ! if (!key.equals (TAGNAME)) ! { ! if (key.equals (EMPTYTAG)) ! empty="/"; ! else ! { ! ret.append (" "); ! value = (String[])(getAttributesEx().getRaw (key.toUpperCase ())); ! ret.append (value[0]); ! if (Tag.NULLVALUE != value[1]) ! { ! ret.append ("="); ! if (!(Tag.NOTHING == value[1])) ! { ! ret.append ("\""); ! ret.append (value[1]); ! ret.append ("\""); ! } ! else ! ret.append (""); ! } ! } ! } ! } ! if (null != empty) ! ret.append (empty); ! if (isEmptyXmlTag ()) ! ret.append ("/"); ! ret.append (">"); ! ! return (ret.toString ()); ! } ! ! /** ! * Print the contents of the tag ! */ ! public String toString() ! { ! return "Begin Tag : "+tagContents+"; begins at : "+elementBegin()+"; ends at : "+elementEnd(); ! } ! ! /** ! * Sets the tagParser. ! * @param tagParser The tagParser to set ! */ ! public static void setTagParser(TagParser tagParser) { ! Tag.tagParser = tagParser; ! } ! ! /** ! * Determines if the given tag breaks the flow of text. ! * @return <code>true</code> if following text would start on a new line, ! * <code>false</code> otherwise. ! */ ! public boolean breaksFlow () ! { ! return (breakTags.contains (getText ().toUpperCase ())); } --- 80,89 ---- public TagScanner getThisScanner() { ! return (mScanner); } public void setThisScanner(TagScanner scanner) { ! mScanner = scanner; } *************** *** 549,612 **** * @see org.htmlparser.Node#collectInto(NodeList, String) */ ! public void collectInto(NodeList collectionList, String filter) { ! if (thisScanner!=null && thisScanner.getFilter()==filter) ! collectionList.add(this); ! } ! ! /** ! * Returns table of attributes in the tag ! * @return Hashtable ! * @deprecated This method is deprecated. Use getAttributes() instead. ! */ ! public Hashtable getParsed() { ! return getAttributes (); ! } ! ! /** ! * Sometimes, a scanner may need to request a re-evaluation of the ! * attributes in a tag. This may happen when there is some correction ! * activity. An example of its usage can be found in ImageTag. ! * <br> ! * <B>Note:<B> This is an intensive task, hence call only when ! * really necessary ! * @return Hashtable ! */ ! public Hashtable redoParseAttributes() { ! _attributes = null; ! getAttributesEx (); ! return (getAttributes ()); } /** ! * Handle a visitor. ! * <em>NOTE: This currently defers to accept(NodeVisitor), but eventually ! * subclasses of Node should be overriding accept(Object) directly.</em> ! * @param visitor The <code>NodeVisitor</code> object. */ ! public void accept(Object visitor) { ! accept ((NodeVisitor)visitor); ! } ! ! public void accept(NodeVisitor visitor) { ! visitor.visitTag(this); ! } ! ! public String getType() { ! return TYPE; ! } ! /** ! * Is this an empty xml tag of the form<br> ! * <tag/> ! * @return boolean ! */ ! public boolean isEmptyXmlTag() { ! return emptyXmlTag; } ! public void setEmptyXmlTag(boolean emptyXmlTag) { ! this.emptyXmlTag = emptyXmlTag; } - } --- 95,122 ---- * @see org.htmlparser.Node#collectInto(NodeList, String) */ ! public void collectInto(NodeList collectionList, String filter) { ! if (null != getThisScanner () && getThisScanner ().getFilter () == filter) ! collectionList.add (this); } /** ! * Jeez I hope this goes away. */ ! public String getTagContents () ! { ! String ret; ! if (null != mData) ! ret = mData.getTagContents(); ! else ! ret = ""; ! ! return (ret); } ! public void accept (Object visitor) ! { ! ((NodeVisitor)visitor).visitTag (this); } } --- EndTag.java DELETED --- |