[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/nodeDecoratorTests DecodingNodeTest.java,1.16,1
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests In directory sc8-pr-cvs1:/tmp/cvs-serv16537/tests/nodeDecoratorTests Modified Files: DecodingNodeTest.java EscapeCharacterRemovingNodeTest.java NonBreakingSpaceConvertingNodeTest.java Log Message: Remove most of the scanners. The only scanners left are ones that really do something different (script and jsp). Instead of registering a scanner to enable returning a specific tag you now add a tag to the a PrototypicalNodeFactory. All known tags are 'registered' by default in a new Parser which is similar to having called the old 'registerDOMScanners()', so tags are fully nested. This is different behaviour, and specifically, you will need to recurse into returned nodes to get at what you want. I've tried to adjust the applications accordingly, but worked examples are still scarce. If you want to return only some of the derived tags while keeping most as generic tags, there are various constructors and manipulators on the factory. See the javadocs and examples in the tests package. Nearly all the old scanner tests are folded into the tag tests. toString() has been revamped. This means that the default Parser mainline now returns an indented listing of tags, making it easy to see the structure of a page. The downside is the text of the page had to have newlines, tabs etc. turned into escape sequences. But if you were really interested in content you would be using toHtml() or toPlainTextString(). Index: DecodingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/DecodingNodeTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** DecodingNodeTest.java 9 Nov 2003 17:07:14 -0000 1.16 --- DecodingNodeTest.java 7 Dec 2003 23:41:41 -0000 1.17 *************** *** 51,57 **** StringBuffer decodedContent = new StringBuffer(); StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setNodeDecoding(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); --- 51,57 ---- StringBuffer decodedContent = new StringBuffer(); StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setDecode (true); createParser(STRING_TO_DECODE); ! parser.setNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); Index: EscapeCharacterRemovingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/EscapeCharacterRemovingNodeTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EscapeCharacterRemovingNodeTest.java 9 Nov 2003 17:07:14 -0000 1.15 --- EscapeCharacterRemovingNodeTest.java 7 Dec 2003 23:41:41 -0000 1.16 *************** *** 52,58 **** StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setEscapeCharacterRemoval(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); --- 52,58 ---- StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setRemoveEscapes (true); createParser(STRING_TO_DECODE); ! parser.setNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); *************** *** 100,108 **** StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setNodeDecoding(true); ! stringNodeFactory.setEscapeCharacterRemoval(true); createParser(ENCODED_WORKSHOP_TITLE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); --- 100,108 ---- StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setDecode (true); ! stringNodeFactory.setRemoveEscapes (true); createParser(ENCODED_WORKSHOP_TITLE); ! parser.setNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); Index: NonBreakingSpaceConvertingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/NonBreakingSpaceConvertingNodeTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NonBreakingSpaceConvertingNodeTest.java 9 Nov 2003 17:07:14 -0000 1.14 --- NonBreakingSpaceConvertingNodeTest.java 7 Dec 2003 23:41:41 -0000 1.15 *************** *** 51,57 **** StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setNonBreakSpaceConversion(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); --- 51,57 ---- StringNodeFactory stringNodeFactory = new StringNodeFactory(); ! stringNodeFactory.setConvertNonBreakingSpaces (true); createParser(STRING_TO_DECODE); ! parser.setNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); |