Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / testsuite / javax.swing.text.html.parser / test / gnu / javax / swing / text / html / parser / ParserTest.java
blobaf12cbbdb45dadf7251416b43df5d871667ad1eb
1 /* ParserTest.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package test.gnu.javax.swing.text.html.parser;
41 import gnu.javax.swing.text.html.parser.support.Parser;
43 import java.io.PrintStream;
45 import java.util.Enumeration;
47 import javax.swing.text.AttributeSet;
48 import javax.swing.text.html.parser.Element;
49 import javax.swing.text.html.parser.TagElement;
51 /**
52 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
54 public class ParserTest
55 extends gnu.javax.swing.text.html.parser.support.Parser
57 PrintStream out = System.out;
58 StringBuffer errors = new StringBuffer();
60 public ParserTest()
62 super(gnu.javax.swing.text.html.parser.HTML_401F.getInstance());
65 public static void main(String[] args)
67 String sx;
68 sx =
69 "<html><head></head><body><table>< tbody><tr >< td >C_0_0< td>C_0_1< td >C_0_2< /td >< td >C_0_3<td>C_0_4< /td></tr ></tbody></table></body></html>";
70 try
72 System.out.println(sx);
74 ParserTest t = new ParserTest();
75 t.parse(new java.io.StringReader(sx));
76 System.out.println("\nErrors:");
77 System.out.println(t.errors);
79 catch (Exception ex)
81 ex.printStackTrace();
85 protected void handleComment(char[] parm1)
87 out.print("{" + new String(parm1) + "}");
90 protected void handleEOFInComment()
92 out.print(" [EOF in comment] ");
95 protected void handleEmptyTag(TagElement tag)
96 throws javax.swing.text.ChangedCharSetException
98 out.print("<" + tag);
100 javax.swing.text.AttributeSet atts = getAttributes();
101 dumpAttributes(atts);
102 out.print("/>");
105 protected void handleEndTag(TagElement tag)
107 out.print("</" + tag + "> ");
110 protected void handleError(int line, String message)
112 errors.append(message);
113 errors.append('\n');
116 protected void handleStartTag(TagElement tag)
118 out.print("<" + tag);
120 javax.swing.text.AttributeSet atts = getAttributes();
121 dumpAttributes(atts);
122 out.print('>');
125 protected void handleText(char[] parm1)
127 out.print("'" + new String(parm1) + "'");
130 protected void handleTitle(char[] parm1)
132 out.print(" [ Title: " + new String(parm1) + "] ");
135 protected void markFirstTime(Element element)
137 out.print("(1:" + element + ")");
140 private void dumpAttributes(AttributeSet atts)
142 Enumeration enum = atts.getAttributeNames();
143 while (enum.hasMoreElements())
145 String a = enum.nextElement().toString();
146 String v = (String) atts.getAttribute(a);
147 out.print(" " + a + "='" + v + "'");