Added Utility.getChars() and modified the rest of the classes that use StringBuffer.getChars().

X-SVN-Rev: 7309
This commit is contained in:
Syn Wee Quek 2001-12-04 20:09:08 +00:00
parent 5e119cd4aa
commit 55e323ecd8
14 changed files with 106 additions and 48 deletions

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/lang/UTF16Test.java,v $
* $Date: 2001/09/06 16:32:54 $
* $Revision: 1.8 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.9 $
*
*******************************************************************************
*/
@ -16,6 +16,7 @@ package com.ibm.icu.test.text;
import com.ibm.test.TestFmwk;
import com.ibm.text.UCharacter;
import com.ibm.text.UTF16;
import com.ibm.util.Utility;
/**
* Testing class for UTF16
@ -45,7 +46,7 @@ public final class UTF16Test extends TestFmwk
int strsize = strbuff.length();
int arraysize = strsize;
strbuff.getChars(0, strsize, array, 0);
Utility.getChars(strbuff, 0, strsize, array, 0);
for (int i = 1; i < UCharacter.MAX_VALUE; i += 100)
{
UTF16.append(strbuff, i);
@ -476,7 +477,7 @@ public final class UTF16Test extends TestFmwk
{
StringBuffer strbuff = new StringBuffer("0123456789");
char array[] = new char[128];
strbuff.getChars(0, strbuff.length(), array, 0);
Utility.getChars(strbuff, 0, strbuff.length(), array, 0);
int length = 10;
UTF16.insert(strbuff, 5, 't');
UTF16.insert(strbuff, 5, 's');
@ -657,7 +658,7 @@ public final class UTF16Test extends TestFmwk
{
StringBuffer strbuff = new StringBuffer("012345");
char array[] = new char[128];
strbuff.getChars(0, strbuff.length(), array, 0);
Utility.getChars(strbuff, 0, strbuff.length(), array, 0);
int length = 6;
for (int i = 0; i < length; i ++) {
UTF16.setCharAt(strbuff, i, '0');

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/rbbi/BuildDictionaryFile.java,v $
* $Date: 2000/09/22 18:58:26 $
* $Revision: 1.1 $
* $Date: 2001/12/04 20:09:08 $
* $Revision: 1.2 $
*
*****************************************************************************************
*/
@ -14,6 +14,7 @@ package com.ibm.tools.rbbi;
import com.ibm.util.CompactByteArray;
import com.ibm.text.UnicodeSet;
import com.ibm.util.Utility;
import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
@ -114,7 +115,7 @@ int totalChars = 0;
//System.out.println(tempReverseMap.toString());
reverseColumnMap = new char[p];
tempReverseMap.getChars(0, p, reverseColumnMap, 0);
Utility.getChars(tempReverseMap, 0, p, reverseColumnMap, 0);
System.out.println("total columns = " + p);
numCols = p;

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/Utility.java,v $
* $Date: 2001/12/03 18:35:33 $
* $Revision: 1.17 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.18 $
*
*****************************************************************************************
*/
@ -1235,4 +1235,26 @@ public final class Utility {
Transliterator.Position pos) {
return formatInput(appendTo, (ReplaceableString) input, pos);
}
/**
* Similar to StringBuffer.getChars, version 1.3.
* Since JDK 1.2 implements StringBuffer.getChars differently, this method
* is here to provide consistent results.
* To be removed after JDK 1.2 ceased to be the reference platform.
* @param src source string buffer
* @param srcBegin offset to the start of the src to retrieve from
* @param srcEnd offset to the end of the src to retrieve from
* @param dst char array to store the retrieved chars
* @param dstBegin offset to the start of the destination char array to
* store the retrieved chars
* @draft since ICU4J 2.0
*/
public static void getChars(StringBuffer src, int srcBegin, int srcEnd,
char dst[], int dstBegin)
{
if (srcBegin == srcEnd) {
return;
}
src.getChars(srcBegin, srcEnd, dst, dstBegin);
}
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/lang/UCharacter.java,v $
* $Date: 2001/12/03 20:59:00 $
* $Revision: 1.19 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.20 $
*
*******************************************************************************
*/
@ -15,6 +15,7 @@
package com.ibm.text;
import java.util.Locale;
import com.ibm.util.Utility;
/**
* <p>
@ -1222,7 +1223,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialLowerCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_LOWERCASE_)) {
@ -1264,7 +1265,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialUpperCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_UPPERCASE_)) {
@ -1313,7 +1314,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialUpperCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_UPPERCASE_)) {

View file

@ -2,6 +2,7 @@
/* Options: Binary Comments Crossref Format Java Logo Strictargs Strictcase Trace2 Verbose3 */
package com.ibm.math;
import java.math.BigInteger;
import com.ibm.util.Utility;
/* ------------------------------------------------------------------ */
/* BigDecimal -- Decimal arithmetic for Java */
@ -3424,7 +3425,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
sb.append('E').append(csign).append(euse);
}
rec=new char[sb.length()];
sb.getChars(0,sb.length(),rec,0);
Utility.getChars(sb, 0,sb.length(),rec,0);
return rec;
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/test/text/Attic/UTF16Test.java,v $
* $Date: 2001/09/06 16:32:54 $
* $Revision: 1.8 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.9 $
*
*******************************************************************************
*/
@ -16,6 +16,7 @@ package com.ibm.icu.test.text;
import com.ibm.test.TestFmwk;
import com.ibm.text.UCharacter;
import com.ibm.text.UTF16;
import com.ibm.util.Utility;
/**
* Testing class for UTF16
@ -45,7 +46,7 @@ public final class UTF16Test extends TestFmwk
int strsize = strbuff.length();
int arraysize = strsize;
strbuff.getChars(0, strsize, array, 0);
Utility.getChars(strbuff, 0, strsize, array, 0);
for (int i = 1; i < UCharacter.MAX_VALUE; i += 100)
{
UTF16.append(strbuff, i);
@ -476,7 +477,7 @@ public final class UTF16Test extends TestFmwk
{
StringBuffer strbuff = new StringBuffer("0123456789");
char array[] = new char[128];
strbuff.getChars(0, strbuff.length(), array, 0);
Utility.getChars(strbuff, 0, strbuff.length(), array, 0);
int length = 10;
UTF16.insert(strbuff, 5, 't');
UTF16.insert(strbuff, 5, 's');
@ -657,7 +658,7 @@ public final class UTF16Test extends TestFmwk
{
StringBuffer strbuff = new StringBuffer("012345");
char array[] = new char[128];
strbuff.getChars(0, strbuff.length(), array, 0);
Utility.getChars(strbuff, 0, strbuff.length(), array, 0);
int length = 6;
for (int i = 0; i < length; i ++) {
UTF16.setCharAt(strbuff, i, '0');

View file

@ -5,13 +5,14 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Attic/HexToUnicodeTransliterator.java,v $
* $Date: 2001/09/28 20:27:02 $
* $Revision: 1.10 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.11 $
*
*****************************************************************************************
*/
package com.ibm.text;
import java.util.*;
import com.ibm.util.Utility;
/**
* A transliterator that converts from hexadecimal Unicode escape
@ -23,7 +24,7 @@ import java.util.*;
* applyPattern() for details.
*
* @author Alan Liu
* @version $RCSfile: HexToUnicodeTransliterator.java,v $ $Revision: 1.10 $ $Date: 2001/09/28 20:27:02 $
* @version $RCSfile: HexToUnicodeTransliterator.java,v $ $Revision: 1.11 $ $Date: 2001/12/04 20:09:07 $
*/
public class HexToUnicodeTransliterator extends Transliterator {
private static final String COPYRIGHT =
@ -252,7 +253,7 @@ public class HexToUnicodeTransliterator extends Transliterator {
this.pattern = pattern;
int len = affixes.length();
this.affixes = new char[len];
affixes.getChars(0, len, this.affixes, 0);
Utility.getChars(affixes, 0, len, this.affixes, 0);
}
/**

View file

@ -5,13 +5,15 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/ReplaceableString.java,v $
* $Date: 2001/11/21 21:19:57 $
* $Revision: 1.6 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.7 $
*
*****************************************************************************************
*/
package com.ibm.text;
import com.ibm.util.Utility;
/**
* <code>ReplaceableString</code> is an adapter class that implements the
* <code>Replaceable</code> API around an ordinary <code>StringBuffer</code>.
@ -24,7 +26,7 @@ package com.ibm.text;
*
* @see Replaceable
* @author Alan Liu
* @version $RCSfile: ReplaceableString.java,v $ $Revision: 1.6 $ $Date: 2001/11/21 21:19:57 $
* @version $RCSfile: ReplaceableString.java,v $ $Revision: 1.7 $ $Date: 2001/12/04 20:09:07 $
*/
public class ReplaceableString implements Replaceable {
private StringBuffer buf;
@ -110,7 +112,7 @@ public class ReplaceableString implements Replaceable {
* @param dstStart the start offset in the destination array.
*/
public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) {
buf.getChars(srcStart, srcLimit, dst, dstStart);
Utility.getChars(buf, srcStart, srcLimit, dst, dstStart);
}
/**

View file

@ -2,6 +2,7 @@
/* Options: Binary Comments Crossref Format Java Logo Strictargs Strictcase Trace2 Verbose3 */
package com.ibm.math;
import java.math.BigInteger;
import com.ibm.util.Utility;
/* ------------------------------------------------------------------ */
/* BigDecimal -- Decimal arithmetic for Java */
@ -3424,7 +3425,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
sb.append('E').append(csign).append(euse);
}
rec=new char[sb.length()];
sb.getChars(0,sb.length(),rec,0);
Utility.getChars(sb, 0,sb.length(),rec,0);
return rec;
}

View file

@ -5,13 +5,14 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/HexToUnicodeTransliterator.java,v $
* $Date: 2001/09/28 20:27:02 $
* $Revision: 1.10 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.11 $
*
*****************************************************************************************
*/
package com.ibm.text;
import java.util.*;
import com.ibm.util.Utility;
/**
* A transliterator that converts from hexadecimal Unicode escape
@ -23,7 +24,7 @@ import java.util.*;
* applyPattern() for details.
*
* @author Alan Liu
* @version $RCSfile: HexToUnicodeTransliterator.java,v $ $Revision: 1.10 $ $Date: 2001/09/28 20:27:02 $
* @version $RCSfile: HexToUnicodeTransliterator.java,v $ $Revision: 1.11 $ $Date: 2001/12/04 20:09:07 $
*/
public class HexToUnicodeTransliterator extends Transliterator {
private static final String COPYRIGHT =
@ -252,7 +253,7 @@ public class HexToUnicodeTransliterator extends Transliterator {
this.pattern = pattern;
int len = affixes.length();
this.affixes = new char[len];
affixes.getChars(0, len, this.affixes, 0);
Utility.getChars(affixes, 0, len, this.affixes, 0);
}
/**

View file

@ -5,13 +5,15 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/ReplaceableString.java,v $
* $Date: 2001/11/21 21:19:57 $
* $Revision: 1.6 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.7 $
*
*****************************************************************************************
*/
package com.ibm.text;
import com.ibm.util.Utility;
/**
* <code>ReplaceableString</code> is an adapter class that implements the
* <code>Replaceable</code> API around an ordinary <code>StringBuffer</code>.
@ -24,7 +26,7 @@ package com.ibm.text;
*
* @see Replaceable
* @author Alan Liu
* @version $RCSfile: ReplaceableString.java,v $ $Revision: 1.6 $ $Date: 2001/11/21 21:19:57 $
* @version $RCSfile: ReplaceableString.java,v $ $Revision: 1.7 $ $Date: 2001/12/04 20:09:07 $
*/
public class ReplaceableString implements Replaceable {
private StringBuffer buf;
@ -110,7 +112,7 @@ public class ReplaceableString implements Replaceable {
* @param dstStart the start offset in the destination array.
*/
public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) {
buf.getChars(srcStart, srcLimit, dst, dstStart);
Utility.getChars(buf, srcStart, srcLimit, dst, dstStart);
}
/**

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/UCharacter.java,v $
* $Date: 2001/12/03 20:59:00 $
* $Revision: 1.19 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.20 $
*
*******************************************************************************
*/
@ -15,6 +15,7 @@
package com.ibm.text;
import java.util.Locale;
import com.ibm.util.Utility;
/**
* <p>
@ -1222,7 +1223,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialLowerCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_LOWERCASE_)) {
@ -1264,7 +1265,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialUpperCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_UPPERCASE_)) {
@ -1313,7 +1314,7 @@ public final class UCharacter
StringBuffer buf = new StringBuffer();
getSpecialUpperCase(ch, index, buf, str, offset,
locale);
buf.getChars(0, buf.length(), result, 0);
Utility.getChars(buf, 0, buf.length(), result, 0);
return buf.length();
} else if (PROPERTY_DB_.hasExceptionValue(index,
UCharacterPropertyDB.EXC_UPPERCASE_)) {

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/tools/rbbi/Attic/BuildDictionaryFile.java,v $
* $Date: 2000/09/22 18:58:26 $
* $Revision: 1.1 $
* $Date: 2001/12/04 20:09:08 $
* $Revision: 1.2 $
*
*****************************************************************************************
*/
@ -14,6 +14,7 @@ package com.ibm.tools.rbbi;
import com.ibm.util.CompactByteArray;
import com.ibm.text.UnicodeSet;
import com.ibm.util.Utility;
import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
@ -114,7 +115,7 @@ int totalChars = 0;
//System.out.println(tempReverseMap.toString());
reverseColumnMap = new char[p];
tempReverseMap.getChars(0, p, reverseColumnMap, 0);
Utility.getChars(tempReverseMap, 0, p, reverseColumnMap, 0);
System.out.println("total columns = " + p);
numCols = p;

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/util/Attic/Utility.java,v $
* $Date: 2001/12/03 18:35:33 $
* $Revision: 1.17 $
* $Date: 2001/12/04 20:09:07 $
* $Revision: 1.18 $
*
*****************************************************************************************
*/
@ -1235,4 +1235,26 @@ public final class Utility {
Transliterator.Position pos) {
return formatInput(appendTo, (ReplaceableString) input, pos);
}
/**
* Similar to StringBuffer.getChars, version 1.3.
* Since JDK 1.2 implements StringBuffer.getChars differently, this method
* is here to provide consistent results.
* To be removed after JDK 1.2 ceased to be the reference platform.
* @param src source string buffer
* @param srcBegin offset to the start of the src to retrieve from
* @param srcEnd offset to the end of the src to retrieve from
* @param dst char array to store the retrieved chars
* @param dstBegin offset to the start of the destination char array to
* store the retrieved chars
* @draft since ICU4J 2.0
*/
public static void getChars(StringBuffer src, int srcBegin, int srcEnd,
char dst[], int dstBegin)
{
if (srcBegin == srcEnd) {
return;
}
src.getChars(srcBegin, srcEnd, dst, dstBegin);
}
}