[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags CompositeTag.java,1.56,1.57 ImageTag.java,1.28,1
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-09-28 19:30:55
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1:/tmp/cvs-serv11047/tags Modified Files: CompositeTag.java ImageTag.java LinkTag.java Tag.java TitleTag.java Log Message: Fixed up the broken visitor logic. Added some docos on NodeVisitor. Index: CompositeTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** CompositeTag.java 28 Sep 2003 15:33:58 -0000 1.56 --- CompositeTag.java 28 Sep 2003 19:30:04 -0000 1.57 *************** *** 319,343 **** /** ! * 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()) { ! startTag.accept(visitor); ! SimpleNodeIterator children = children(); ! while (children.hasMoreNodes()) { ! Node child = (Node)children.nextNode(); ! child.accept(visitor); } ! endTag.accept(visitor); } ! if (visitor.shouldRecurseSelf()) ! visitor.visitTag(this); } --- 319,349 ---- /** ! * Tag visiting code. ! * Invokes <code>accept()</code> on the start tag and then ! * walks the child list invoking <code>accept()</code> on each ! * of the children, finishing up with an <code>accept()</code> ! * call on the end tag. If <code>shouldRecurseSelf()</code> ! * returns true it then asks the visitor to visit itself. ! * @param visitor The <code>NodeVisitor</code> object to be signalled ! * for each child and possibly this tag. */ ! public void accept (NodeVisitor visitor) ! { ! SimpleNodeIterator children; ! Node child; ! if (visitor.shouldRecurseChildren ()) ! { ! startTag.accept (visitor); ! children = children (); ! while (children.hasMoreNodes ()) ! { ! child = (Node)children.nextNode (); ! child.accept (visitor); } ! endTag.accept (visitor); } ! if (visitor.shouldRecurseSelf ()) ! visitor.visitTag (this); } Index: ImageTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ImageTag.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ImageTag.java 28 Sep 2003 15:33:58 -0000 1.28 --- ImageTag.java 28 Sep 2003 19:30:04 -0000 1.29 *************** *** 72,77 **** } ! public void accept(NodeVisitor visitor) { ! visitor.visitImageTag(this); } --- 72,86 ---- } ! /** ! * Image visiting code. ! * Invokes <code>visitImageTag()</code> on the visitor and then ! * invokes the normal tag processing. ! * @param visitor The <code>NodeVisitor</code> object to invoke ! * <code>visitImageTag()</code> on. ! */ ! public void accept (NodeVisitor visitor) ! { ! visitor.visitImageTag (this); ! super.accept (visitor); } Index: LinkTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/LinkTag.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** LinkTag.java 22 Sep 2003 02:40:01 -0000 1.35 --- LinkTag.java 28 Sep 2003 19:30:04 -0000 1.36 *************** *** 251,257 **** } ! public void accept(NodeVisitor visitor) { ! visitor.visitLinkTag(this); ! super.accept(visitor); } } --- 251,265 ---- } ! /** ! * Link visiting code. ! * Invokes <code>visitLinkTag()</code> on the visitor and then ! * invokes the normal tag processing. ! * @param visitor The <code>NodeVisitor</code> object to invoke ! * <code>visitLinkTag()</code> on. ! */ ! public void accept (NodeVisitor visitor) ! { ! visitor.visitLinkTag (this); ! super.accept (visitor); } } Index: Tag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Tag.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Tag.java 28 Sep 2003 15:33:58 -0000 1.49 --- Tag.java 28 Sep 2003 19:30:04 -0000 1.50 *************** *** 116,122 **** } public void accept (Object visitor) { ! ((NodeVisitor)visitor).visitTag (this); } } --- 116,144 ---- } + /** + * Handle a visitor. + * <em>NOTE: This currently defers to accept(NodeVisitor). If + * subclasses of Node override accept(Object) directly, they must + * handle the delegation to <code>visitTag()</code> and + * <code>visitEndTag()</code>.</em> + * @param visitor The <code>NodeVisitor</code> object + * (a cast is performed without checking). + */ public void accept (Object visitor) { ! accept ((NodeVisitor)visitor); ! } ! ! /** ! * Default tag visiting code. ! * Based on <code>isEndTag()</code>, calls either <code>visitTag()</code> or ! * <code>visitEndTag()</code>. ! */ ! public void accept (NodeVisitor visitor) ! { ! if (isEndTag ()) ! ((NodeVisitor)visitor).visitEndTag (this); ! else ! ((NodeVisitor)visitor).visitTag (this); } } Index: TitleTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/TitleTag.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TitleTag.java 22 Sep 2003 02:40:02 -0000 1.26 --- TitleTag.java 28 Sep 2003 19:30:04 -0000 1.27 *************** *** 50,56 **** } ! public void accept(NodeVisitor visitor) { ! visitor.visitTitleTag(this); } - } --- 50,64 ---- } ! /** ! * Title visiting code. ! * Invokes <code>visitTitleTag()</code> on the visitor and then ! * invokes the normal tag processing. ! * @param visitor The <code>NodeVisitor</code> object to invoke ! * <code>visitTitleTag()</code> on. ! */ ! public void accept (NodeVisitor visitor) ! { ! visitor.visitTitleTag (this); ! super.accept (visitor); } } |