[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/tagTests CompositeTagTest.java,1.11,1.12 ImageT
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-11-08 21:31:00
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests In directory sc8-pr-cvs1:/tmp/cvs-serv18855/src/org/htmlparser/tests/tagTests Modified Files: CompositeTagTest.java ImageTagTest.java ObjectCollectionTest.java Log Message: Implement generic node filtering. Added the NodeFilter interface and the filter package. Sideline tag specific scanners; tags now use only one scanner of each type, TagScanner or CompositeTagScanner (except for ScriptScanner). Obviated PeekingIterator by moving the META tag semantics to doSemanticAction, much simpler, old IteratorImpl is now PeekingIteratorImpl but deprecated. Index: CompositeTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/CompositeTagTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CompositeTagTest.java 26 Oct 2003 19:46:27 -0000 1.11 --- CompositeTagTest.java 8 Nov 2003 21:30:57 -0000 1.12 *************** *** 100,104 **** CompositeTag parent = (CompositeTag)stringNode[0].getParent(); int pos = parent.findPositionOf(stringNode[0]); ! assertEquals("position",5,pos); } } --- 100,106 ---- CompositeTag parent = (CompositeTag)stringNode[0].getParent(); int pos = parent.findPositionOf(stringNode[0]); ! /* a(b(),string("sdsd"),/b(),string("Hello World")) */ ! /* 0 1 2 3 */ ! assertEquals("position",3,pos); } } Index: ImageTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/ImageTagTest.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** ImageTagTest.java 29 Oct 2003 03:31:18 -0000 1.35 --- ImageTagTest.java 8 Nov 2003 21:30:57 -0000 1.36 *************** *** 37,40 **** --- 37,41 ---- import org.htmlparser.util.NodeList; import org.htmlparser.util.ParserException; + import org.htmlparser.util.ParserUtils; import org.htmlparser.util.SimpleNodeIterator; *************** *** 168,182 **** public ImageTag extractLinkImage (LinkTag link) { ! NodeList subElements = new NodeList (); ! link.collectInto (subElements, ImageTag.class); ! SimpleNodeIterator subScan = subElements.elements (); ! while (subScan.hasMoreNodes ()) ! { ! Node subNode = subScan.nextNode (); ! if (subNode instanceof ImageTag) ! return (ImageTag) subNode; ! } ! ! return null; } --- 169,174 ---- public ImageTag extractLinkImage (LinkTag link) { ! Node[] list = ParserUtils.findTypeInNode (link, ImageTag.class); ! return (0 == list.length ? null : (ImageTag)list[0]); } Index: ObjectCollectionTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/ObjectCollectionTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ObjectCollectionTest.java 26 Oct 2003 19:46:27 -0000 1.15 --- ObjectCollectionTest.java 8 Nov 2003 21:30:57 -0000 1.16 *************** *** 39,42 **** --- 39,43 ---- import org.htmlparser.util.NodeList; import org.htmlparser.util.ParserException; + import org.htmlparser.util.ParserUtils; public class ObjectCollectionTest extends ParserTestCase { *************** *** 89,95 **** parseAndAssertNodeCount(1); Div div = (Div)node[0]; ! NodeList nodeList = new NodeList(); ! div.collectInto(nodeList,Span.class); ! Node[] spans = nodeList.toNodeArray(); assertSpanContent(spans); } --- 90,94 ---- parseAndAssertNodeCount(1); Div div = (Div)node[0]; ! Node[] spans = ParserUtils.findTypeInNode (div, Span.class); assertSpanContent(spans); } *************** *** 111,116 **** TableTag tableTag = (TableTag)node[0]; NodeList nodeList = new NodeList(); ! tableTag.collectInto(nodeList,Span.class); ! Node [] spans = nodeList.toNodeArray(); assertSpanContent(spans); } --- 110,114 ---- TableTag tableTag = (TableTag)node[0]; NodeList nodeList = new NodeList(); ! Node[] spans = ParserUtils.findTypeInNode (tableTag, Span.class); assertSpanContent(spans); } |