Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/util
In directory sc8-pr-cvs1:/tmp/cvs-serv19975/util
Modified Files:
IteratorImpl.java
Log Message:
Moved the recursion from the NodeFactory to the CompositeTagScanner where it belongs.
Also needed to kick off the recursion in IteratorImpl.
The scnner is obtained in a kludgy way -- just 'til tags know their own scanners.
Also fixed the other NodeFactory signatures to have a Page rather than a Lexer.
Index: IteratorImpl.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/util/IteratorImpl.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** IteratorImpl.java 26 Oct 2003 19:46:28 -0000 1.31
--- IteratorImpl.java 28 Oct 2003 03:04:19 -0000 1.32
***************
*** 58,62 ****
--- 58,85 ----
ret = mLexer.nextNode ();
if (null != ret)
+ {
+ // kick off recursion for the top level node
+ if (ret instanceof org.htmlparser.tags.Tag)
+ {
+ org.htmlparser.tags.Tag tag;
+ String name;
+ org.htmlparser.scanners.TagScanner scanner;
+
+ tag = (org.htmlparser.tags.Tag)ret;
+ if (!tag.isEndTag ())
+ {
+ // now recurse if there is a scanner for this type of tag
+ name = tag.getTagName ();
+ // whoah! really cheat here to get the parser
+ // maybe eventually the tag will know it's own scanner eh
+ org.htmlparser.Parser parser = (org.htmlparser.Parser)mLexer.getNodeFactory ();
+ scanner = parser.getScanner (name);
+ if ((null != scanner) && scanner.evaluate (tag, null))
+ ret = scanner.createScannedNode (tag, mLexer.getPage ().getUrl (), mLexer);
+ }
+ }
+
preRead.addElement (ret);
+ }
}
catch (Exception e) {
|