harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r450327 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/html/parser/Entity.java test/api/java.injected/javax/swing/text/html/parser/EntityTest.java
Date Wed, 27 Sep 2006 05:50:03 GMT
Author: pyang
Date: Tue Sep 26 22:50:02 2006
New Revision: 450327

URL: http://svn.apache.org/viewvc?view=rev&rev=450327
Log:
Apply patch with modifications for HARMONY-1349 ([classlib][html] Compatibility: The values
stored in the public field type of j.s.t.h.p.Entity are different from those used in the RI)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Entity.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Entity.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Entity.java?view=diff&rev=450327&r1=450326&r2=450327
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Entity.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Entity.java
Tue Sep 26 22:50:02 2006
@@ -27,11 +27,10 @@
 
     public char[] data;
 
-    boolean isGeneral;
-
-    boolean isParameter;
-
-
+    private final static int GENERAL_MASK = DTDConstants.GENERAL;
+    
+    private final static int PARAMETER_MASK = DTDConstants.PARAMETER;
+    
     public Entity(final String name,
                   final int type,
                   final char[] data) {
@@ -45,22 +44,18 @@
            final String data,
            final boolean isGeneral,
            final boolean isParameter) {
-        this.name = name;
-        this.type = type;
-        this.data = data.toCharArray();
-        this.isGeneral = isGeneral;
-        this.isParameter = isParameter;
+        this (name, 
+                (type | 
+                        (isGeneral ? GENERAL_MASK : 0) | 
+                        (isParameter ? PARAMETER_MASK : 0)), 
+                data.toCharArray());
     }
 
     Entity(final String name,
            final char ch) {
-        this.name = name;
-        this.type = DTDConstants.CDATA;
-        this.data = new char[] {ch};
-        this.isGeneral = true;
+        this(name, DTDConstants.CDATA | GENERAL_MASK, new char[] {ch});
     }
 
-
     public String getString() {
         return String.valueOf(data);
     }
@@ -70,17 +65,15 @@
     }
 
     public boolean isGeneral() {
-        // TODO: implement
-        return isGeneral;
+        return (type & GENERAL_MASK) != 0;
     }
 
     public boolean isParameter() {
-        // TODO: implement
-        return isParameter;
+        return (type & PARAMETER_MASK) != 0;
     }
 
     public int getType() {
-        return type;
+        return type & 0xFFFF;
     }
 
     public String getName() {
@@ -108,6 +101,5 @@
             return DTDConstants.CDATA;
         }
     }
-
 }
 

Modified: 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?view=diff&rev=450327&r1=450326&r2=450327
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/parser/EntityTest.java
Tue Sep 26 22:50:02 2006
@@ -43,13 +43,28 @@
     }
 
     //TODO Investigate how is it defined.
-    public void testIsGeneral() {
-
+    public void testIsGeneral() throws Exception{
+        Entity entity2 = new Entity("name", DTDConstants.GENERAL, new char[0]); //$NON-NLS-1$
+        assertTrue(entity2.isGeneral());
+        
+        entity2 = new Entity("name", DTDConstants.GENERAL | DTDConstants.CDATA, new char[0]);
//$NON-NLS-1$
+        assertTrue(entity2.isGeneral());
+        
+        entity2 = new Entity("name", DTDConstants.CDATA, new char[0]); //$NON-NLS-1$
+        assertFalse(entity2.isGeneral());
     }
 
     //TODO Investigate how is it defined.
-    public void testIsParameter() {
-
+    public void testIsParameter() throws Exception{
+        //regression for HARMONY-1349
+        Entity entity2 = new Entity("name", DTDConstants.PARAMETER, new char[0]); //$NON-NLS-1$
+        assertTrue(entity2.isParameter());
+        
+        entity2 = new Entity("name", DTDConstants.PARAMETER | DTDConstants.CDATA, new char[0]);
//$NON-NLS-1$
+        assertTrue(entity2.isParameter());
+        
+        entity2 = new Entity("name", DTDConstants.CDATA, new char[0]); //$NON-NLS-1$
+        assertFalse(entity2.isParameter());
     }
 
     public void testName2type() {
@@ -77,5 +92,16 @@
                 assertEquals(DTDConstants.CDATA, value);
             }
         }
+    }
+    
+    /**
+     * @test javax.swing.text.html.parser.Entity#getType()
+     */
+    public void testType() throws Exception{
+        //regression for HARMONY-1349
+        DTD dtd = DTD.getDTD("dummy"); //$NON-NLS-1$
+        Entity space = dtd.getEntity("#SPACE"); //$NON-NLS-1$
+        assertEquals(65536, space.type);
+        assertEquals(0, space.getType()); 
     }
 }



Mime
View raw message