Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 91180 invoked from network); 25 Oct 2007 10:53:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Oct 2007 10:53:25 -0000 Received: (qmail 32744 invoked by uid 500); 25 Oct 2007 10:53:13 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 32726 invoked by uid 500); 25 Oct 2007 10:53:13 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 32712 invoked by uid 99); 25 Oct 2007 10:53:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 03:53:13 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 10:53:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7028A1A9832; Thu, 25 Oct 2007 03:52:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r588195 - in /harmony/enhanced/classlib/trunk: depends/files/ depends/jars/icu4j_3.8/ depends/manifests/icu4j_3.4.4/ depends/manifests/icu4j_3.8/ depends/manifests/icu4j_3.8/META-INF/ depends/manifests/icu4jni_3.4/ make/ modules/luni/src/te... Date: Thu, 25 Oct 2007 10:52:46 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071025105252.7028A1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: odeakin Date: Thu Oct 25 03:52:32 2007 New Revision: 588195 URL: http://svn.apache.org/viewvc?rev=588195&view=rev Log: Move classlib to use icu4j 3.8, removing icu4c and icu4jni dependencies. Added: harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/ harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-3_8.jar (with props) harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-charsets-3_8.jar (with props) harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/ harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/ harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF Removed: harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.4.4/ harmony/enhanced/classlib/trunk/depends/manifests/icu4jni_3.4/ harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java harmony/enhanced/classlib/trunk/modules/text/src/main/native/ Modified: harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties harmony/enhanced/classlib/trunk/make/build-java.xml harmony/enhanced/classlib/trunk/make/build-native.xml harmony/enhanced/classlib/trunk/make/depends.properties harmony/enhanced/classlib/trunk/make/depends.xml harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/InputStreamReaderTest.java harmony/enhanced/classlib/trunk/modules/nio_char/META-INF/MANIFEST.MF harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/org/apache/harmony/niochar/java.nio.charset.spi.CharsetProvider harmony/enhanced/classlib/trunk/modules/text/build.xml harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java Modified: harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties (original) +++ harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties Thu Oct 25 03:52:32 2007 @@ -163,10 +163,10 @@ bootclasspath.source.30=xml-src.jar bootclasspath.source.packageroot.30=/ -# ICU functionality for text/characters is provided by JNI wrappers -# to ICU4C and pure-Java implementation in the ICU4J JAR file. -bootclasspath.32=icu4jni_3.4/icu4jni-3.4.jar -bootclasspath.33=icu4j_3.4.4/icu4j_3_4_4.jar +# ICU functionality for text/characters are provided by the ICU4J +# and ICU4J-charsets JAR files. +bootclasspath.31=icu4j_3.8/icu4j-3_8.jar +bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar # The following JARs are from Xerces/Xalan bootclasspath.34=xalan-j_2.7.0/xalan.jar Added: harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-3_8.jar URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-3_8.jar?rev=588195&view=auto ============================================================================== Binary file - no diff available. Propchange: harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-3_8.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-charsets-3_8.jar URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-charsets-3_8.jar?rev=588195&view=auto ============================================================================== Binary file - no diff available. Propchange: harmony/enhanced/classlib/trunk/depends/jars/icu4j_3.8/icu4j-charsets-3_8.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF?rev=588195&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF (added) +++ harmony/enhanced/classlib/trunk/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF Thu Oct 25 03:52:32 2007 @@ -0,0 +1,25 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ICU4J +Bundle-SymbolicName: com.ibm.icu4j;singleton:=true +Bundle-Version: 3.8 +Bundle-ClassPath: icu4j-3_8.jar +Eclipse-JREBundle: true +Import-Package: java.io, + java.lang, + java.lang.ref, + java.lang.reflect, + java.math, + java.net, + java.nio, + java.nio.charset, + java.security, + java.text, + java.util, + java.util.jar, + java.util.regex, + java.util.zip +Export-Package: com.ibm.icu.lang, + com.ibm.icu.math, + com.ibm.icu.text, + com.ibm.icu.util Modified: harmony/enhanced/classlib/trunk/make/build-java.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/make/build-java.xml (original) +++ harmony/enhanced/classlib/trunk/make/build-java.xml Thu Oct 25 03:52:32 2007 @@ -202,8 +202,7 @@ - - + Modified: harmony/enhanced/classlib/trunk/make/build-native.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-native.xml?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/make/build-native.xml (original) +++ harmony/enhanced/classlib/trunk/make/build-native.xml Thu Oct 25 03:52:32 2007 @@ -68,8 +68,7 @@ - - + @@ -92,8 +91,7 @@ - - + Modified: harmony/enhanced/classlib/trunk/make/depends.properties URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/depends.properties?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/make/depends.properties (original) +++ harmony/enhanced/classlib/trunk/make/depends.properties Thu Oct 25 03:52:32 2007 @@ -55,11 +55,6 @@ msvcr.url.x86_64=file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%208/VC/redist/amd64/Microsoft.VC80.CRT/msvcr80.dll msvcr.md5.x86_64=465cebd7da2ceaba5e552fc9118a1415 -icu4j.dir=${depends.jars}/icu4j_3.4.4 -icu4j.jar=${icu4j.dir}/icu4j_3_4_4.jar -icu4j.url=${maven2.base}/com/ibm/icu/icu4j/3.4.4/icu4j-3.4.4.jar -icu4j.md5=92422a9465ccc608bc7a8ae9cf594509 - mx4j.dir=${depends.jars}/mx4j_3.0.2 mx4j.zip=${mx4j.dir}/mx4j.zip mx4j.url=${sf.base}/mx4j/mx4j-3.0.2.zip @@ -132,4 +127,5 @@ derby.jar=${derby.dir}/derby.jar derby.url=http://www.ibiblio.org/maven/org.apache.derby/jars/derby-10.3.1.4.jar derby.md5=f28d6047ab26445de53c4c96126494df + Modified: harmony/enhanced/classlib/trunk/make/depends.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/depends.xml?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/make/depends.xml (original) +++ harmony/enhanced/classlib/trunk/make/depends.xml Thu Oct 25 03:52:32 2007 @@ -41,7 +41,6 @@ - @@ -366,10 +365,6 @@ - - - - - - - - - - - - - - - - - - - - - - Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java (original) +++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java Thu Oct 25 03:52:32 2007 @@ -17,13 +17,6 @@ package java.text; -import java.awt.font.NumericShaper; -import java.awt.font.TextAttribute; -import java.util.Arrays; -import java.util.LinkedList; - -import org.apache.harmony.text.BidiRun; -import org.apache.harmony.text.BidiWrapper; import org.apache.harmony.text.internal.nls.Messages; /** @@ -45,25 +38,31 @@ public final class Bidi { /** * Constant that indicates the default base level. If there is no strong - * character, then set the paragraph level to 0 (left-to-right). + * character, then set the paragraph level to left-to-right. */ - public static final int DIRECTION_DEFAULT_LEFT_TO_RIGHT = -2; + public static final int DIRECTION_DEFAULT_LEFT_TO_RIGHT = com.ibm.icu.text.Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT; /** * Constant that indicates the default base level. If there is no strong - * character, then set the paragraph level to 1 (right-to-left). + * character, then set the paragraph level to right-to-left. */ - public static final int DIRECTION_DEFAULT_RIGHT_TO_LEFT = -1; + public static final int DIRECTION_DEFAULT_RIGHT_TO_LEFT = com.ibm.icu.text.Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT; /** - * Constant that specifies the default base level as 0 (left-to-right). + * Constant that specifies the default base level as + * left-to-right. */ - public static final int DIRECTION_LEFT_TO_RIGHT = 0; + public static final int DIRECTION_LEFT_TO_RIGHT = com.ibm.icu.text.Bidi.DIRECTION_LEFT_TO_RIGHT; /** - * Constant that specifies the default base level as 1 (right-to-left). + * Constant that specifies the default base level right-to-left. + */ + public static final int DIRECTION_RIGHT_TO_LEFT = com.ibm.icu.text.Bidi.DIRECTION_RIGHT_TO_LEFT; + + /* + * Use an embedded ICU4J Bidi object to do all the work */ - public static final int DIRECTION_RIGHT_TO_LEFT = 1; + private com.ibm.icu.text.Bidi icuBidi; /** * Create a Bidi object from the AttributedCharacterIterator of a paragraph @@ -97,64 +96,7 @@ throw new IllegalArgumentException(Messages.getString("text.14")); //$NON-NLS-1$ } - int begin = paragraph.getBeginIndex(); - int end = paragraph.getEndIndex(); - int length = end - begin; - char text[] = new char[length + 1]; // One more char for - // AttributedCharacterIterator.DONE - - if (length != 0) { - text[0] = paragraph.first(); - } else { - paragraph.first(); - } - - // First check the RUN_DIRECTION attribute. - int flags = DIRECTION_DEFAULT_LEFT_TO_RIGHT; - Object direction = paragraph.getAttribute(TextAttribute.RUN_DIRECTION); - if (direction != null && direction instanceof Boolean) { - if (direction.equals(TextAttribute.RUN_DIRECTION_LTR)) { - flags = DIRECTION_LEFT_TO_RIGHT; - } else { - flags = DIRECTION_RIGHT_TO_LEFT; - } - } - - // Retrieve the text and gather BIDI_EMBEDDINGS - byte embeddings[] = null; - for (int textLimit = 1, i = 1; i < length; textLimit = paragraph - .getRunLimit(TextAttribute.BIDI_EMBEDDING) - - begin + 1) { - Object embedding = paragraph - .getAttribute(TextAttribute.BIDI_EMBEDDING); - if (embedding != null && embedding instanceof Integer) { - int embLevel = ((Integer) embedding).intValue(); - - if (embeddings == null) { - embeddings = new byte[length]; - } - - for (; i < textLimit; i++) { - text[i] = paragraph.next(); - embeddings[i - 1] = (byte) embLevel; - } - } else { - for (; i < textLimit; i++) { - text[i] = paragraph.next(); - } - } - } - - // Apply NumericShaper to the text - Object numericShaper = paragraph - .getAttribute(TextAttribute.NUMERIC_SHAPING); - if (numericShaper != null && numericShaper instanceof NumericShaper) { - ((NumericShaper) numericShaper).shape(text, 0, length); - } - - long pBidi = createUBiDi(text, 0, embeddings, 0, length, flags); - readBidiInfo(pBidi); - BidiWrapper.ubidi_close(pBidi); + icuBidi = new com.ibm.icu.text.Bidi(paragraph); } /** @@ -191,6 +133,17 @@ */ public Bidi(char[] text, int textStart, byte[] embeddings, int embStart, int paragraphLength, int flags) { + + if (text == null || text.length - textStart < paragraphLength) { + throw new IllegalArgumentException(); + } + + if (embeddings != null) { + if (embeddings.length - embStart < paragraphLength) { + throw new IllegalArgumentException(); + } + } + if (textStart < 0) { // text.0D=Negative textStart value {0} throw new IllegalArgumentException(Messages.getString( @@ -206,10 +159,8 @@ throw new IllegalArgumentException(Messages.getString( "text.11", paragraphLength)); //$NON-NLS-1$ } - long pBidi = createUBiDi(text, textStart, embeddings, embStart, - paragraphLength, flags); - readBidiInfo(pBidi); - BidiWrapper.ubidi_close(pBidi); + + icuBidi = new com.ibm.icu.text.Bidi(text, textStart, embeddings, embStart, paragraphLength, flags); } /** @@ -234,104 +185,18 @@ (paragraph == null ? 0 : paragraph.length()), flags); } - // create the native UBiDi struct, need to be closed with ubidi_close(). - private static long createUBiDi(char[] text, int textStart, - byte[] embeddings, int embStart, int paragraphLength, int flags) { - char[] realText = null; - - byte[] realEmbeddings = null; - - if (text == null || text.length - textStart < paragraphLength) { - throw new IllegalArgumentException(); - } - realText = new char[paragraphLength]; - System.arraycopy(text, textStart, realText, 0, paragraphLength); - - if (embeddings != null) { - if (embeddings.length - embStart < paragraphLength) { - throw new IllegalArgumentException(); - } - if (paragraphLength > 0) { - Bidi temp = new Bidi(text, textStart, null, 0, paragraphLength, - flags); - realEmbeddings = new byte[paragraphLength]; - System.arraycopy(temp.offsetLevel, 0, realEmbeddings, 0, - paragraphLength); - for (int i = 0; i < paragraphLength; i++) { - byte e = embeddings[i]; - if (e < 0) { - realEmbeddings[i] = (byte) (BidiWrapper.UBIDI_LEVEL_OVERRIDE - e); - } else if (e > 0) { - realEmbeddings[i] = e; - } else { - realEmbeddings[i] |= (byte) BidiWrapper.UBIDI_LEVEL_OVERRIDE; - } - } - } - } - - if (flags > 1 || flags < -2) { - flags = 0; - } - - long bidi = BidiWrapper.ubidi_open(); - BidiWrapper.ubidi_setPara(bidi, realText, paragraphLength, - (byte) flags, realEmbeddings); - return bidi; - } - - // private constructor, used by createLineBidi() - private Bidi(long pBidi) { - readBidiInfo(pBidi); - } - - // read info from the native UBiDi struct - private void readBidiInfo(long pBidi) { - - length = BidiWrapper.ubidi_getLength(pBidi); - - offsetLevel = (length == 0) ? null : BidiWrapper.ubidi_getLevels(pBidi); - - baseLevel = BidiWrapper.ubidi_getParaLevel(pBidi); - - int runCount = BidiWrapper.ubidi_countRuns(pBidi); - if (runCount == 0) { - unidirectional = true; - runs = null; - } else if (runCount < 0) { - runs = null; - } else { - runs = BidiWrapper.ubidi_getRuns(pBidi); - - // Simplified case for one run which has the base level - if (runCount == 1 && runs[0].getLevel() == baseLevel) { - unidirectional = true; - runs = null; - } - } - - direction = BidiWrapper.ubidi_getDirection(pBidi); + /* private constructor used by createLineBidi() */ + private Bidi(com.ibm.icu.text.Bidi bidi) { + this.icuBidi = bidi; } - private int baseLevel; - - private int length; - - private byte[] offsetLevel; - - private BidiRun[] runs; - - private int direction; - - private boolean unidirectional; - /** * Return whether the base level is from left to right. * * @return true if the base level is from left to right. */ public boolean baseIsLeftToRight() { - return baseLevel % 2 == 0 ? true : false; + return icuBidi.baseIsLeftToRight(); } /** @@ -346,29 +211,17 @@ * range from 0 to (limit - start - 1). */ public Bidi createLineBidi(int lineStart, int lineLimit) { + int length = icuBidi.getLength(); if (lineStart < 0 || lineLimit < 0 || lineLimit > length || lineStart > lineLimit) { // text.12=Invalid ranges (start={0}, limit={1}, length={2}) throw new IllegalArgumentException(Messages.getString( "text.12", new Object[] { lineStart, lineLimit, length })); //$NON-NLS-1$ } - char[] text = new char[this.length]; - Arrays.fill(text, 'a'); - byte[] embeddings = new byte[this.length]; - for (int i = 0; i < embeddings.length; i++) { - embeddings[i] = (byte) -this.offsetLevel[i]; - } - - int dir = this.baseIsLeftToRight() ? Bidi.DIRECTION_LEFT_TO_RIGHT - : Bidi.DIRECTION_RIGHT_TO_LEFT; - - long parent = createUBiDi(text, 0, embeddings, 0, this.length, dir); - - long line = BidiWrapper.ubidi_setLine(parent, lineStart, lineLimit); - Bidi result = new Bidi(line); - BidiWrapper.ubidi_close(line); - BidiWrapper.ubidi_close(parent); - return result; + + com.ibm.icu.text.Bidi lineBidi = icuBidi.createLineBidi(lineStart, lineLimit); + Bidi bidi = new Bidi(lineBidi); + return bidi; } /** @@ -377,7 +230,7 @@ * @return the int value of the base level. */ public int getBaseLevel() { - return baseLevel; + return icuBidi.getBaseLevel(); } /** @@ -386,7 +239,7 @@ * @return the int value of the length. */ public int getLength() { - return length; + return icuBidi.getLength(); } /** @@ -398,9 +251,9 @@ */ public int getLevelAt(int offset) { try { - return offsetLevel[offset] & ~BidiWrapper.UBIDI_LEVEL_OVERRIDE; + return icuBidi.getLevelAt(offset); } catch (RuntimeException e) { - return baseLevel; + return icuBidi.getBaseLevel(); } } @@ -410,7 +263,8 @@ * @return the int value of runs, at least 1. */ public int getRunCount() { - return unidirectional ? 1 : runs.length; + int runCount = icuBidi.getRunCount(); + return (runCount < 1) ? 1 : runCount; } /** @@ -421,7 +275,11 @@ * @return the level of the run. */ public int getRunLevel(int run) { - return unidirectional ? baseLevel : runs[run].getLevel(); + if (icuBidi.getRunCount() == 0) { + return icuBidi.getBaseLevel(); + } else { + return icuBidi.getRunLevel(run); + } } /** @@ -432,7 +290,11 @@ * @return the limit offset of the run. */ public int getRunLimit(int run) { - return unidirectional ? length : runs[run].getLimit(); + if (icuBidi.getRunCount() == 0) { + return icuBidi.getLength(); + } else { + return icuBidi.getRunLimit(run); + } } /** @@ -443,7 +305,11 @@ * @return the start offset of the run. */ public int getRunStart(int run) { - return unidirectional ? 0 : runs[run].getStart(); + if (icuBidi.getRunCount() == 0) { + return 0; + } else { + return icuBidi.getRunStart(run); + } } /** @@ -453,7 +319,7 @@ * @return true if the text is from left to right. */ public boolean isLeftToRight() { - return direction == BidiWrapper.UBiDiDirection_UBIDI_LTR; + return icuBidi.isLeftToRight(); } /** @@ -462,7 +328,7 @@ * @return true if the text direction is mixed. */ public boolean isMixed() { - return direction == BidiWrapper.UBiDiDirection_UBIDI_MIXED; + return icuBidi.isMixed(); } /** @@ -472,7 +338,7 @@ * @return true if the text is from right to left. */ public boolean isRightToLeft() { - return direction == BidiWrapper.UBiDiDirection_UBIDI_RTL; + return icuBidi.isRightToLeft(); } /** @@ -504,17 +370,8 @@ new Object[] { levels.length, levelStart, objects.length, objectStart, count })); } - byte[] realLevels = new byte[count]; - System.arraycopy(levels, levelStart, realLevels, 0, count); - int[] indices = BidiWrapper.ubidi_reorderVisual(realLevels, count); - - LinkedList result = new LinkedList(); - for (int i = 0; i < count; i++) { - result.addLast(objects[objectStart + indices[i]]); - } - - System.arraycopy(result.toArray(), 0, objects, objectStart, count); + com.ibm.icu.text.Bidi.reorderVisually(levels, levelStart, objects, objectStart, count); } /** @@ -530,12 +387,12 @@ * @return true if the range of characters requires a Bidi object. */ public static boolean requiresBidi(char[] text, int start, int limit) { - int length = text.length; - if (limit < 0 || start < 0 || start > limit || limit > length) { + //int length = text.length; + if (limit < 0 || start < 0 || start > limit || limit > text.length) { throw new IllegalArgumentException(); } - Bidi bidi = new Bidi(text, start, null, 0, limit - start, 0); - return !bidi.isLeftToRight(); + + return com.ibm.icu.text.Bidi.requiresBidi(text, start, limit); } /** @@ -545,8 +402,6 @@ */ @Override public String toString() { - return super.toString() - + "[direction: " + direction + " baselevel: " + baseLevel //$NON-NLS-1$ //$NON-NLS-2$ - + " length: " + length + " runs: " + (unidirectional ? "null" : runs.toString()) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + return icuBidi.toString(); } } Modified: harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java?rev=588195&r1=588194&r2=588195&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java Thu Oct 25 03:52:32 2007 @@ -781,7 +781,7 @@ } public void testCreateLineBidi() { - bd = new Bidi("a\u05D0a\na\u05D0\"\u05D0a".toCharArray(), 0, + bd = new Bidi("a\u05D0a\u05D0a\u05D0\"\u05D0a".toCharArray(), 0, new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9, Bidi.DIRECTION_RIGHT_TO_LEFT); Bidi line = bd.createLineBidi(2, 7); @@ -789,14 +789,14 @@ assertEquals(1, line.getBaseLevel()); assertEquals(5, line.getLength()); assertEquals(2, line.getLevelAt(0)); - assertEquals(1, line.getLevelAt(1)); + assertEquals(3, line.getLevelAt(1)); assertEquals(3, line.getLevelAt(2)); assertEquals(3, line.getLevelAt(3)); assertEquals(2, line.getLevelAt(4)); assertEquals(1, line.getLevelAt(1000)); - assertEquals(4, line.getRunCount()); - assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 }, - { 2, 4, 3 }, { 4, 5, 2 }, }, line); + assertEquals(3, line.getRunCount()); + assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 4, 3 }, + { 4, 5, 2 }, }, line); assertFalse(line.isLeftToRight()); assertTrue(line.isMixed()); assertFalse(line.isRightToLeft()); @@ -832,8 +832,12 @@ } catch (IllegalArgumentException e) { // Expected } - - bidi.createLineBidi(2, 2); + + try { + bidi.createLineBidi(2, 2); + }catch (IllegalArgumentException e){ + // Expected + } try { bidi.createLineBidi(2, 4); @@ -961,18 +965,29 @@ bd = new Bidi("text", Bidi.DIRECTION_LEFT_TO_RIGHT); try { assertTrue(4 == bd.getRunLimit(-1)); + } catch (IllegalArgumentException e) { + // Expected for illegal run limit + return; } catch (Exception e) { fail("Unexpected exception: " + e); } + + fail("Expected IllegalArgumentException to be thrown for invalid run limit"); } + public void testBidiConstructor_Iterator() { AttributedString paragraph = new AttributedString("text"); bd = new Bidi(paragraph.getIterator()); try { assertTrue(4 == bd.getRunLimit(1)); + } catch (IllegalArgumentException e) { + // Expected for illegal run limit + return; } catch (Exception e) { fail("Unexpected exception: " + e); } + + fail("Expected IllegalArgumentException to be thrown for invalid run limit"); } }