harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427121 [28/29] - in /incubator/harmony/enhanced/classlib/trunk/modules/swing: make/ src/main/java/common/javax/swing/ src/main/java/common/javax/swing/text/ src/main/java/common/javax/swing/text/html/ src/main/java/common/javax/swing/text/...
Date Mon, 31 Jul 2006 14:08:55 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTD401Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTD401Test.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTD401Test.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTD401Test.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,262 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+
+import java.util.BitSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.SwingTestCase;
+
+import junit.framework.TestCase;
+
+public class DTD401Test extends TestCase {
+    DTD dtd;
+    Vector elements;
+
+    protected void setUp() throws Exception {
+        dtd = Utils.getFilledDTD();
+        super.setUp();
+    }
+
+    private void checkBitSet(final BitSet bs, final String descr) {
+        boolean isEmptyBs = (bs == null || bs.cardinality() == 0);
+        boolean isEmptyDescr = descr == null || descr == "";
+        assertFalse(isEmptyBs ^ isEmptyDescr);
+        if (!isEmptyBs) {
+            String[] names = descr.split("\\|");
+            for (int i = 0; i < names.length; i++) {
+                int index = ((Element)dtd.elementHash.get(names[i])).getIndex();
+                assertTrue(bs.get(index));
+            }
+            for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))  {
+                String name = ((Element)dtd.elements.get(i)).getName();
+                boolean result = false;
+                for (int j = 0; j < names.length; j++) {
+                    if (names[j].equals(name)) {
+                        result = true;
+                        break;
+                    }
+                }
+                assertTrue(result);
+            }
+        }
+    }
+
+    private String tagsToString(final boolean oStart, final boolean oEnd) {
+        return (oStart ? "O" : "-") + " " + (oEnd ? "O" : "-");
+    }
+
+    public void testEntities() {
+        if (!SwingTestCase.isHarmony()) {
+            Utils401.check32Entities(dtd.entityHash);
+        } else {
+            Utils401.check401Entities(dtd.entityHash);
+        }
+    }
+
+    public void testElements() {
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        ElementDescrHash hash = new ElementDescrHash();
+        ElementsHandler.initAttributes();
+        ElementsHandler.initElementsCreation(hash);
+        assertEquals(hash.size() + 2, dtd.elementHash.size());
+        assertEquals(hash.size() + 2, dtd.elements.size());
+        Iterator iter = hash.keySet().iterator();
+        for (int i = 0; i < dtd.elements.size(); i++) {
+            String name = ((Element)dtd.elements.get(i)).getName();
+            if (!hash.containsKey(name)) {
+                assertTrue("UNKNOWN".equals(name) || "#PCDATA".equals(name));
+            }
+        }
+
+        while (iter.hasNext()) {
+            String name = (String)iter.next();
+            String descr = (String)hash.get(name);
+            String atts = (String)ElementsHandler.atts.get(name);
+            checkElement(name, descr, atts);
+        }
+    }
+
+
+    public void testFields() {
+        if (!SwingTestCase.isHarmony()) {
+            return;
+        }
+        ElementDescrHash hash = new ElementDescrHash();
+        ElementsHandler.initAttributes();
+        ElementsHandler.initElementsCreation(hash);
+
+        Element[] elements = new Element[]
+             {dtd.html,
+             dtd.meta,
+             dtd.base,
+             dtd.isindex,
+             dtd.head,
+             dtd.body,
+             dtd.applet,
+             dtd.param,
+             dtd.p,
+             dtd.title};
+         for (int i = 0; i < elements.length; i++) {
+             Element element = elements[i];
+             String name = element.getName();
+             String descr = (String)hash.get(name);
+             String atts = (String)ElementsHandler.atts.get(name);
+             checkElement(element, descr, atts);
+       }
+
+    }
+
+    private void checkElement(final Element elem, final String descr,
+                              final String atts) {
+        assertEquals(dtd.elements.get(elem.getIndex()), elem);
+        assertEquals(dtd.elementHash.get(elem.name), elem);
+        String[] splDescr = DTDUtilities.splitElementDescr(descr);
+        checkTags(elem.oStart, elem.oEnd, splDescr[0]);
+        checkBitSet(elem.exclusions, splDescr[2]);
+        checkBitSet(elem.inclusions, splDescr[3]);
+        checkContentModel(elem.name, elem.content, splDescr[1]);
+        checkType(elem, splDescr[1]);
+        checkAttributes(elem, atts);
+    }
+
+    private void checkElement(final String name, final String descr,
+                              final String atts) {
+        Element elem = (Element)dtd.elementHash.get(name);
+        checkElement(elem, descr, atts);
+    }
+
+    private void checkType(final Element elem, final String descr) {
+        int type = elem.type;
+        if (descr.equals("EMPTY")) {
+            assertEquals(DTDConstants.EMPTY, type);
+        } else if (descr.equals("CDATA")) {
+            assertEquals(DTDConstants.CDATA, type);
+        } else {
+            assertEquals(DTDConstants.MODEL, type);
+        }
+    }
+
+    private void checkContentModel(final String name,
+                                   final ContentModel contentModel,
+                                   final String descr) {
+        if (contentModel == null) {
+            assertTrue(descr.equals("EMPTY") || descr.equals("CDATA"));
+        } else  if (descr.equals("EMPTY")) {
+            assertNull(contentModel);
+        } else  if (!descr.equals("CDATA")) {
+            String content = contentModel.toString();
+            if (!checExtraordinaryCase(name, content, descr)) {
+               assertEquals(descr, content);
+            }
+        }
+    }
+
+    private boolean checExtraordinaryCase(final String name,
+                                          final String content,
+                                          final String descr) {
+        if (name.equals("COLGROUP")
+            || name.equals("TFOOT")
+            || name.equals("DIR")
+            || name.equals("MENU")
+            || name.equals("OPTGROUP")
+            || name.equals("OL")
+            || name.equals("UL")
+            || name.equals("TBODY")
+            || name.equals("THEAD")) {
+            String s1 = "(" + content.substring(0, content.length() - 1)
+                    + ")" + content.charAt(content.length() - 1);
+            assertEquals(descr, s1);
+            return true;
+        } else if (name.equals("TABLE")
+                || name.equals("HTML")
+                || name.equals("#PCDATA")
+                || name.equals("TEXTAREA")
+                || name.equals("FIELDSET")
+                || name.equals("TITLE")
+                || name.equals("HEAD")
+                || name.equals("OPTION")
+                || name.equals("FRAMESET")) {
+            String s1 = "(" + content + ")";
+            assertEquals(descr, s1);
+            return true;
+        } else if (name.equals("ADDRESS")) {
+            String s1 = "(" + content.substring(0, content.length() - 4)
+              + ")" + content.substring(content.length() - 4, content.length());
+             assertEquals(descr, s1);
+            return true;
+        } else if (name.equals("MAP")) {
+            String s1 = "(" + content.substring(0, content.length() - 7)
+            + ")" + content.substring(content.length() - 7, content.length());
+            assertEquals(descr, s1);
+            return true;
+        }
+        return false;
+    }
+
+
+    private void checkTags(final boolean oStart,
+                           final boolean oEnd,
+                           final String desc) {
+        assertEquals(desc, tagsToString(oStart, oEnd));
+    }
+
+    private void checkAttributes(final Element elem,
+                                 final String atts) {
+        String name = elem.getName();
+        if (name.equals("INPUT") || name.equals("FORM")
+                || name.equals("FRAMESET")) {
+            assertEquals(atts.replaceAll("\\(|\\)", "")
+                         .replaceAll("( )+", "").replaceAll("CDATAs;", "CDATA"),
+                         elem.atts.paramString()
+                         .replaceAll(",", " ").replaceAll("( )+", ""));
+
+        } else {
+            assertEquals(atts.replaceAll("\\(|\\)", "").replaceAll("( )+", ""),
+                         elem.atts.paramString().replaceAll(",", " ")
+                         .replaceAll("( )+", ""));
+        }
+    }
+
+    static class ElementDescrHash extends Hashtable {
+
+        public synchronized Object put(final Object key, final Object value) {
+            String name = (String) key;
+            if (name.indexOf("|") >= 0) {
+                String[] names = DTDUtilities.replaceAndSplit(name);
+                for (int i = 0; i < names.length; i++) {
+                    put(names[i], value);
+                }
+                return null;
+            } else {
+                return super.put(key, value);
+            }
+        }
+    }
+
+//    public void testSer() {
+//        DTDUtilities.createBinaryDTD("C:/jenja.bd");
+//    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDConstantsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDConstantsTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDConstantsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDConstantsTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,62 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import junit.framework.TestCase;
+
+public class DTDConstantsTest extends TestCase {
+    public void testConstants() {
+        assertEquals(19, DTDConstants.ANY);
+        assertEquals(1, DTDConstants.CDATA);
+        assertEquals(4, DTDConstants.CONREF);
+        assertEquals(3, DTDConstants.CURRENT);
+        assertEquals(131072, DTDConstants.DEFAULT);
+        assertEquals(17, DTDConstants.EMPTY);
+        assertEquals(14, DTDConstants.ENDTAG);
+        assertEquals(3, DTDConstants.ENTITIES);
+        assertEquals(2, DTDConstants.ENTITY);
+        assertEquals(1, DTDConstants.FIXED);
+        assertEquals(65536, DTDConstants.GENERAL);
+        assertEquals(4, DTDConstants.ID);
+        assertEquals(5, DTDConstants.IDREF);
+        assertEquals(6, DTDConstants.IDREFS);
+        assertEquals(5, DTDConstants.IMPLIED);
+        assertEquals(16, DTDConstants.MD);
+        assertEquals(18, DTDConstants.MODEL);
+        assertEquals(15, DTDConstants.MS);
+        assertEquals(7, DTDConstants.NAME);
+        assertEquals(8, DTDConstants.NAMES);
+        assertEquals(9, DTDConstants.NMTOKEN);
+        assertEquals(10, DTDConstants.NMTOKENS);
+        assertEquals(11, DTDConstants.NOTATION);
+        assertEquals(12, DTDConstants.NUMBER);
+        assertEquals(13, DTDConstants.NUMBERS);
+        assertEquals(14, DTDConstants.NUTOKEN);
+        assertEquals(15, DTDConstants.NUTOKENS);
+        assertEquals(262144, DTDConstants.PARAMETER);
+        assertEquals(12, DTDConstants.PI);
+        assertEquals(10, DTDConstants.PUBLIC);
+        assertEquals(16, DTDConstants.RCDATA);
+        assertEquals(2, DTDConstants.REQUIRED);
+        assertEquals(11, DTDConstants.SDATA);
+        assertEquals(13, DTDConstants.STARTTAG);
+        assertEquals(17, DTDConstants.SYSTEM);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DTDTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,500 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.swing.SwingTestCase;
+import junit.framework.TestCase;
+
+/**
+ * That's a test for default dtd, doesn't check dtd 4.01 and read method.
+ */
+public class DTDTest extends TestCase {
+    static final String PCDATA = conv("#pcdata");
+    static final String HTML = conv("html"); //1
+    static final String META = conv("meta"); //2
+    static final String BASE = conv("base"); //3
+    static final String ISINDEX = conv("isindex"); //4
+    static final String HEAD = conv("head"); //5
+    static final String BODY = conv("body"); //6
+    static final String APPLET = conv("applet"); //7
+    static final String PARAM = conv("param"); //8
+    static final String P = conv("p"); //9
+    static final String TITLE = conv("title"); //10
+    static final String STYLE = conv("style"); //11
+    static final String LINK = conv("link"); //12
+    static final String UNKNOWN = conv("unknown"); //13
+
+    DTD dtd = new DTD("DTDTest1");
+    Vector elementNames;
+
+    public static final String SPACE_ENTITY_NAME = "#SPACE";
+    public static final String RS_ENTITY_NAME = "#RS";
+    public static final String RE_ENTITY_NAME = "#RE";
+    private static final int DEFAULT_SIZE = 14;
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testGetPutDTD() {
+        try {
+            DTD dtd1 = DTD.getDTD("DTDTest1");
+            DTD dtd2 = DTD.getDTD("DTDTest1");
+
+            int hashCode1 = dtd1.hashCode();
+            int hashCode2 = dtd2.hashCode();
+            assertEquals("DTDTest1".toLowerCase(), dtd1.getName());
+            assertTrue(hashCode1 != hashCode2);
+            assertNotSame(dtd, DTD.getDTD("DTDTest1".toLowerCase()));
+
+            String name = "name";
+            dtd1 = new DTD("abcd");
+            DTD.putDTDHash(name, dtd1);
+
+            assertEquals(dtd1, DTD.getDTD(name));
+            assertNotSame(dtd1, DTD.getDTD("abcd"));
+            assertEquals(dtd1, DTD.getDTD("Name"));
+            assertEquals(dtd1, DTD.getDTD("name"));
+
+            dtd2 = new DTD("abcdef");
+            DTD.putDTDHash(name, dtd2);
+            assertEquals(dtd2, DTD.getDTD(name));
+
+            DTD.putDTDHash("name1", dtd2);
+            assertEquals(dtd2, DTD.getDTD("name"));
+            assertEquals(dtd2, DTD.getDTD("name1"));
+
+
+            //If name contains upper characters that willn't be put to DTD.
+            //That's isn't logically and not documented.
+            if (SwingTestCase.isHarmony()) {
+                name = "Name";
+                dtd1 = new DTD("abcd");
+                DTD.putDTDHash(name, dtd1);
+
+                assertEquals(dtd1, DTD.getDTD(name));
+                assertNotSame(dtd1, DTD.getDTD("abcd"));
+                assertEquals(dtd1, DTD.getDTD("Name"));
+                assertEquals(dtd1, DTD.getDTD("name"));
+            }
+
+            if (SwingTestCase.isHarmony()) {
+                try {
+                    dtd = DTD.getDTD(null);
+                    assertFalse("IllegalArgumentException wasn't thrown", true);
+                } catch (IllegalArgumentException e) {
+                }
+                try {
+                    DTD.putDTDHash(null, dtd1);
+                    assertFalse("IllegalArgumentException wasn't thrown", true);
+                } catch (IllegalArgumentException e) {
+                }
+                try {
+                    DTD.putDTDHash("nn", null);
+                    assertFalse("IllegalArgumentException wasn't thrown", true);
+                } catch (IllegalArgumentException e) {
+                }
+            }
+
+          } catch (IOException e) {
+              assertFalse("Unexcepted IOException", true);
+          }
+    }
+
+    public void testFILE_VERSION() {
+        assertEquals(1, DTD.FILE_VERSION);
+    }
+
+
+    private void checkDefaultElements(final DTD dtd) {
+        Vector elements = dtd.elements;
+        assertEquals(DEFAULT_SIZE, dtd.elements.size());
+        for (int i = 0; i < DEFAULT_SIZE - 1; i++) {
+            Utils.checkDTDDefaultElement(((Element)elements.get(i)),
+                                         ((String)elementNames.get(i)),
+                                         i);
+        }
+
+        Utils.checkElement(((Element)elements.get(DEFAULT_SIZE - 1)),
+                           null, null, null, null, null, DEFAULT_SIZE - 1,
+                           UNKNOWN,
+                           true, false, 17);
+
+    }
+
+    private void initDefaultElementsVector() {
+        elementNames = new Vector();
+        elementNames.add(PCDATA); //0
+        elementNames.add(HTML); //1
+        elementNames.add(META); //2
+        elementNames.add(BASE); //3
+        elementNames.add(ISINDEX); //4
+        elementNames.add(HEAD); //5
+        elementNames.add(BODY); //6
+        elementNames.add(APPLET); //7
+        elementNames.add(PARAM); //8
+        elementNames.add(P); //9
+        elementNames.add(TITLE); //10
+        elementNames.add(STYLE); //11
+        elementNames.add(LINK); //12
+        elementNames.add(UNKNOWN); //13
+    }
+
+    private void checkDefaultElementHash(final DTD dtd) {
+        Hashtable elementHash = dtd.elementHash;
+        assertEquals(DEFAULT_SIZE, elementHash.size());
+
+        for (int i = 0; i < DEFAULT_SIZE - 1; i++) {
+            String name = (String)elementNames.get(i);
+            Utils.checkDTDDefaultElement(((Element)elementHash.get(name)),
+                                         name,
+                                         i);
+        }
+
+        Utils.checkElement(((Element)elementHash.get(UNKNOWN)),
+                           null, null, null, null, null, DEFAULT_SIZE - 1,
+                           UNKNOWN,
+                           true, false, 17);
+    }
+
+    private void checkDefaultEntityHash(final DTD dtd) {
+        Hashtable entityHash = dtd.entityHash;
+        assertEquals(3, entityHash.size());
+        Set keys = entityHash.keySet();
+        Iterator iter = keys.iterator();
+        int count = 0;
+        while (iter.hasNext()) {
+            String name = (String)iter.next();
+            Entity entity = (Entity)entityHash.get(name);
+            if (SPACE_ENTITY_NAME.equals(name)) {
+                count++;
+                Utils.checkEntity(entity, name, 0, " ", true, false);
+            } else if (RS_ENTITY_NAME.equals(name)) {
+                count++;
+                Utils.checkEntity(entity, name, 0, "\n", true, false);
+            } else if (RE_ENTITY_NAME.equals(name)) {
+                count++;
+                Utils.checkEntity(entity, name, 0, "\r", true, false);
+            }
+        }
+        assertEquals(3, count);
+    }
+
+
+    public void testDTD() {
+        DTD dtd1 = new DTD(null);
+        assertNull(dtd1.getName());
+
+        assertEquals("DTDTest1", dtd.name);
+        initDefaultElementsVector();
+        checkDefaultElements(dtd);
+        checkDefaultElementHash(dtd);
+        checkDefaultEntityHash(dtd);
+
+        Utils.checkDTDDefaultElement(dtd.pcdata, PCDATA, 0);
+        Utils.checkDTDDefaultElement(dtd.html, HTML, 1);
+        Utils.checkDTDDefaultElement(dtd.meta, META, 2);
+        Utils.checkDTDDefaultElement(dtd.base, BASE, 3);
+        Utils.checkDTDDefaultElement(dtd.isindex, ISINDEX, 4);
+        Utils.checkDTDDefaultElement(dtd.head, HEAD, 5);
+        Utils.checkDTDDefaultElement(dtd.body, BODY, 6);
+        Utils.checkDTDDefaultElement(dtd.applet, APPLET, 7);
+        Utils.checkDTDDefaultElement(dtd.param, PARAM, 8);
+        Utils.checkDTDDefaultElement(dtd.p, P, 9);
+        Utils.checkDTDDefaultElement(dtd.title, TITLE, 10);
+    }
+
+    public void testToString() {
+        assertEquals(dtd.getName(), dtd.toString());
+    }
+
+    public void testDefContentModel() {
+        Element e1 = new Element();
+        e1.name = "e1";
+        Element e2 = new Element();
+        e2.name = "e2";
+        ContentModel contentModel1 = new ContentModel(e1);
+        ContentModel contentModel = dtd.defContentModel('|', e2, contentModel1);
+        Utils.checkContentModel(contentModel, e2, '|', contentModel1);
+    }
+
+    public void testDefAttributeList() {
+        String name = "name";
+        int type = 22;
+        int modifier = 23;
+        String value = "value";
+        String values = "value1|value2|value3|";
+        AttributeList next = new AttributeList("next");
+        AttributeList attl = dtd.defAttributeList(name, type, modifier, value,
+                                             values, next);
+        Vector v = new Vector();
+        v.add("value1");
+        v.add("value2");
+        v.add("value3");
+        Utils.checkAttributeList(attl, modifier, type, name, next, v,
+                                 value, true);
+
+        attl = dtd.defAttributeList(name, type, modifier, value, null, next);
+        Utils.checkAttributeList(attl, modifier, type, name, next, null,
+                                 value, true);
+        v = new Vector();
+        attl = dtd.defAttributeList(name, type, modifier, value, "", next);
+        Utils.checkAttributeList(attl, modifier, type, name, next, v,
+                                 value, true);
+    }
+
+    public void testDefElement() {
+        String name = "newElement";
+        int type = 234;
+        boolean omitStart = true;
+        boolean omitEnd = true;
+        ContentModel contentModel = null;
+        String[] exclusions = new String[] {HTML, BASE};
+        String[] inclusions = new String[] {APPLET, BODY};
+        AttributeList attl = new AttributeList("atttibuteList");
+        Element elem = dtd.defElement(name, type, omitStart, omitEnd,
+                                      contentModel, exclusions, inclusions,
+                                      attl);
+        BitSet excl = new BitSet();
+        excl.set(1);
+        excl.set(3);
+        BitSet incl = new BitSet();
+        incl.set(6);
+        incl.set(7);
+        Utils.checkElement(elem, attl, contentModel, null, incl, excl,
+                           DEFAULT_SIZE,
+                           name, omitEnd, omitStart, 234);
+        assertEquals(DEFAULT_SIZE + 1, dtd.elements.size());
+        assertEquals(name, ((Element)dtd.elements.get(DEFAULT_SIZE)).getName());
+        dtd.elements.remove(DEFAULT_SIZE);
+        dtd.elementHash.remove(name);
+
+        elem = dtd.defElement(HTML, 123, false, false, null, null, null, null);
+        assertEquals(14, dtd.elements.size());
+        elem = (Element)dtd.elementHash.get(HTML);
+        assertEquals(123, elem.getType());
+        elem.type = 19;
+    }
+
+    static String conv(final String name) {
+        return SwingTestCase.isHarmony() ? name.toUpperCase() : name;
+    }
+
+    public void testDefEntityStringintString() {
+        String name = "newStringEntity";
+        int type = 123;
+        String data = "AbcD";
+        Entity entity = dtd.defEntity(name, type, data);
+        Utils.checkEntity(entity, name, type, data, false, false);
+        assertEquals(entity, dtd.entityHash.get(name));
+        dtd.entityHash.remove(name);
+
+        name = "#SPACE";
+        entity = dtd.defEntity(name, type, data);
+        Utils.checkEntity(entity, name, 0, " ", true, false);
+        assertEquals(3, dtd.entityHash.size());
+    }
+
+    public void testDefEntityStringintint() {
+        String name = "newCharEntity";
+        int type = 123;
+        char data = 'J';
+        Entity entity = dtd.defEntity(name, type, data);
+        Utils.checkEntity(entity, name, type, Character.toString(data),
+                          false, false);
+        assertEquals(entity, dtd.entityHash.get(name));
+        assertEquals(4, dtd.entityHash.size());
+        dtd.entityHash.remove(name);
+
+
+        name = "#SPACE";
+        entity = dtd.defEntity(name, type, data);
+        Utils.checkEntity(entity, name, 0, " ", true, false);
+        assertEquals(3, dtd.entityHash.size());
+    }
+
+    public void testDefineAttributes() {
+        String name = HTML;
+        AttributeList attl = new AttributeList("new AttributeList");
+        dtd.defineAttributes(HTML, attl);
+        Element element = (Element)dtd.elementHash.get(name);
+        assertEquals(attl, element.getAttributes());
+        element.atts = null;
+
+        name = "newElement";
+        dtd.defineAttributes(name, attl);
+        element = (Element)dtd.elementHash.get(name);
+        assertEquals(DEFAULT_SIZE + 1, dtd.elements.size());
+        assertEquals(attl, element.getAttributes());
+        dtd.elements.remove(DEFAULT_SIZE);
+        dtd.elementHash.remove(name);
+    }
+
+    public void testDefineElement() {
+        Element elem = (Element)dtd.elementHash.get(HTML);
+        String name = elem.getName();
+        int type = elem.getType();
+        boolean omitStart = elem.omitStart();
+        boolean omitEnd = elem.omitEnd();
+        ContentModel content = elem.getContent();
+        BitSet exclusions = elem.exclusions;
+        BitSet inclusions = elem.inclusions;
+        AttributeList atts = elem.getAttributes();
+        //check exactly the same
+        Element elem1 = dtd.defineElement(name, type, omitStart, omitEnd,
+                                          content, exclusions, inclusions,
+                                          atts);
+        assertEquals(elem, elem1);
+        Utils.checkElement(elem1, atts, content, null, exclusions, inclusions,
+                           1, name, omitEnd, omitStart, type);
+        assertEquals(DEFAULT_SIZE, dtd.elements.size());
+
+        // change fields
+        type = 245;
+        elem1 = dtd.defineElement(name, type, omitStart, omitEnd,
+                                  content, exclusions, inclusions,
+                                  atts);
+        Utils.checkElement(elem1, atts, content, null, exclusions, inclusions,
+                           1, name, omitEnd, omitStart, type);
+        elem1 = (Element)dtd.elementHash.get(name); //TODO dtdHash isn't changed
+        elem1 = (Element)dtd.elements.get(1);
+        Utils.checkElement(elem1, atts, content, null, exclusions, inclusions,
+                           1, name, omitEnd, omitStart, type);
+        elem1.type = 19;
+        assertEquals(DEFAULT_SIZE, dtd.elements.size());
+
+        // other name
+        name = "test";
+        elem1 = dtd.defineElement(name, type, omitStart, omitEnd,
+                                  content, exclusions, inclusions,
+                                  atts);
+        Utils.checkElement(elem1, atts, content, null, exclusions, inclusions,
+                           DEFAULT_SIZE, name, omitEnd, omitStart, type);
+
+        elem1 = (Element)dtd.elementHash.get(name);
+        Utils.checkElement(elem1, atts, content, null, exclusions, inclusions,
+                           DEFAULT_SIZE, name, omitEnd, omitStart, type);
+        assertEquals(DEFAULT_SIZE + 1, dtd.elements.size());
+        dtd.elementHash.remove(name);
+        dtd.elements.remove(DEFAULT_SIZE);
+    }
+
+    public void testDefineEntity() {
+        Entity entity = (Entity)dtd.entityHash.get("#SPACE");
+        String name = entity.getName();
+        int type = entity.getType();
+        String data = entity.getString();
+        boolean isGeneral = entity.isGeneral();
+        boolean isParameter = entity.isParameter();
+
+        Entity entity1 = dtd.defineEntity(name, type, data.toCharArray());
+        Utils.checkEntity(entity1, name, type, data, isGeneral, isParameter);
+        assertEquals(3, dtd.entityHash.size());
+
+        entity1 = (Entity)dtd.entityHash.get(name);
+        Utils.checkEntity(entity1, name, type, data, isGeneral, isParameter);
+
+        data = "data";
+        entity1 = dtd.defineEntity(name, type, data.toCharArray());
+        //Attention: data wasn't updated
+        Utils.checkEntity(entity1, name, type, " ", isGeneral, isParameter);
+        assertEquals(3, dtd.entityHash.size());
+
+        data = entity1.getString();
+        type = 235;
+        entity1 = dtd.defineEntity(name, type, data.toCharArray());
+        //Attention: type wasn't updated
+        Utils.checkEntity(entity1, name, 0, " ", isGeneral, isParameter);
+        assertEquals(3, dtd.entityHash.size());
+
+        name = "newEntity";
+        entity1 = dtd.defineEntity(name, type, data.toCharArray());
+        Utils.checkEntity(entity1, name, type, data, false, false);
+        assertEquals(4, dtd.entityHash.size());
+        entity1 = (Entity)dtd.entityHash.get(name);
+        Utils.checkEntity(entity1, name, type, data, false, false);
+        dtd.entityHash.remove(name);
+    }
+
+    public void testGetElementint() {
+        initDefaultElementsVector();
+        for (int i = 0; i < DEFAULT_SIZE; i++) {
+            assertEquals(elementNames.get(i), dtd.getElement(i).getName());
+        }
+        //ArrayIndexOutOfBoundsException on RI
+        if (SwingTestCase.isHarmony()) {
+           assertNull(dtd.getElement(DEFAULT_SIZE));
+        }
+    }
+
+    public void testGetElementString() {
+        initDefaultElementsVector();
+        for (int i = 0; i < DEFAULT_SIZE; i++) {
+            String name = (String)elementNames.get(i);
+            assertEquals(name, dtd.getElement(name).getName());
+        }
+        String name = "test1";
+        Utils.checkDTDDefaultElement(dtd.getElement(name), name,
+                                     DEFAULT_SIZE);
+        assertEquals(DEFAULT_SIZE + 1, dtd.elementHash.size());
+        assertEquals(DEFAULT_SIZE + 1, dtd.elements.size());
+
+        dtd.elements.remove(DEFAULT_SIZE);
+        dtd.elementHash.remove(name);
+    }
+
+    public void testGetEntityint() {
+        //RI
+        if (!SwingTestCase.isHarmony()) {
+            assertNull(dtd.getEntity(0));
+            assertNull(dtd.getEntity(1));
+            assertNull(dtd.getEntity(2));
+            assertNull(dtd.getEntity(' '));
+            assertNull(dtd.getEntity('\n'));
+            assertNull(dtd.getEntity('\r'));
+        }
+    }
+
+    public void testGetEntityString() {
+        assertEquals(dtd.entityHash.get(SPACE_ENTITY_NAME),
+                     dtd.getEntity(SPACE_ENTITY_NAME));
+        assertEquals(dtd.entityHash.get(RS_ENTITY_NAME),
+                     dtd.getEntity(RS_ENTITY_NAME));
+        assertEquals(dtd.entityHash.get(RE_ENTITY_NAME),
+                     dtd.getEntity(RE_ENTITY_NAME));
+        assertNull(dtd.getEntity("Test"));
+    }
+
+    public void testGetName() {
+        assertEquals("DTDTest1", dtd.getName());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DocumentParserTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DocumentParserTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DocumentParserTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/DocumentParserTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,72 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+public class DocumentParserTest extends TestCase {
+    Utils.ExtDocumentParser dp;
+
+    protected void setUp() throws Exception {
+        DTD dtd = Utils.getDefaultDTD();
+        dp = new Utils.ExtDocumentParser(dtd);
+    }
+
+    //Looks liek these methods tesing is no of use... (as they are calles
+    //only from by
+    //parse method)... Otherwise, NPE will be thrown (no callback...)
+/*
+    public void testHandleError() {
+        dp.handleError(5, "That's an error message");
+    }
+
+    public void testHandleEndTag() {
+    }
+
+    public void testHandleStartTag() {
+    }
+
+    public void testHandleEmptyTag() {
+    }
+
+    public void testHandleComment() {
+    }
+
+    public void testHandleText() {
+    }
+
+
+    public void testDocumentParser() {
+    }
+
+    */
+    public void testParseReaderParserCallbackBoolean() {
+        Utils.ParserCallback cb = new Utils.ParserCallback();
+        cb.checkArguments = true;
+        cb.setParser(dp);
+        try {
+               dp.parse(Utils.getReader("test41"), cb, true);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ElementTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ElementTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ElementTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/ElementTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,138 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.awt.Rectangle;
+import java.util.BitSet;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+public class ElementTest extends TestCase {
+    Element elem = new Element();
+    AttributeList atts1 = new AttributeList("atts1");
+    ContentModel contentModel = new ContentModel(new Element());
+    Object data = new Rectangle();
+    BitSet exclusions = new BitSet();
+    BitSet inclusions = new BitSet();
+    int index = 4;
+    String name = "testElement";
+    boolean oEnd = false;
+    boolean oStart = true;
+    int type = 26;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        elem = new Element();
+    }
+
+    public void testElement() {
+        Utils.checkElement(elem, null, null, null, null, null, 0, null, false,
+                           false, 19);
+    }
+
+    public void testGetters() {
+        Utils.initElement(elem, atts1, contentModel, data, inclusions,
+                          exclusions, index, name, oEnd, oStart, type);
+        Utils.checkElement(elem, atts1, contentModel, data, inclusions,
+                          exclusions, index, name, oEnd, oStart, type);
+    }
+
+    public void testAttributes() {
+        Vector values1 = new Vector();
+        values1.add("a");
+        values1.add("b");
+        atts1 = new AttributeList("atts1", 0, 0, "a", values1, null);
+
+        elem.atts = atts1;
+        assertEquals(atts1, elem.getAttribute("atts1"));
+        assertNull(elem.getAttribute(null));
+        assertEquals(atts1, elem.getAttributeByValue("a"));
+        assertEquals(atts1, elem.getAttributeByValue("b"));
+        assertNull(elem.getAttributeByValue("c"));
+        assertNull(elem.getAttribute("atts2"));
+
+        Vector values2 = new Vector();
+        values2.add("swing");
+        values2.add("awt");
+        AttributeList atts2 = new AttributeList("atts2", 0, 0, "swing",
+                                                values2, atts1);
+        elem.atts = atts2;
+        assertEquals(atts1, elem.getAttribute("atts1"));
+        assertEquals(atts2, elem.getAttribute("atts2"));
+        assertEquals(atts1, elem.getAttributeByValue("a"));
+        assertEquals(atts1, elem.getAttributeByValue("b"));
+        assertEquals(atts2, elem.getAttributeByValue("swing"));
+        assertEquals(atts2, elem.getAttributeByValue("awt"));
+        assertNull(elem.getAttributeByValue("c"));
+        assertNull(elem.getAttributeByValue("2d"));
+    }
+
+    public void testIsEmpty() {
+        assertFalse(elem.isEmpty());
+        Utils.initElement(elem, atts1, contentModel, data, inclusions,
+                          exclusions, index, name, oEnd, oStart, type);
+        assertFalse(elem.isEmpty());
+        Utils.initElement(elem, atts1, contentModel, data, inclusions,
+                  exclusions, index, name, false, true, type);
+        assertFalse(elem.isEmpty());
+        Utils.initElement(elem, atts1, null, null, null,
+                  null, index, name, oEnd, oStart, type);
+        assertFalse(elem.isEmpty());
+        Utils.initElement(elem, atts1, null, null, null,
+                  null, index, name, oEnd, oStart, 17);
+        assertTrue(elem.isEmpty());
+    }
+
+    public void testName2type() {
+       String[] names = Utils.getDTDConstantsNames();
+       for (int i = 0; i < names.length; i++) {
+          String key = names[i];
+          int type = Element.name2type(key);
+          if (key.equals("ANY")) {
+              assertEquals(DTDConstants.ANY, type);
+          } else if (key.equals("CDATA")) {
+              assertEquals(DTDConstants.CDATA, type);
+          } else if (key.equals("EMPTY")) {
+              assertEquals(DTDConstants.EMPTY, type);
+          } else if (key.equals("RCDATA")) {
+              assertEquals(DTDConstants.RCDATA, type);
+          } else {
+              assertEquals(0, type);
+          }
+       }
+   }
+
+   public void testSerialization() {
+       Element intElement = (Element)contentModel.content;
+       intElement.name = "A";
+       Utils.initElement(elem, atts1, contentModel, data, inclusions,
+                         exclusions, index, name, oEnd, oStart, type);
+       Element element = (Element)Utils.doSerialization(elem);
+       assertEquals(atts1.name, element.atts.getName());
+       assertEquals(contentModel.type, element.getContent().type);
+       assertEquals(intElement.getName(),
+                    ((Element)element.getContent().content).getName());
+       Utils.checkElement(element, atts1,
+                          contentModel, data, inclusions,
+                          exclusions, index, name, oEnd, oStart,
+                          type, false);
+   }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,81 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import junit.framework.TestCase;
+
+public class EntityTest extends TestCase {
+    public void testEntity() {
+        String name  = "first";
+        int type = 26;
+        String data = "firstData";
+        Entity entity = new Entity(name, type, data.toCharArray());
+        Utils.checkEntity(entity, name, type, data, false, false);
+
+        name = "second";
+        type = 106;
+        data = "secondData";
+        entity = new Entity(name, type, data.toCharArray());
+        Utils.checkEntity(entity, name, type, data, false, false);
+
+        name = null;
+        type = 0;
+        data = "";
+        entity = new Entity(name, type, data.toCharArray());
+        Utils.checkEntity(entity, name, type, data, false, false);
+    }
+
+    //TODO Investigate how is it defined.
+    public void testIsGeneral() {
+
+    }
+
+    //TODO Investigate how is it defined.
+    public void testIsParameter() {
+
+    }
+
+    public void testName2type() {
+        String[] names = Utils.getDTDConstantsNames();
+        for (int i = 0; i < names.length; i++) {
+            String key = names[i];
+            int value = Entity.name2type(key);
+            if (key.equals("PUBLIC")) {
+                assertEquals(DTDConstants.PUBLIC, value);
+            } else if (key.equals("SDATA")) {
+                assertEquals(DTDConstants.SDATA, value);
+            } else if (key.equals("PI")) {
+                assertEquals(DTDConstants.PI, value);
+            } else if (key.equals("STARTTAG")) {
+                assertEquals(DTDConstants.STARTTAG, value);
+            } else if (key.equals("ENDTAG")) {
+                assertEquals(DTDConstants.ENDTAG, value);
+            } else if (key.equals("MS")) {
+                assertEquals(DTDConstants.MS, value);
+            } else if (key.equals("MD")) {
+                assertEquals(DTDConstants.MD, value);
+            } else if (key.equals("SYSTEM")) {
+                assertEquals(DTDConstants.SYSTEM, value);
+            } else {
+                assertEquals(DTDConstants.CDATA, value);
+            }
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/TagElementTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/TagElementTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/TagElementTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/TagElementTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,81 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import javax.swing.text.html.HTML;
+
+import junit.framework.TestCase;
+
+public class TagElementTest extends TestCase {
+    Element element;
+    TagElement tagElement;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        element = new Element();
+        element.name = "test";
+        tagElement = new TagElement(element);
+    }
+
+    public void testFictional() {
+        assertFalse(tagElement.fictional());
+        tagElement = new TagElement(element, true);
+        assertTrue(tagElement.fictional());
+        tagElement = new TagElement(element, false);
+        assertFalse(tagElement.fictional());
+    }
+
+    public void testGetHTMLTag() {
+        HTML.Tag tag = tagElement.getHTMLTag();
+        assertTrue(tag instanceof HTML.UnknownTag);
+        //name check
+        assertEquals("test", tag.toString());
+
+        element.name = DTDTest.HTML;
+        tagElement = new TagElement(element);
+        tag = tagElement.getHTMLTag();
+        assertFalse(tag instanceof HTML.UnknownTag);
+        assertEquals(HTML.Tag.HTML, tag);
+    }
+
+    public void testGetElement() {
+        assertEquals(element, tagElement.getElement());
+    }
+
+    public void testIsPreformatted() {
+        assertFalse(tagElement.isPreformatted());
+        element.name = DTDTest.conv("pre");
+        tagElement = new TagElement(element);
+        assertTrue(tagElement.isPreformatted());
+        element.name = DTDTest.conv("textarea");
+        tagElement = new TagElement(element);
+        assertTrue(tagElement.isPreformatted());
+    }
+
+    public void testBreaksFlow() {
+        element.name = DTDTest.conv("td");
+        tagElement = new TagElement(element);
+        assertTrue(tagElement.breaksFlow());
+
+        element.name = DTDTest.conv("textarea");
+        tagElement = new TagElement(element);
+        assertFalse(tagElement.breaksFlow());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/Utils.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/Utils.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/Utils.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/Utils.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,766 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Evgeniya G. Maenkova
+ * @version $Revision$
+ */
+package javax.swing.text.html.parser;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Reader;
+import java.lang.reflect.Field;
+import java.util.BitSet;
+import java.util.Vector;
+
+import javax.swing.SwingTestCase;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.ChangedCharSetException;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.HTML.Tag;
+
+import junit.framework.TestCase;
+
+public class Utils {
+    static Field[] dtdConstantsFields;
+    static String[] dtdConstantsNames;
+
+    public static String[] getDTDConstantsNames() {
+        if (dtdConstantsFields == null) {
+            dtdConstantsFields = DTDConstants.class.getDeclaredFields();
+        }
+        if (dtdConstantsNames == null) {
+            dtdConstantsNames = new String[dtdConstantsFields.length];
+            for (int i = 0; i < dtdConstantsFields.length; i++) {
+                dtdConstantsNames[i] = dtdConstantsFields[i].getName();
+            }
+        }
+        return dtdConstantsNames;
+    }
+
+    public static String attrToString(final AttributeList attl) {
+        if (attl == null) {
+            return null;
+        };
+        String result = attl + "[" + attl.value + "]:";
+        if (attl.values == null) {
+            return result;
+        }
+        for (int i = 0; i < attl.values.size(); i++) {
+            result += attl.values.get(i) + ",";
+        }
+        if (attl.next == null) {
+           return result;
+        }
+        return result + "!" + attrToString(attl.next);
+    }
+
+    public static void printElement(final Element e, final String descr) {
+        String offset = "   ";
+        System.out.println(offset + descr);
+        System.out.println(offset + "name: " + e.getName());
+        System.out.println(offset + "type: " + e.getType());
+        System.out.println(offset + "oStart: " + e.omitStart());
+        System.out.println(offset + "oEnd: " + e.omitEnd());
+        System.out.println(offset + "content: " + e.content);
+        System.out.println(offset + "exclusions: " + e.exclusions);
+        System.out.println(offset + "inclusions: " + e.inclusions);
+        //System.out.println(offset + "atts: " + e.atts.paramString());
+        System.out.println(offset + "data: " + e.data);
+        System.out.println(offset + "index: " + e.index);
+    }
+
+    public static void printEntity(final Entity e, final String descr) {
+        String offset = "   ";
+        System.out.println(offset + descr);
+        System.out.println(offset + "name: " + e.getName());
+        System.out.println(offset + "type: " + (int)e.type + " " + e.getType());
+        System.out.println(offset + "data: " + String.valueOf(e.data));
+        System.out.println(offset + "isParameter: " + e.isParameter());
+        System.out.println(offset + "isGeneral: " + e.isGeneral());
+    }
+
+    public static void printContentModel(final ContentModel contentModel,
+              final Object content,
+              final int type,
+              final ContentModel next,
+              final boolean isEmpty,
+              final Element first,
+              final Object objUnderTest,
+              final boolean canBeFirst) {
+        System.out.println(content + " " + contentModel.content);
+        System.out.println(content.hashCode() + " "
+                           + contentModel.content.hashCode());
+        System.out.println((char)type + " " + (char)contentModel.type);
+        System.out.println(next + " " + contentModel.next);
+        System.out.println(isEmpty + " " + contentModel.empty());
+        System.out.println(canBeFirst + " " + contentModel.first(objUnderTest));
+        System.out.println(first + " " + contentModel.first());
+    }
+
+    public static void checkElement(final Element elem,
+                             final AttributeList atts,
+                             final ContentModel model,
+                             final Object data,
+                             final BitSet inclusions,
+                             final BitSet exclusions,
+                             final int index,
+                             final String name,
+                             final boolean oEnd,
+                             final boolean oStart,
+                             final int type) {
+        checkElement(elem, atts, model, data, inclusions, exclusions,
+                     index, name, oEnd, oStart, type, true);
+    }
+
+    public static Object doSerialization(final Object data) {
+        try {
+            ByteArrayOutputStream outByte = new ByteArrayOutputStream();
+            BufferedOutputStream buffOut = new BufferedOutputStream(outByte);
+            ObjectOutputStream output = new ObjectOutputStream(buffOut);
+            output.writeObject(data);
+            output.flush();
+            buffOut.flush();
+            ByteArrayInputStream inptByte = new ByteArrayInputStream(outByte
+                    .toByteArray());
+            ObjectInputStream input = new ObjectInputStream(inptByte);
+            return input.readObject();
+        } catch (Exception e) {
+             e.printStackTrace();
+             TestCase.assertFalse("unexcepted Exception", true);
+        }
+
+        return null;
+    }
+
+    public static void checkElement(final Element elem,
+                                    final AttributeList atts,
+                                    final ContentModel model,
+                                    final Object data,
+                                    final BitSet inclusions,
+                                    final BitSet exclusions,
+                                    final int index,
+                                    final String name,
+                                    final boolean oEnd,
+                                    final boolean oStart,
+                                    final int type, boolean isStrongCheck) {
+        if (isStrongCheck) {
+            TestCase.assertEquals(atts, elem.atts);
+            TestCase.assertEquals(model, elem.content);
+            TestCase.assertEquals(atts, elem.getAttributes());
+            TestCase.assertEquals(model, elem.getContent());
+        }
+
+        TestCase.assertEquals(data, elem.data);
+        TestCase.assertEquals(inclusions, elem.inclusions);
+        TestCase.assertEquals(exclusions, elem.exclusions);
+        TestCase.assertEquals(index, elem.index);
+        TestCase.assertEquals(name, elem.name);
+        TestCase.assertEquals(oEnd, elem.oEnd);
+        TestCase.assertEquals(oStart, elem.oStart);
+        TestCase.assertEquals(type, elem.type);
+        TestCase.assertEquals(index, elem.getIndex());
+        TestCase.assertEquals(name, elem.getName());
+        TestCase.assertEquals(oEnd, elem.omitEnd());
+        TestCase.assertEquals(oStart, elem.omitStart());
+        TestCase.assertEquals(type, elem.getType());
+    }
+
+    public static void checkDTDDefaultElement(final Element elem,
+                                              final String name,
+                                              final int index) {
+
+        TestCase.assertNull(elem.atts);
+        TestCase.assertNull(elem.content);
+        TestCase.assertNull(elem.data);
+        TestCase.assertNull(elem.inclusions);
+        TestCase.assertNull(elem.exclusions);
+        TestCase.assertEquals(index, elem.index);
+        TestCase.assertEquals(name, elem.name);
+        TestCase.assertFalse(elem.oEnd);
+        TestCase.assertFalse(elem.oStart);
+        TestCase.assertEquals(19, elem.type);
+    }
+
+    public static void checkAttributeList(final AttributeList attl,
+                                          final int modifier,
+                                          final int type,
+                                          final String name,
+                                          final AttributeList next,
+                                          final Vector values,
+                                          final String value,
+                                          final boolean isStrongCheck) {
+        TestCase.assertEquals(modifier, attl.getModifier());
+        TestCase.assertEquals(name, attl.getName());
+        TestCase.assertEquals(type, attl.getType());
+        TestCase.assertEquals(value, attl.getValue());
+        TestCase.assertEquals(values, attl.values);
+        if (isStrongCheck || next == null) {
+            TestCase.assertEquals(next, attl.getNext());
+        } else {
+            AttributeList attrList = attl.getNext();
+            TestCase.assertEquals(next.modifier, attrList.getModifier());
+            TestCase.assertEquals(next.name, attrList.getName());
+            TestCase.assertEquals(next.type, attrList.getType());
+            TestCase.assertEquals(next.value, attrList.getValue());
+            TestCase.assertEquals(next.values, attrList.values);
+        }
+    }
+
+    public static void checkContentModel(final ContentModel contentModel,
+                                         final Object content,
+                                         final int type,
+                                         final ContentModel next) {
+        TestCase.assertEquals("content", content, contentModel.content);
+        TestCase.assertEquals("type", type, contentModel.type);
+        TestCase.assertEquals("next", next, contentModel.next);
+    }
+
+    public static void initElement(final Element elem,
+                                   final AttributeList atts,
+                                   final ContentModel model,
+                                   final Object data,
+                                   final BitSet inclusions,
+                                   final BitSet exclusions,
+                                   final int index,
+                                   final String name,
+                                   final boolean oEnd,
+                                   final boolean oStart,
+                                   final int type) {
+        elem.atts = atts;
+        elem.content = model;
+        elem.data = data;
+        elem.inclusions = inclusions;
+        elem.exclusions = exclusions;
+        elem.index = index;
+        elem.name = name;
+        elem.oEnd = oEnd;
+        elem.oStart = oStart;
+        elem.type = type;
+    }
+
+    public static void checkEntity(final Entity entity,
+                                   final String name,
+                                   final int type,
+                                   final String data,
+                                   final boolean isGeneral,
+                                   final boolean isParametr) {
+        TestCase.assertEquals(name, entity.name);
+        //TestCase.assertEquals(type, entity.type);
+        TestCase.assertEquals(data, String.valueOf(entity.data));
+        TestCase.assertEquals(name, entity.getName());
+        TestCase.assertEquals(type, entity.getType()); //TODO 65536
+        TestCase.assertEquals(data, entity.getString());
+        TestCase.assertEquals(isGeneral, entity.isGeneral());
+        TestCase.assertEquals(isParametr, entity.isParameter());
+    }
+
+    public static void checkEntity(final Entity entity,
+                                   final String name,
+                                   final int type,
+                                   final char data,
+                                   final boolean isGeneral,
+                                   final boolean isParametr) {
+        TestCase.assertEquals(name, entity.name);
+        TestCase.assertEquals(1, entity.data.length);
+        TestCase.assertEquals(data, entity.data[0]);
+        TestCase.assertEquals(name, entity.getName());
+        TestCase.assertEquals(type, entity.getType()); //TODO 65536
+        TestCase.assertEquals(isGeneral, entity.isGeneral());
+        TestCase.assertEquals(isParametr, entity.isParameter());
+    }
+
+
+    public static Reader getReader(final String testName) {
+        Reader result = null;
+        try {
+            FileInputStream fis =
+                new FileInputStream(System.getProperty("TEST_SRC_DIR")
+                                    + "javax/swing/text/html/parser/" + testName
+                                    + ".html");
+            result = new InputStreamReader(fis);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    static DTD dtd;
+
+    public static DTD getDefaultDTDInstance() {
+        DTD dtd = new DTD("test") {
+            public Element getElement(final int index) {
+                return super.getElement(index);
+            }
+
+            public Element getElement(final String name) {
+                Element result = super.getElement(name);
+                return result;
+            }
+        };
+
+        return dtd;
+    }
+
+    public static DTD getFilledDTD() {
+//        if (SwingTestCase.isHarmony())  {
+//            DTD dtd = new DTD("test");
+//            DTDUtilities.initDTD(dtd);
+//            return dtd;
+//        }
+
+        DTD dtd = getDefaultDTDInstance();
+        fillDTD(dtd);
+        return dtd;
+    }
+
+    public static void fillDTD(final DTD dtd) {
+        String name = SwingTestCase.isHarmony() ? "transitional401.bdtd"
+                : "html32.bdtd";
+        try {
+            dtd.read(new DataInputStream(dtd.getClass()
+                                         .getResourceAsStream(name)));
+        } catch (IOException e) {
+            e.printStackTrace();
+            TestCase.assertFalse("Unexcepted IOException", true);
+        }
+    }
+
+    public static DTD getDefaultDTD() {
+        if (dtd == null) {
+            dtd = getDefaultDTDInstance();
+        }
+        return dtd;
+    }
+
+    public static void printDebugInfo(final String msg,
+                                      final boolean condition) {
+        if (condition) {
+            System.out.println(msg);
+        }
+    }
+
+    //TODO add checking position for atts && pos &&
+    public static class ParserCallback extends HTMLEditorKit.ParserCallback {
+        public final boolean debugOut = true;
+
+        public Utils.ExtDocumentParser parserForCheck;
+
+        public boolean checkArguments = false;
+
+        public void checkArguments(final int pos,
+                                   final HTML.Tag tag) {
+            if (checkArguments) {
+                TestCase.assertEquals(parserForCheck.pos_d, pos);
+                TestCase.assertEquals(parserForCheck.tag_d, tag);
+            }
+        }
+
+        public void checkArguments(final int pos) {
+            if (checkArguments) {
+                TestCase.assertEquals(parserForCheck.pos_d, pos);
+            }
+        }
+
+        public void checkArguments(final HTML.Tag tag) {
+            if (checkArguments) {
+                 TestCase.assertEquals(parserForCheck.tag_d, tag);
+            }
+        }
+
+        public void setParser(final Utils.ExtDocumentParser parser) {
+            parserForCheck = parser;
+        }
+
+        public void printDebugInfo(final String msg) {
+            Utils.printDebugInfo("Utils.ParserCallback:" + msg, debugOut);
+        }
+
+        public void flush() throws BadLocationException {
+            printDebugInfo("flush");
+            super.flush();
+        }
+
+        public void handleComment(final char[] data,
+                                  final int pos) {
+            printDebugInfo("handleComment(data=" + String.valueOf(data)
+                           + ", " + "pos= " + pos + ")");
+            super.handleComment(data, pos);
+        }
+
+        public void handleEndOfLineString(final String eol) {
+            printDebugInfo("handleEndOfLineString(eol=" + eol + ")");
+            super.handleEndOfLineString(eol);
+        }
+
+        public void handleEndTag(final Tag tag,
+                                 final int pos) {
+            printDebugInfo("handleEndTag(tag=" + tag + ", " + "pos="
+                           + pos + ")");
+            super.handleEndTag(tag, pos);
+        }
+
+        public void handleError(final String msg,
+                                final int pos) {
+            printDebugInfo("handleError(msg=" + msg + ", " + "pos="
+                           + pos + ")");
+            super.handleError(msg, pos);
+        }
+        public void handleSimpleTag(final Tag tag,
+                                    final MutableAttributeSet atts,
+                                    final int pos) {
+            printDebugInfo("handleSimpleTag(tag=" + tag + ", " + "atts="
+                           + atts + ", " +  "pos=" + pos + ")");
+            super.handleSimpleTag(tag, atts, pos);
+        }
+
+        public void handleStartTag(final Tag tag,
+                                   final MutableAttributeSet atts,
+                                   final int pos) {
+            checkArguments(tag);
+            printDebugInfo("handleStartTag(tag=" + tag + ", " + "atts="
+                           + atts + ", " +  "pos=" + pos + ")");
+            super.handleStartTag(tag, atts, pos);
+        }
+        public void handleText(final char[] text,
+                               final int pos) {
+            printDebugInfo("handleText(data=" + String.valueOf(text) + ", "
+                           + "pos= " + pos + ")");
+            super.handleText(text, pos);
+        }
+    }
+
+    public static class ExtParser extends Parser {
+        public boolean debugOut = true;
+        public void printDebugInfo(final String msg) {
+            Utils.printDebugInfo("Utils.ExtParser:" + msg, debugOut);
+        }
+
+        public ExtParser(final DTD dtd) {
+            super(dtd);
+        }
+
+        protected void endTag(final boolean omitted) {
+            printDebugInfo("endTag()");
+            super.endTag(omitted);
+        }
+        protected void error(final String msg) {
+            printDebugInfo("2.error: " + msg);
+            super.error(msg);
+        }
+        protected void error(final String msg1, final String msg2) {
+            printDebugInfo("3.error: " + msg1 + " " + msg2);
+            super.error(msg1, msg2);
+        }
+        protected void error(final String msg1,
+                             final String msg2,
+                             final String msg3) {
+            printDebugInfo("4.error: " + msg1 + " " + msg2 + " " + msg3);
+            super.error(msg1, msg2, msg3);
+        }
+        protected void error(final String msg1,
+                             final String msg2,
+                              final String msg3,
+                              final String msg4) {
+            printDebugInfo("5.error: " + msg1 + " " + msg2 + " " +  msg3
+                           + " " + msg4);
+            super.error(msg1, msg2, msg3, msg4);
+        }
+        protected void flushAttributes() {
+            printDebugInfo("6.flushAttributes");
+            super.flushAttributes();
+        }
+
+        protected SimpleAttributeSet getAttributes() {
+            printDebugInfo("7.getAttributes");
+            return super.getAttributes();
+        }
+
+        protected int getCurrentLine() {
+            printDebugInfo("8.getCurrentLine");
+            return super.getCurrentLine();
+        }
+
+        protected int getCurrentPos() {
+            printDebugInfo("9.getCurrentLine");
+            return super.getCurrentPos();
+        }
+
+        protected void handleComment(final char[] text) {
+            super.handleComment(text);
+            printDebugInfo("10.handleComment: " + new String(text));
+
+        }
+
+        protected void handleEmptyTag(final TagElement elem)
+            throws ChangedCharSetException {
+            printDebugInfo("11.handleEmptyTag");
+            super.handleEmptyTag(elem);
+        }
+
+        protected void handleEndTag(final TagElement elem) {
+            printDebugInfo("12.handleEndTag");
+            super.handleEndTag(elem);
+        }
+
+        protected void handleEOFInComment() {
+            printDebugInfo("13.handleEOFInComment");
+            super.handleEOFInComment();
+        }
+
+        protected void handleError(final int pos, final String msg) {
+            printDebugInfo("14.handleError: " + pos + " " + msg);
+            super.handleError(pos, msg);
+        }
+
+        protected void handleStartTag(final TagElement elem) {
+            printDebugInfo("15.handleStartTag " + elem.getElement());
+            AttributeList attList = elem.getElement().getAttributes();
+            if (attList != null) {
+                printDebugInfo("..." + attList.getName() + " "
+                               + attList.getValue());
+            }
+            super.handleStartTag(elem);
+        }
+
+        protected void handleText(final char[] text) {
+            printDebugInfo("16.handleText: " + new String(text));
+            super.handleText(text);
+        }
+
+        protected void handleTitle(final char[] text) {
+            printDebugInfo("17.handleTitle: " + new String(text));
+            super.handleTitle(text);
+        }
+
+        protected TagElement makeTag(final Element elem) {
+            printDebugInfo("18.makeTag(1)" + elem);
+            //printElement(elem, "");
+            return super.makeTag(elem);
+        }
+
+        protected TagElement makeTag(final Element elem,
+                                     final boolean functional) {
+            printDebugInfo("19.makeTag(2)" + functional + " " + elem);
+            //printElement(elem, "");
+            return super.makeTag(elem, functional);
+        }
+
+        protected void markFirstTime(final Element elem) {
+            printDebugInfo("20.markFirstTime");
+            super.markFirstTime(elem);
+        }
+
+        protected boolean parseMarkupDeclarations(final StringBuffer buf)
+            throws IOException {
+            printDebugInfo("21.parseMarkupDeclarations");
+            return super.parseMarkupDeclarations(buf);
+        }
+
+        protected void startTag(final TagElement elem)
+            throws ChangedCharSetException {
+            printDebugInfo("22.startTag " + elem.getHTMLTag());
+            /*System.out.println("__________________________ _");
+            Utils.printElement(elem.getElement()," ");
+            System.out.println("____________________________"); */
+            super.startTag(elem);
+        }
+    }
+
+    public static class ExtDTD extends DTD {
+        public boolean debugOut = true;
+        ExtDTD(final String name) {
+            super(name);
+        }
+
+        public void printDebugInfo(final String msg) {
+            Utils.printDebugInfo("Utils:ExtDTD:" + msg, debugOut);
+
+        }
+
+        protected AttributeList defAttributeList(final String arg0,
+                                                 final int arg1, final int arg2,
+                                                 final String arg3,
+                                                 final String arg4,
+                                                 final AttributeList arg5) {
+            AttributeList result = super.defAttributeList(arg0, arg1, arg2,
+                                                          arg3, arg4, arg5);
+            printDebugInfo("defAttributeList=" + result);
+            return result;
+        }
+        protected ContentModel defContentModel(final int arg0,
+                                               final Object arg1,
+                                               final ContentModel arg2) {
+            ContentModel result = super.defContentModel(arg0, arg1, arg2);
+            printDebugInfo("defContentModel=" + result);
+            return result;
+        }
+
+        protected Element defElement(final String name,
+                                     final int type,
+                                     final boolean o1,
+                                     final boolean o2,
+                                     final ContentModel model,
+                                     final String[] excl,
+                                     final String[] incl,
+                                     final AttributeList atts) {
+            Element e = super.defElement(name, type, o1, o2, model, excl,
+                                         incl, atts);
+            printDebugInfo("defElement(str)=" + e);
+            Utils.printElement(e, "(defElement)");
+            return e;
+        }
+        public Entity defEntity(final String arg0, final int arg1,
+                                final int arg2) {
+            Entity result = super.defEntity(arg0, arg1, arg2);
+            printDebugInfo("defEntity=" + result);
+            return result;
+        }
+        protected Entity defEntity(final String arg0, final int arg1,
+                                   final String arg2) {
+            Entity result = super.defEntity(arg0, arg1, arg2);
+            printDebugInfo("defEntity=" + result);
+            return result;
+        }
+
+        public void defineAttributes(final String arg0,
+                                     final AttributeList arg1) {
+            printDebugInfo("defineAttributes");
+            super.defineAttributes(arg0, arg1);
+        }
+
+        public  Element defineElement(final String name,
+                                      final int type,
+                                      final boolean o1,
+                                      final boolean o2,
+                                      final ContentModel model,
+                                      final BitSet excl,
+                                      final BitSet incl,
+                                      final AttributeList atts) {
+
+          Element e = super.defineElement(name, type, o1, o2, model,
+                                          excl, incl, atts);
+          printDebugInfo("defineElement=" + e);
+          //Utils.printElement(e, "(defineElement)");
+          return e;
+        }
+        public Entity defineEntity(final String arg0,
+                                   final int arg1,
+                                   final char[] arg2) {
+            Entity result = super.defineEntity(arg0, arg1, arg2);
+            printDebugInfo("defineEntity=" + result);
+            return result;
+        }
+        public Element getElement(final int arg0) {
+            Element result = super.getElement(arg0);
+            printDebugInfo("getElement(int)=" + result);
+            return result;
+        }
+        public Element getElement(final String arg0) {
+            Element result = super.getElement(arg0);
+            printDebugInfo("getElement(str)=" + result);
+            return result;
+        }
+        public Entity getEntity(final int arg0) {
+            Entity result = super.getEntity(arg0);
+            printDebugInfo("getEntity(int)=" + result);
+            return result;
+        }
+        public Entity getEntity(final String arg0) {
+            Entity result = super.getEntity(arg0);
+            printDebugInfo("getEntity(str)=" + result);
+            return result;
+        }
+        public String getName() {
+            printDebugInfo("getName " + super.getName());
+            return super.getName();
+        }
+        public void read(final DataInputStream arg0) throws IOException {
+            printDebugInfo("read");
+            super.read(arg0);
+        }
+        public String toString() {
+            printDebugInfo("toString");
+            return super.toString();
+        }
+    }
+
+    public static class ExtDocumentParser extends DocumentParser {
+        public boolean debugOut = true;
+
+        public int pos_d;
+
+        public HTML.Tag tag_d;
+
+        public ExtDocumentParser(final DTD dtd) {
+            super(dtd);
+        }
+
+        public void printDebugInfo(final String msg) {
+            Utils.printDebugInfo("Utils.ExtDocumentParser:" + msg, debugOut);
+        }
+        protected void handleComment(final char[] text) {
+            printDebugInfo("handleComment(text=" +  String.valueOf(text) + ")");
+            super.handleComment(text);
+        }
+
+        protected void handleEmptyTag(final TagElement tagElement)
+            throws ChangedCharSetException {
+            printDebugInfo("handleEmptyTag(tag=" + tagElement + ")");
+            super.handleEmptyTag(tagElement);
+        }
+
+        protected void handleEndTag(final TagElement tagElement) {
+            printDebugInfo("handleEndTag(tag=" + tagElement + ")");
+            super.handleEndTag(tagElement);
+        }
+
+        protected void handleError(final int pos, final String msg) {
+            printDebugInfo("handleError(pos=" + pos + ", msg=" + ")");
+            super.handleError(pos, msg);
+        }
+
+        protected void handleStartTag(final TagElement tagElement) {
+            printDebugInfo("handleStartTag(" + tagElement + ")");
+            pos_d = getCurrentPos();
+            tag_d = tagElement.getHTMLTag();
+            super.handleStartTag(tagElement);
+        }
+
+        protected void handleText(final char[] text) {
+            printDebugInfo("handleText(text=" + String.valueOf(text) + ")");
+            super.handleText(text);
+        }
+
+        public void parse(final Reader reader,
+                          final HTMLEditorKit.ParserCallback cb,
+                          final boolean ichs) throws IOException {
+            printDebugInfo("parse(reader=" + reader + ", cb=" + cb + ", "
+                           + "ichs=" + ichs);
+            super.parse(reader, cb, ichs);
+        }
+    }
+}



Mime
View raw message