[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/lexerTests KitTest.java,1.2,1.3
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-08-27 02:40:28
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests In directory sc8-pr-cvs1:/tmp/cvs-serv21827 Modified Files: KitTest.java Log Message: Testing cvs keyword substitution. Index: KitTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/KitTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KitTest.java 21 Aug 2003 01:52:23 -0000 1.2 --- KitTest.java 27 Aug 2003 02:40:24 -0000 1.3 *************** *** 1,7 **** ! /* ! * KitTest.java ! * ! * Created on August 16, 2003, 2:16 PM ! */ package org.htmlparser.tests.lexerTests; --- 1,26 ---- ! // HTMLParser Library $Name$ - A java-based parser for HTML ! // Copyright (C) August 26, 2003 Derrick Oswald ! // ! // Revision Control Information ! // ! // $Source$ ! // $Author$ ! // $Date$ ! // $Revision$ ! // ! // This library is free software; you can redistribute it and/or ! // modify it under the terms of the GNU Lesser General Public ! // License as published by the Free Software Foundation; either ! // version 2.1 of the License, or (at your option) any later version. ! // ! // This library is distributed in the hope that it will be useful, ! // but WITHOUT ANY WARRANTY; without even the implied warranty of ! // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! // Lesser General Public License for more details. ! // ! // You should have received a copy of the GNU Lesser General Public ! // License along with this library; if not, write to the Free Software ! // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! // package org.htmlparser.tests.lexerTests; *************** *** 32,37 **** /** ! * ! * @author derrick */ public class KitTest extends ParserCallback --- 51,65 ---- /** ! * Compare output from javax.swing.text.html.HTMLEditorKit with Lexer. ! * This test provides a means of comparing the lexemes from ! * javax.swing.text.html.HTMLEditorKit.Parser class with the lexemes ! * produced by the org.htmlparser.lexer.Lexer class. ! * <blockquote> ! * The differences have eluded automation since the HTMLEditorKit parser ! * adds spurious nodes where it thinks elements need closing or it gets ! * confused. The intent is to eventually incorporate this into the ! * 'fit test' and run it against lots of HTML pages, but so far you must ! * analyse the differences by hand. ! * </blockquote> */ public class KitTest extends ParserCallback *************** *** 40,44 **** int mIndex; ! /** Creates a new instance of KitTest */ public KitTest (Vector nodes) { --- 68,75 ---- int mIndex; ! /** ! * Creates a new instance of KitTest ! * @param nodes The list of lexemes from Lexer to compare with the kit lexemes. ! */ public KitTest (Vector nodes) { *************** *** 47,50 **** --- 78,86 ---- } + /** + * Remove whitespace from a string. + * @param s The string to crunch. + * @return The string with whitespace characters removed. + */ String snowhite (String s) { *************** *** 65,68 **** --- 101,110 ---- } + /** + * Check if two strings match. + * @param s1 One string. + * @param s2 The other string. + * @return <code>true</code> if the strings are equivalent ignoring whitespace. + */ boolean match (String s1, String s2) { *************** *** 72,75 **** --- 114,125 ---- } + /** + * Callback for a text lexeme. + * @param data The text extracted from the page. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleText (char[] data, int pos) { *************** *** 134,137 **** --- 184,195 ---- } + /** + * Callback for a remark lexeme. + * @param data The text extracted from the page. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleComment (char[] data, int pos) { *************** *** 190,193 **** --- 248,260 ---- } + /** + * Callback for a start tag lexeme. + * @param t The tag extracted from the page. + * @param a The attributes parsed out of the tag. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleStartTag (HTML.Tag t, MutableAttributeSet a, int pos) { *************** *** 247,250 **** --- 314,325 ---- } + /** + * Callback for an end tag lexeme. + * @param t The tag extracted from the page. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleEndTag (HTML.Tag t, int pos) { *************** *** 304,307 **** --- 379,391 ---- } + /** + * Callback for a non-composite tag. + * @param t The tag extracted from the page. + * @param a The attributes parsed out of the tag. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleSimpleTag (HTML.Tag t, MutableAttributeSet a, int pos) { *************** *** 367,375 **** public void handleError (String errorMsg, int pos) { System.out.println ("******* error @" + pos + " ******** " + errorMsg); } ! public void flush () throws BadLocationException { --- 451,470 ---- + /** + * Callback for an error condition. + * @param errorMsg The error condition as a text message. + * @param pos The position in the page. + * <em>Note: This differs from the Lexer concept of position which is an + * absolute location in the HTML input stream. This position is the character + * position if the text from the page were displayed in a browser.</em> + */ public void handleError (String errorMsg, int pos) { System.out.println ("******* error @" + pos + " ******** " + errorMsg); } ! ! /** ! * Callback for flushing the state, just prior to shutting down the parser. ! */ public void flush () throws BadLocationException { *************** *** 449,452 **** --- 544,550 ---- // } + /** + * Subclass of HTMLEditorKit to expose getParser(). + */ class MyKit extends HTMLEditorKit { *************** *** 460,464 **** } } ! public MyKit getKit () { --- 558,565 ---- } } ! ! /** ! * Return a editor kit. ! */ public MyKit getKit () { *************** *** 467,471 **** /** ! * @param args the command line arguments */ public static void main (String[] args) throws ParserException, IOException --- 568,574 ---- /** ! * Manline for the test. ! * @param args the command line arguments. ! * If present the first array element is used as a URL to parse. */ public static void main (String[] args) throws ParserException, IOException *************** *** 499,502 **** parser.parse ((Reader)lexer.getPage ().getSource (), (ParserCallback)test, true); } - } --- 602,614 ---- parser.parse ((Reader)lexer.getPage ().getSource (), (ParserCallback)test, true); } } + + /* + * Revision Control Modification History + * + * $Log$ + * Revision 1.3 2003/08/27 02:40:24 derrickoswald + * Testing cvs keyword substitution. + * + * + */ \ No newline at end of file |