[Htmlparser-developer] Swing integration - Code so far (brief explanation)
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2002-05-07 11:57:54
|
Hi Craig, A brief description - you will probably want to use ParserTester. The code is quite dirty at the moment, but a basic idea is : [1] HTMLParserAdapter adapts our HTMLParser into Parser (Swing's parser) - The donkey work comes here with all those if-then statements. [2] HTMLParserProvider gives me the parser (makes the method public), so I can control it. [3] TrialParser - the parser class that allows you to configure which parser you want. ParserTester uses this to create two different parsers, by using the c'tor params. Based on the params, at the point of invoking the parser (in MyParserDelegator), the decision is made as to which parser is to be used. [4] MyParserCallBack - the same class is used for both parsers. For every call back method, an object of a certain time is created, which is collected in a vector, and is used later for comparison in the testcase. So, handleSimpleTag() will create a SimpleTagCallBack object. If this method is correctly called by our parser, then the two objects ought to match. (The equals method accomplishes this). [5] testTypes package contains the various types like SimpleTagCallBack, which aid us in testing these call back objects returned by the two parsers. [6] ParserTester - the main testing mechanism - where you get to create the two parsers, choose what html they have to parse, and then compare their respective callback objects. This one's a nightmare - bcos the swing parser puts in tags that werent there. You can ignore the other classes safely (I ought to delete them). If you have any doubts, pls let me know. Regards, Somik |