Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 37294 invoked from network); 2 Aug 2006 06:00:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Aug 2006 06:00:08 -0000 Received: (qmail 52786 invoked by uid 500); 2 Aug 2006 06:00:08 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 52750 invoked by uid 500); 2 Aug 2006 06:00:08 -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 52739 invoked by uid 99); 2 Aug 2006 06:00:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Aug 2006 23:00:07 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Aug 2006 23:00:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id AB4E21A981A; Tue, 1 Aug 2006 22:59:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r427906 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Locale.java test/java/tests/api/java/util/LocaleTest.java Date: Wed, 02 Aug 2006 05:59:46 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060802055946.AB4E21A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: pyang Date: Tue Aug 1 22:59:45 2006 New Revision: 427906 URL: http://svn.apache.org/viewvc?rev=427906&view=rev Log: Fix for HARMONY-1027 ([classlib][luni] java.util.Locale.toString() returns wrong value) Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java?rev=427906&r1=427905&r2=427906&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java Tue Aug 1 22:59:45 2006 @@ -1,4 +1,4 @@ -/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +/* Copyright 1998, 2006 The Apache 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. @@ -219,11 +219,11 @@ languageCode = language.toLowerCase(); // Map new language codes to the obsolete language // codes so the correct resource bundles will be used. - if (languageCode.equals("he")) { + if (languageCode.equals("he")) {//$NON-NLS-1$ languageCode = "iw"; //$NON-NLS-1$ - } else if (languageCode.equals("id")) { + } else if (languageCode.equals("id")) {//$NON-NLS-1$ languageCode = "in"; //$NON-NLS-1$ - } else if (languageCode.equals("yi")) { + } else if (languageCode.equals("yi")) {//$NON-NLS-1$ languageCode = "ji"; //$NON-NLS-1$ } @@ -307,6 +307,7 @@ } } } catch (IOException e) { + //Empty } } else { // Handle ZIP/JAR files. @@ -317,12 +318,13 @@ ZipEntry e = entries.nextElement(); String name = e.getName(); if (name.startsWith(prefix) - && name.endsWith(".class")) { + && name.endsWith(".class")) {//$NON-NLS-1$ result.add(name); } } zip.close(); } catch (IOException e) { + // Empty } } } @@ -612,6 +614,7 @@ bundle.getString("CS"); //$NON-NLS-1$ hasCS = true; } catch (MissingResourceException e) { + //Empty } Enumeration keys = bundle.getKeys(); // to initialize the table @@ -623,7 +626,7 @@ int index = 0; while (keys.hasMoreElements()) { String element = keys.nextElement(); - if (!element.equals("CS")) { + if (!element.equals("CS")) {//$NON-NLS-1$ result[index++] = element; } } @@ -706,14 +709,14 @@ * @return the string representation of this Locale */ public final String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(languageCode); if (countryCode.length() > 0) { result.append('_'); result.append(countryCode); } - if (variantCode.length() > 0) { - if (countryCode.length() == 0) { + if (variantCode.length() > 0 && result.length() > 0 ) { + if (0 == countryCode.length()) { result.append("__"); //$NON-NLS-1$ } else { result.append('_'); Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java?rev=427906&r1=427905&r2=427906&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java Tue Aug 1 22:59:45 2006 @@ -1,4 +1,4 @@ -/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +/* Copyright 1998, 2006 The Apache 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. @@ -320,6 +320,10 @@ assertEquals("Wrong representation 6", "en_CA", l.toString()); l = new Locale("en", "CA", "VAR"); assertEquals("Wrong representation 7", "en_CA_VAR", l.toString()); + + l = new Locale("", "", "var"); + assertEquals("Wrong representation 8", "", l.toString()); + } /**