Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 86882 invoked from network); 27 Sep 2006 05:50:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Sep 2006 05:50:08 -0000 Received: (qmail 46913 invoked by uid 500); 27 Sep 2006 05:50:07 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 46882 invoked by uid 500); 27 Sep 2006 05:50:07 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 46871 invoked by uid 99); 27 Sep 2006 05:50:07 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Sep 2006 22:50:07 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=pyang@apache.org; spf=permerror X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received-SPF: error (idunn.apache.osuosl.org: domain apache.org from 140.211.166.113 cause and error) Received: from [140.211.166.113] ([140.211.166.113:55198] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id EE/40-22638-D011A154 for ; Tue, 26 Sep 2006 22:50:07 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id BC66B1A981A; Tue, 26 Sep 2006 22:50:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060927055003.BC66B1A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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()); } }