ICU-7381 Replacing StringBuffer with StringBuilder in ICU4J runtime library implementation code.

X-SVN-Rev: 27424
This commit is contained in:
Yoshito Umaoka 2010-01-27 03:09:08 +00:00
parent b618bb7665
commit 72b20e8947
62 changed files with 239 additions and 263 deletions

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2006-2009, International Business Machines Corporation and *
* Copyright (C) 2006-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -201,7 +201,7 @@ final class UConverterAlias {
int mid, start, limit;
int lastMid;
int result;
StringBuffer strippedName = new StringBuffer();
StringBuilder strippedName = new StringBuilder();
String aliasToCompare;
stripForCompare(strippedName, alias);
@ -257,7 +257,7 @@ final class UConverterAlias {
* @param name The alias to strip
* @return the destination buffer.
*/
public static final StringBuffer stripForCompare(StringBuffer dst, String name) {
public static final StringBuilder stripForCompare(StringBuilder dst, String name) {
return io_stripASCIIForCompare(dst, name);
}
@ -285,7 +285,7 @@ final class UConverterAlias {
}
/** @see UConverterAlias#compareNames */
private static final StringBuffer io_stripASCIIForCompare(StringBuffer dst, String name) {
private static final StringBuilder io_stripASCIIForCompare(StringBuilder dst, String name) {
int nameIndex = 0;
char type, nextType;
char c1;

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2006-2008, International Business Machines Corporation and *
* Copyright (C) 2006-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -528,7 +528,7 @@ final class UConverterDataReader implements ICUBinary.Authenticate {
protected String readBaseTableName() throws IOException
{
char c;
StringBuffer name = new StringBuffer();
StringBuilder name = new StringBuilder();
while((c = (char)dataInputStream.readByte()) != 0){
name.append(c);
bytesRead++;

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -592,11 +592,11 @@ public final class CollationElementIterator
CollationElementIterator(String source, RuleBasedCollator collator)
{
m_srcUtilIter_ = new StringUCharacterIterator(source);
m_utilStringBuffer_ = new StringBuffer();
m_utilStringBuffer_ = new StringBuilder();
m_source_ = m_srcUtilIter_;
m_collator_ = collator;
m_CEBuffer_ = new int[CE_BUFFER_INIT_SIZE_];
m_buffer_ = new StringBuffer();
m_buffer_ = new StringBuilder();
m_utilSpecialBackUp_ = new Backup();
updateInternalState();
}
@ -616,11 +616,11 @@ public final class CollationElementIterator
RuleBasedCollator collator)
{
m_srcUtilIter_ = new StringUCharacterIterator();
m_utilStringBuffer_ = new StringBuffer();
m_utilStringBuffer_ = new StringBuilder();
m_source_ = new CharacterIteratorWrapper(source);
m_collator_ = collator;
m_CEBuffer_ = new int[CE_BUFFER_INIT_SIZE_];
m_buffer_ = new StringBuffer();
m_buffer_ = new StringBuilder();
m_utilSpecialBackUp_ = new Backup();
updateInternalState();
}
@ -640,12 +640,12 @@ public final class CollationElementIterator
RuleBasedCollator collator)
{
m_srcUtilIter_ = new StringUCharacterIterator();
m_utilStringBuffer_ = new StringBuffer();
m_utilStringBuffer_ = new StringBuilder();
m_srcUtilIter_.setText(source.getText());
m_source_ = m_srcUtilIter_;
m_collator_ = collator;
m_CEBuffer_ = new int[CE_BUFFER_INIT_SIZE_];
m_buffer_ = new StringBuffer();
m_buffer_ = new StringBuilder();
m_utilSpecialBackUp_ = new Backup();
updateInternalState();
}
@ -810,7 +810,7 @@ public final class CollationElementIterator
* Buffer for temporary storage of normalized characters, discontiguous
* characters and Thai characters
*/
private StringBuffer m_buffer_;
private StringBuilder m_buffer_;
/**
* Position in the original string to continue forward FCD check from.
*/
@ -852,8 +852,8 @@ public final class CollationElementIterator
* Utility
*/
private StringUCharacterIterator m_srcUtilIter_;
private StringBuffer m_utilStringBuffer_;
private StringBuffer m_utilSkippedBuffer_;
private StringBuilder m_utilStringBuffer_;
private StringBuilder m_utilSkippedBuffer_;
private CollationElementIterator m_utilColEIter_;
/**
* One character before the first non-zero combining class character
@ -973,12 +973,7 @@ public final class CollationElementIterator
backup.m_bufferOffset_ = m_bufferOffset_;
backup.m_buffer_.setLength(0);
if (m_bufferOffset_ >= 0) {
// jdk 1.3.1 does not have append(StringBuffer) yet
if(ICUDebug.isJDK14OrHigher){
backup.m_buffer_.append(m_buffer_);
}else{
backup.m_buffer_.append(m_buffer_.toString());
}
backup.m_buffer_.append(m_buffer_);
}
}
@ -995,8 +990,7 @@ public final class CollationElementIterator
m_FCDStart_ = backup.m_FCDStart_;
m_buffer_.setLength(0);
if (m_bufferOffset_ >= 0) {
// jdk 1.3.1 does not have append(StringBuffer) yet
m_buffer_.append(backup.m_buffer_.toString());
m_buffer_.append(backup.m_buffer_);
}
}
@ -1509,7 +1503,7 @@ public final class CollationElementIterator
* really painful.
* @param skipped character buffer
*/
private void setDiscontiguous(StringBuffer skipped)
private void setDiscontiguous(StringBuilder skipped)
{
if (m_bufferOffset_ >= 0) {
m_buffer_.replace(0, m_bufferOffset_, skipped.toString());
@ -1555,7 +1549,7 @@ public final class CollationElementIterator
boolean multicontraction = false;
// since it will be stuffed into this iterator and ran over again
if (m_utilSkippedBuffer_ == null) {
m_utilSkippedBuffer_ = new StringBuffer();
m_utilSkippedBuffer_ = new StringBuilder();
}
else {
m_utilSkippedBuffer_.setLength(0);

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -342,7 +342,7 @@ public final class CollationKey implements Comparable<CollationKey>
}
else {
int size = m_key_.length >> 1;
StringBuffer key = new StringBuffer(size);
StringBuilder key = new StringBuilder(size);
int i = 0;
while (m_key_[i] != 0 && m_key_[i + 1] != 0) {
key.append((char)((m_key_[i] << 8) | m_key_[i + 1]));

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -559,7 +559,7 @@ final class CollationParsedRuleBuilder {
}
m_utilElement_.clear();
StringBuffer str = new StringBuffer();
StringBuilder str = new StringBuilder();
// add latin-1 stuff
copyRangeFromUCA(t, 0, 0xFF);
@ -836,12 +836,12 @@ final class CollationParsedRuleBuilder {
BasicContractionTable() {
m_CEs_ = new Vector<Integer>();
m_codePoints_ = new StringBuffer();
m_codePoints_ = new StringBuilder();
}
// package private data members -------------------------------------
StringBuffer m_codePoints_;
StringBuilder m_codePoints_;
Vector<Integer> m_CEs_;
}
@ -857,7 +857,7 @@ final class CollationParsedRuleBuilder {
m_mapping_ = mapping;
m_elements_ = new Vector<BasicContractionTable>();
m_CEs_ = new Vector<Integer>();
m_codePoints_ = new StringBuffer();
m_codePoints_ = new StringBuilder();
m_offsets_ = new Vector<Integer>();
m_currentTag_ = CE_NOT_FOUND_TAG_;
}
@ -871,7 +871,7 @@ final class CollationParsedRuleBuilder {
ContractionTable(ContractionTable table) {
m_mapping_ = table.m_mapping_;
m_elements_ = new Vector<BasicContractionTable>(table.m_elements_);
m_codePoints_ = new StringBuffer(table.m_codePoints_.toString());
m_codePoints_ = new StringBuilder(table.m_codePoints_);
m_CEs_ = new Vector<Integer>(table.m_CEs_);
m_offsets_ = new Vector<Integer>(table.m_offsets_);
m_currentTag_ = table.m_currentTag_;
@ -884,7 +884,7 @@ final class CollationParsedRuleBuilder {
*/
Vector<BasicContractionTable> m_elements_;
IntTrieBuilder m_mapping_;
StringBuffer m_codePoints_;
StringBuilder m_codePoints_;
Vector<Integer> m_CEs_;
Vector<Integer> m_offsets_;
int m_currentTag_;
@ -1328,7 +1328,7 @@ final class CollationParsedRuleBuilder {
private WeightRange m_utilWeightRange_ = new WeightRange();
private char m_utilCharBuffer_[] = new char[256];
private CanonicalIterator m_utilCanIter_ = new CanonicalIterator("");
private StringBuffer m_utilStringBuffer_ = new StringBuffer("");
private StringBuilder m_utilStringBuffer_ = new StringBuilder("");
// Flag indicating a combining marks table is required or not.
private static boolean buildCMTabFlag = false;
@ -3661,7 +3661,7 @@ final class CollationParsedRuleBuilder {
table.m_CEs_.clear();
table.m_codePoints_.delete(0, table.m_codePoints_.length());
// Now stuff the things in
StringBuffer cpPointer = table.m_codePoints_;
StringBuilder cpPointer = table.m_codePoints_;
Vector<Integer> CEPointer = table.m_CEs_;
for (int i = 0; i < tsize; i++) {
BasicContractionTable bct = table.m_elements_.get(i);
@ -4010,7 +4010,7 @@ final class CollationParsedRuleBuilder {
maxIndex = index[cClass - 1];
}
for (int i = 0; i < maxIndex; i++) {
StringBuffer decompBuf = new StringBuffer();
StringBuilder decompBuf = new StringBuilder();
decompBuf.append(baseChar).append(cmLookup.cPoints[i]);
String comp = Normalizer.compose(decompBuf.toString(), false);
if (comp.length() == 1) {
@ -4018,7 +4018,7 @@ final class CollationParsedRuleBuilder {
precompClass[precompLen] = (NormalizerImpl
.getFCD16(cmLookup.cPoints[i]) & 0xff);
precompLen++;
StringBuffer decomp = new StringBuffer();
StringBuilder decomp = new StringBuilder();
for (int j = 0; j < m_utilElement_.m_cPoints_.length(); j++) {
if (m_utilElement_.m_cPoints_.charAt(j) == cMark) {
decomp.append(cmLookup.cPoints[i]);
@ -4027,7 +4027,7 @@ final class CollationParsedRuleBuilder {
}
}
comp = Normalizer.compose(decomp.toString(), false);
StringBuffer buf = new StringBuffer(comp);
StringBuilder buf = new StringBuilder(comp);
buf.append(cMark);
decomp.append(cMark);
comp = buf.toString();
@ -4135,7 +4135,7 @@ final class CollationParsedRuleBuilder {
for (int j = 0; j < maxComp; j++) {
int count = 0;
StringBuffer temp;
StringBuilder temp;
do {
String newDecomp, comp;
@ -4143,11 +4143,11 @@ final class CollationParsedRuleBuilder {
if (count == 0) { // Decompose the saved precomposed char.
newDecomp = Normalizer.decompose(
new String(precompCh, j, 1), false);
temp = new StringBuffer(newDecomp);
temp = new StringBuilder(newDecomp);
temp.append(cmLookup.cPoints[cmPos]);
newDecomp = temp.toString();
} else {
temp = new StringBuffer(decomp);
temp = new StringBuilder(decomp);
temp.append(precompCh[j]);
newDecomp = temp.toString();
}

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -37,7 +37,7 @@ final class CollationRuleParser
CollationRuleParser(String rules) throws ParseException
{
extractSetsFromRules(rules);
m_source_ = new StringBuffer(Normalizer.decompose(rules, false).trim());
m_source_ = new StringBuilder(Normalizer.decompose(rules, false).trim());
m_rules_ = m_source_.toString();
m_current_ = 0;
m_extraCurrent_ = m_source_.length();
@ -151,7 +151,7 @@ final class CollationRuleParser
TokenListHeader m_listHeader_;
Token m_previous_;
Token m_next_;
StringBuffer m_rules_;
StringBuilder m_rules_;
char m_flags_;
// package private constructors ---------------------------------------
@ -259,7 +259,7 @@ final class CollationRuleParser
/**
* Normalized collation rules with some extra characters
*/
StringBuffer m_source_;
StringBuilder m_source_;
/**
* Hash table to keep all tokens
*/
@ -1090,7 +1090,7 @@ final class CollationRuleParser
// for pre-context
String precontext = rules.substring(0, offset);
String postcontext = rules.substring(offset, rules.length());
StringBuffer error = new StringBuffer(
StringBuilder error = new StringBuilder(
"Parse error occurred in rule at offset ");
error.append(offset);
error.append("\n after the prefix \"");

View File

@ -183,7 +183,7 @@ public class IndexCharacters {
* Return the string with interspersed CGJs. Input must have more than 2 codepoints.
*/
private String separated(String item) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
// add a CGJ except within surrogates
char last = item.charAt(0);
result.append(last);

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -750,9 +750,9 @@ public final class RuleBasedCollator extends Collator
}
private void
addSpecial(contContext c, StringBuffer buffer, int CE)
addSpecial(contContext c, StringBuilder buffer, int CE)
{
StringBuffer b = new StringBuffer();
StringBuilder b = new StringBuilder();
int offset = (CE & 0xFFFFFF) - c.coll.m_contractionOffset_;
int newCE = c.coll.m_contractionCE_[offset];
// we might have a contraction that ends from previous level
@ -824,7 +824,7 @@ public final class RuleBasedCollator extends Collator
int start = element.start;
int limit = element.limit;
int CE = element.value;
StringBuffer contraction = new StringBuffer(internalBufferSize);
StringBuilder contraction = new StringBuilder(internalBufferSize);
if(isSpecial(CE)) {
if(((getTag(CE) == CollationElementIterator.CE_SPEC_PROC_TAG_ && c.addPrefixes) || getTag(CE) == CollationElementIterator.CE_CONTRACTION_TAG_)) {

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -453,14 +453,14 @@ public final class StringSearch extends SearchIterator
m_isCanonicalMatch_ = allowCanonical;
if (m_isCanonicalMatch_ == true) {
if (m_canonicalPrefixAccents_ == null) {
m_canonicalPrefixAccents_ = new StringBuffer();
m_canonicalPrefixAccents_ = new StringBuilder();
}
else {
m_canonicalPrefixAccents_.delete(0,
m_canonicalPrefixAccents_.length());
}
if (m_canonicalSuffixAccents_ == null) {
m_canonicalSuffixAccents_ = new StringBuffer();
m_canonicalSuffixAccents_ = new StringBuilder();
}
else {
m_canonicalSuffixAccents_.delete(0,
@ -746,11 +746,11 @@ public final class StringSearch extends SearchIterator
/**
* Buffer storing accents during a canonical search
*/
private StringBuffer m_canonicalPrefixAccents_;
private StringBuilder m_canonicalPrefixAccents_;
/**
* Buffer storing accents during a canonical search
*/
private StringBuffer m_canonicalSuffixAccents_;
private StringBuilder m_canonicalSuffixAccents_;
/**
* Flag to indicate if canonical search is to be done.
* E.g looking for "a\u0300" in "a\u0318\u0300" will yield the match at 0.
@ -1634,7 +1634,7 @@ public final class StringSearch extends SearchIterator
* are not blocked
* @return the length of populated accentsindex
*/
private int getUnblockedAccentIndex(StringBuffer accents,
private int getUnblockedAccentIndex(StringBuilder accents,
int accentsindex[])
{
int index = 0;
@ -1661,7 +1661,7 @@ public final class StringSearch extends SearchIterator
}
/**
* Appends 3 StringBuffer/CharacterIterator together into a destination
* Appends 3 StringBuilder/CharacterIterator together into a destination
* string buffer.
* @param source1 string buffer
* @param source2 character iterator
@ -1670,19 +1670,14 @@ public final class StringSearch extends SearchIterator
* @param source3 string buffer
* @return appended string buffer
*/
private static final StringBuffer merge(StringBuffer source1,
private static final StringBuilder merge(StringBuilder source1,
CharacterIterator source2,
int start2, int end2,
StringBuffer source3)
StringBuilder source3)
{
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
if (source1 != null && source1.length() != 0) {
// jdk 1.3.1 does not have append(StringBuffer) yet
if(com.ibm.icu.impl.ICUDebug.isJDK14OrHigher){
result.append(source1);
}else{
result.append(source1.toString());
}
result.append(source1);
}
source2.setIndex(start2);
while (source2.getIndex() < end2) {
@ -1690,12 +1685,7 @@ public final class StringSearch extends SearchIterator
source2.next();
}
if (source3 != null && source3.length() != 0) {
// jdk 1.3.1 does not have append(StringBuffer) yet
if(com.ibm.icu.impl.ICUDebug.isJDK14OrHigher){
result.append(source3);
}else{
result.append(source3.toString());
}
result.append(source3);
}
return result;
}
@ -1753,7 +1743,7 @@ public final class StringSearch extends SearchIterator
int offset = getNextBaseOffset(targetText, start);
start = getPreviousBaseOffset(start);
StringBuffer accents = new StringBuffer();
StringBuilder accents = new StringBuilder();
String accentstr = getString(targetText, start, offset - start);
// normalizing the offensive string
if (Normalizer.quickCheck(accentstr, Normalizer.NFD,0)
@ -1784,7 +1774,7 @@ public final class StringSearch extends SearchIterator
}
}
}
StringBuffer match = merge(m_canonicalPrefixAccents_,
StringBuilder match = merge(m_canonicalPrefixAccents_,
targetText, offset, end,
m_canonicalSuffixAccents_);
@ -1838,7 +1828,7 @@ public final class StringSearch extends SearchIterator
private int doNextCanonicalSuffixMatch(int textoffset)
{
int safelength = 0;
StringBuffer safetext;
StringBuilder safetext;
int safeoffset = m_textBeginOffset_;
if (textoffset != m_textBeginOffset_
@ -1968,7 +1958,7 @@ public final class StringSearch extends SearchIterator
return false;
}
StringBuffer accents = new StringBuffer();
StringBuilder accents = new StringBuilder();
// offset to the last base character in substring to search
int baseoffset = getPreviousBaseOffset(targetText, textoffset);
// normalizing the offensive string
@ -2368,7 +2358,7 @@ public final class StringSearch extends SearchIterator
}
end = getNextBaseOffset(targetText, end);
StringBuffer accents = new StringBuffer();
StringBuilder accents = new StringBuilder();
int offset = getPreviousBaseOffset(targetText, end);
// normalizing the offensive string
String accentstr = getString(targetText, offset, end - offset);
@ -2399,7 +2389,7 @@ public final class StringSearch extends SearchIterator
}
}
}
StringBuffer match = merge(m_canonicalPrefixAccents_, targetText,
StringBuilder match = merge(m_canonicalPrefixAccents_, targetText,
start, offset,
m_canonicalSuffixAccents_);
// run the collator iterator through this match
@ -2429,7 +2419,7 @@ public final class StringSearch extends SearchIterator
private int doPreviousCanonicalPrefixMatch(int textoffset)
{
// int safelength = 0;
StringBuffer safetext;
StringBuilder safetext;
int safeoffset = textoffset;
if (textoffset > m_textBeginOffset_
@ -2557,7 +2547,7 @@ public final class StringSearch extends SearchIterator
return false;
}
StringBuffer accents = new StringBuffer();
StringBuilder accents = new StringBuilder();
// offset to the last base character in substring to search
int baseoffset = getNextBaseOffset(targetText, textoffset);
// normalizing the offensive string
@ -3101,7 +3091,7 @@ public final class StringSearch extends SearchIterator
private static final String getString(CharacterIterator text, int start,
int length)
{
StringBuffer result = new StringBuffer(length);
StringBuilder result = new StringBuilder(length);
int offset = text.getIndex();
text.setIndex(start);
for (int i = 0; i < length; i ++) {

View File

@ -264,7 +264,7 @@ public class ICULocaleService extends ICUService {
public String currentDescriptor() {
String result = currentID();
if (result != null) {
StringBuffer buf = new StringBuffer(); // default capacity 16 is usually good enough
StringBuilder buf = new StringBuilder(); // default capacity 16 is usually good enough
if (kind != KIND_ANY) {
buf.append(prefix());
}
@ -450,7 +450,7 @@ public class ICULocaleService extends ICUService {
* For debugging.
*/
public String toString() {
StringBuffer buf = new StringBuffer(super.toString());
StringBuilder buf = new StringBuilder(super.toString());
if (name != null) {
buf.append(", name: ");
buf.append(name);
@ -509,7 +509,7 @@ public class ICULocaleService extends ICUService {
}
public String toString() {
StringBuffer buf = new StringBuffer(super.toString());
StringBuilder buf = new StringBuilder(super.toString());
buf.append(", id: ");
buf.append(id);
buf.append(", kind: ");

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2001-2009, International Business Machines Corporation and *
* Copyright (C) 2001-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -326,7 +326,7 @@ public class ICUService extends ICUNotifier {
* For debugging.
*/
public String toString() {
StringBuffer buf = new StringBuffer(super.toString());
StringBuilder buf = new StringBuilder(super.toString());
buf.append(", id: ");
buf.append(id);
buf.append(", visible: ");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2005-2009, International Business Machines Corporation and *
* Copyright (C) 2005-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -637,7 +637,7 @@ public class OlsonTimeZone extends BasicTimeZone {
// temp
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(super.toString());
buf.append('[');
buf.append("transitionCount=" + transitionCount);

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008-2009, International Business Machines Corporation and *
* Copyright (C) 2008-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -157,7 +157,7 @@ public class PluralRulesLoader {
UResourceBundle rulesb = pluralb.get("rules");
UResourceBundle setb = rulesb.get(rulesId);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < setb.getSize(); ++i) {
UResourceBundle b = setb.get(i);
if (i > 0) {

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 1996-2008, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -186,7 +186,7 @@ final class UCharacterNameReader implements ICUBinary.Authenticate
size -= (variant << 1);
}
StringBuffer prefix = new StringBuffer();
StringBuilder prefix = new StringBuilder();
char c = (char)(m_dataInputStream_.readByte() & 0x00FF);
while (c != 0)
{

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2009, International Business Machines
* Copyright (c) 2002-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@ -537,7 +537,7 @@ public final class UPropertyAliases implements ICUBinary.Authenticate {
String stringPool[] = new String[count + 1];
stringPool_map = new short[count + 1];
short pos = offset;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
stringPool_map[0] = 0;
for (int i=1; i<=count; ++i) {
buf.setLength(0);

View File

@ -1,8 +1,8 @@
/*
*******************************************************************************
* Copyright (C) 2009, Google, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
********************************************************************************
* Copyright (C) 2009-2010, Google, International Business Machines Corporation *
* and others. All Rights Reserved. *
********************************************************************************
*/
package com.ibm.icu.impl;
@ -58,7 +58,7 @@ public class UnicodeRegex implements Cloneable, Freezable<UnicodeRegex>, StringT
* Pattern.compile().
*/
public String transform(String regex) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
UnicodeSet temp = new UnicodeSet();
ParsePosition pos = new ParsePosition(0);
int state = 0; // 1 = after \
@ -300,7 +300,7 @@ public class UnicodeRegex implements Cloneable, Freezable<UnicodeRegex>, StringT
// ===== PRIVATES =====
private int processSet(String regex, int i, StringBuffer result, UnicodeSet temp, ParsePosition pos) {
private int processSet(String regex, int i, StringBuilder result, UnicodeSet temp, ParsePosition pos) {
try {
pos.setIndex(i);
UnicodeSet x = temp.clear().applyPattern(regex, pos, null, 0);

View File

@ -1608,12 +1608,7 @@ public final class Utility {
}
if (quoteBuf.length() > 0) {
rule.append(APOSTROPHE);
// jdk 1.3.1 does not have append(StringBuffer) yet
if(ICUDebug.isJDK14OrHigher){
rule.append(quoteBuf);
}else{
rule.append(quoteBuf.toString());
}
rule.append(quoteBuf);
rule.append(APOSTROPHE);
quoteBuf.setLength(0);
}

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2003-2009 International Business Machines
* Copyright (c) 2003-2010 International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@ -802,7 +802,7 @@ public final class ZoneMeta {
*/
static String formatCustomID(int hour, int min, int sec, boolean negative) {
// Create normalized time zone ID - GMT[+|-]hh:mm[:ss]
StringBuffer zid = new StringBuffer(kCUSTOM_TZ_PREFIX);
StringBuilder zid = new StringBuilder(kCUSTOM_TZ_PREFIX);
if (hour != 0 || min != 0) {
if(negative) {
zid.append('-');

View File

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -191,7 +191,7 @@ public class XMLRecordReader implements RecordReader {
}
private String readData() {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
boolean inWhitespace = false;
// boolean inAmp = false;
while (true) {
@ -203,7 +203,7 @@ public class XMLRecordReader implements RecordReader {
if (c == '&') {
c = readChar();
if (c == '#') {
StringBuffer numBuf = new StringBuffer();
StringBuilder numBuf = new StringBuilder();
int radix = 10;
c = readChar();
if (c == 'x') {
@ -223,7 +223,7 @@ public class XMLRecordReader implements RecordReader {
throw ex;
}
} else {
StringBuffer charBuf = new StringBuffer();
StringBuilder charBuf = new StringBuilder();
while (c != ';' && c != -1) {
charBuf.append((char) c);
c = readChar();
@ -281,7 +281,7 @@ public class XMLRecordReader implements RecordReader {
if (atTag) {
atTag = false;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
while (true) {
c = readChar();
if (c == '>' || c == -1) {

View File

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -118,7 +118,7 @@ public class XMLRecordWriter implements RecordWriter {
if (str == null) {
return null;
}
StringBuffer sb = null;
StringBuilder sb = null;
boolean inWhitespace = false;
char c = '\0';
boolean special = false;
@ -126,7 +126,7 @@ public class XMLRecordWriter implements RecordWriter {
c = str.charAt(i);
if (UCharacter.isWhitespace(c)) {
if (sb == null && (inWhitespace || c != ' ')) {
sb = new StringBuffer(str.substring(0, i));
sb = new StringBuilder(str.substring(0, i));
}
if (inWhitespace) {
continue;
@ -138,7 +138,7 @@ public class XMLRecordWriter implements RecordWriter {
inWhitespace = false;
special = c == '<' || c == '&';
if (special && sb == null) {
sb = new StringBuffer(str.substring(0, i));
sb = new StringBuilder(str.substring(0, i));
}
}
if (sb != null) {

View File

@ -2070,7 +2070,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
private static String trimBlockName(String name) {
String upper = name.toUpperCase();
StringBuffer result = new StringBuffer(upper.length());
StringBuilder result = new StringBuilder(upper.length());
for (int i = 0; i < upper.length(); i++) {
char c = upper.charAt(i);
if (c != ' ' && c != '_' && c != '-') {
@ -3939,7 +3939,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
return getName(s.charAt(0));
}
int cp;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) {
cp = UTF16.charAt(s,i);
if (i != 0) sb.append(separator);

View File

@ -9,7 +9,7 @@ import com.ibm.icu.lang.UCharacter;
/* ------------------------------------------------------------------ */
/* BigDecimal -- Decimal arithmetic for Java */
/* ------------------------------------------------------------------ */
/* Copyright IBM Corporation, 1996-2009. All Rights Reserved. */
/* Copyright IBM Corporation, 1996-2010. All Rights Reserved. */
/* */
/* The BigDecimal class provides immutable arbitrary-precision */
/* floating point (including integer) decimal numbers. */
@ -2948,7 +2948,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
private char[] layout() {
char cmant[];
int i = 0;
java.lang.StringBuffer sb = null;
StringBuilder sb = null;
int euse = 0;
int sig = 0;
char csign = 0;
@ -2966,7 +2966,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
}/* i */
if (form != com.ibm.icu.math.MathContext.PLAIN) {/* exponential notation needed */
sb = new java.lang.StringBuffer(cmant.length + 15); // -x.xxxE+999999999
sb = new StringBuilder(cmant.length + 15); // -x.xxxE+999999999
if (ind == isneg)
sb.append('-');
euse = (exp + cmant.length) - 1; // exponent to use

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2009, International Business Machines
* Copyright (C) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -575,7 +575,7 @@ public final class ArabicShaping {
* @stable ICU 2.0
*/
public String toString() {
StringBuffer buf = new StringBuffer(super.toString());
StringBuilder buf = new StringBuilder(super.toString());
buf.append('[');
switch (options & LAMALEF_MASK) {

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2009, International Business Machines
* Copyright (C) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -60,7 +60,7 @@ final class BidiWriter {
return dest.toString();
}
case Bidi.REMOVE_BIDI_CONTROLS: {
StringBuffer dest = new StringBuffer(src.length());
StringBuilder dest = new StringBuilder(src.length());
/* copy the LTR run and remove any Bidi control characters */
int i = 0;
@ -237,7 +237,7 @@ final class BidiWriter {
static String writeReordered(Bidi bidi, int options)
{
int run, runCount;
StringBuffer dest;
StringBuilder dest;
char[] text = bidi.text;
runCount = bidi.countRuns();
@ -267,7 +267,7 @@ final class BidiWriter {
(bidi.reorderingMode != Bidi.REORDER_RUNS_ONLY)) {
options &= ~Bidi.INSERT_LRM_FOR_NUMERIC;
}
dest = new StringBuffer((options & Bidi.INSERT_LRM_FOR_NUMERIC) != 0 ?
dest = new StringBuilder((options & Bidi.INSERT_LRM_FOR_NUMERIC) != 0 ?
bidi.length * 2 : bidi.length);
/*
* Iterate through all visual runs and copy the run text segments to

View File

@ -235,7 +235,7 @@ public final class CanonicalIterator {
// int[] pieces_lengths;
// transient fields
private transient StringBuffer buffer = new StringBuffer();
private transient StringBuilder buffer = new StringBuilder();
// we have a segment, in NFD. Find all the strings that are canonically equivalent to it.

View File

@ -87,7 +87,7 @@ public class CharsetMatch implements Comparable<CharsetMatch> {
public String getString(int maxLength) throws java.io.IOException {
String result = null;
if (fInputStream != null) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
char[] buffer = new char[1024];
Reader reader = getReader();
int max = maxLength < 0? Integer.MAX_VALUE : maxLength;

View File

@ -264,7 +264,7 @@ public class CurrencyPluralInfo implements Cloneable, Serializable {
String negPattern = pattern;
String negWithNumber = negPattern.replace("{0}", negNumberPattern);
String negWithCurrSign = negWithNumber.replace("{1}", tripleCurrencyStr);
StringBuffer posNegPatterns = new StringBuffer(patternWithCurrencySign);
StringBuilder posNegPatterns = new StringBuilder(patternWithCurrencySign);
posNegPatterns.append(";");
posNegPatterns.append(negWithCurrSign);
patternWithCurrencySign = posNegPatterns.toString();

View File

@ -897,10 +897,10 @@ public class DateIntervalFormat extends UFormat {
/* Check whether the skeleton is a combination of date and time.
* For the complication reason 1 explained above.
*/
StringBuffer date = new StringBuffer(skeleton.length());
StringBuffer normalizedDate = new StringBuffer(skeleton.length());
StringBuffer time = new StringBuffer(skeleton.length());
StringBuffer normalizedTime = new StringBuffer(skeleton.length());
StringBuilder date = new StringBuilder(skeleton.length());
StringBuilder normalizedDate = new StringBuilder(skeleton.length());
StringBuilder time = new StringBuilder(skeleton.length());
StringBuilder normalizedTime = new StringBuilder(skeleton.length());
/* the difference between time skeleton and normalizedTimeSkeleton are:
* 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,
@ -1108,10 +1108,10 @@ public class DateIntervalFormat extends UFormat {
* skeleton.
*/
private static void getDateTimeSkeleton(String skeleton,
StringBuffer dateSkeleton,
StringBuffer normalizedDateSkeleton,
StringBuffer timeSkeleton,
StringBuffer normalizedTimeSkeleton)
StringBuilder dateSkeleton,
StringBuilder normalizedDateSkeleton,
StringBuilder timeSkeleton,
StringBuilder normalizedTimeSkeleton)
{
// dateSkeleton follows the sequence of y*M*E*d*
// timeSkeleton follows the sequence of hm*[v|z]?
@ -1482,7 +1482,7 @@ public class DateIntervalFormat extends UFormat {
bestMatchIntervalPattern = bestMatchIntervalPattern.replace('v', 'z');
}
StringBuffer adjustedPtn = new StringBuffer(bestMatchIntervalPattern);
StringBuilder adjustedPtn = new StringBuilder(bestMatchIntervalPattern);
boolean inQuote = false;
char prevCh = 0;

View File

@ -1250,7 +1250,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
* @deprecated This API is ICU internal only.
*/
public String toString(int start, int limit) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = start; i < limit; ++i) {
Object item = items.get(i);
if (item instanceof String) {
@ -1585,7 +1585,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
*/
private String adjustFieldTypes(PatternWithMatcher patternWithMatcher, DateTimeMatcher inputRequest, boolean fixFractionalSeconds, int options) {
fp.set(patternWithMatcher.pattern);
StringBuffer newPattern = new StringBuffer();
StringBuilder newPattern = new StringBuilder();
for (Object item : fp.getItems()) {
if (item instanceof String) {
newPattern.append(fp.quoteLiteral((String)item));
@ -1671,7 +1671,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
*/
public String getFields(String pattern) {
fp.set(pattern);
StringBuffer newPattern = new StringBuffer();
StringBuilder newPattern = new StringBuilder();
for (Object item : fp.getItems()) {
if (item instanceof String) {
newPattern.append(fp.quoteLiteral((String)item));
@ -1865,7 +1865,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
}
public String toString() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i < TYPE_LIMIT; ++i) {
if (original[i].length() != 0) result.append(original[i]);
}
@ -1873,7 +1873,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
}
String getBasePattern() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i < TYPE_LIMIT; ++i) {
if (baseOriginal[i].length() != 0) result.append(baseOriginal[i]);
}

View File

@ -3554,7 +3554,7 @@ public class DecimalFormat extends NumberFormat {
}
private String unquote(String pat) {
StringBuffer buf = new StringBuffer(pat.length());
StringBuilder buf = new StringBuilder(pat.length());
int i = 0;
while (i < pat.length()) {
char ch = pat.charAt(i++);
@ -3826,7 +3826,7 @@ public class DecimalFormat extends NumberFormat {
}
StringBuffer affixBuf = new StringBuffer();
expandAffix(affixPat, null, affixBuf, true);
buf.append(affixBuf.toString());
buf.append(affixBuf);
return affixBuf.length();
}
@ -4253,8 +4253,8 @@ public class DecimalFormat extends NumberFormat {
// etc., and then only change the actual object fields if everything parses
// correctly. This also lets us register the data from part 0 and ignore the
// part 1, except for the prefix and suffix.
StringBuffer prefix = new StringBuffer();
StringBuffer suffix = new StringBuffer();
StringBuilder prefix = new StringBuilder();
StringBuilder suffix = new StringBuilder();
int decimalPos = -1;
int multpl = 1;
int digitLeftCount = 0, zeroDigitCount = 0, digitRightCount = 0, sigDigitCount = 0;
@ -4268,7 +4268,7 @@ public class DecimalFormat extends NumberFormat {
boolean expSignAlways = false;
// The affix is either the prefix or the suffix.
StringBuffer affix = prefix;
StringBuilder affix = prefix;
int start = pos;

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -119,7 +119,7 @@ final class DigitList {
*/
public final double getDouble() {
if (count == 0) return 0.0;
StringBuffer temp = new StringBuffer(count);
StringBuilder temp = new StringBuilder(count);
temp.append('.');
for (int i = 0; i < count; ++i) temp.append((char)(digits[i]));
temp.append('E');
@ -143,7 +143,7 @@ final class DigitList {
// we'd get a parse failure.
if (isLongMIN_VALUE()) return Long.MIN_VALUE;
StringBuffer temp = new StringBuffer(count);
StringBuilder temp = new StringBuilder(count);
for (int i = 0; i < decimalAt; ++i)
{
temp.append((i < count) ? (char)(digits[i]) : '0');
@ -163,7 +163,7 @@ final class DigitList {
if (isZero()) return BigInteger.valueOf(0);
//Eclipse stated the following is "dead code"
/*if (false) {
StringBuffer stringRep = new StringBuffer(count);
StringBuilder stringRep = new StringBuilder(count);
if (!isPositive) {
stringRep.append('-');
}
@ -203,7 +203,7 @@ final class DigitList {
private String getStringRep(boolean isPositive) {
if (isZero()) return "0";
StringBuffer stringRep = new StringBuffer(count+1);
StringBuilder stringRep = new StringBuilder(count+1);
if (!isPositive) {
stringRep.append('-');
}
@ -258,7 +258,7 @@ final class DigitList {
return new java.math.BigDecimal(0);
}
}
StringBuffer significantDigits = new StringBuffer(numDigits + 1);
StringBuilder significantDigits = new StringBuilder(numDigits + 1);
if (!isPositive) {
significantDigits.append('-');
}
@ -304,7 +304,7 @@ final class DigitList {
return new com.ibm.icu.math.BigDecimal(0);
}
}
StringBuffer significantDigits = new StringBuffer(numDigits + 1);
StringBuilder significantDigits = new StringBuilder(numDigits + 1);
if (!isPositive) {
significantDigits.append('-');
}
@ -852,7 +852,7 @@ final class DigitList {
public String toString()
{
if (isZero()) return "0";
StringBuffer buf = new StringBuffer("0.");
StringBuilder buf = new StringBuilder("0.");
for (int i=0; i<count; ++i) buf.append((char)digits[i]);
buf.append("x10^");
buf.append(decimalAt);

View File

@ -542,9 +542,9 @@ public class MessageFormat extends UFormat {
*/
@SuppressWarnings("fallthrough")
public void applyPattern(String pttrn) {
StringBuffer[] segments = new StringBuffer[4];
StringBuilder[] segments = new StringBuilder[4];
for (int i = 0; i < segments.length; ++i) {
segments[i] = new StringBuffer();
segments[i] = new StringBuilder();
}
int part = 0;
int formatNumber = 0;
@ -621,7 +621,7 @@ public class MessageFormat extends UFormat {
public String toPattern() {
// later, make this more extensible
int lastOffset = 0;
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i <= maxOffset; ++i) {
copyAndFixQuotes(pattern, lastOffset, offsets[i],result);
lastOffset = offsets[i];
@ -693,20 +693,20 @@ public class MessageFormat extends UFormat {
/**
* Double every single quote
*/
private String duplicateSingleQuotes(String pat){
String result = pat;
if (pat.indexOf('\'') != 0) {
StringBuffer buf = new StringBuffer();
for (int j = 0; j < pat.length(); ++j) {
char ch = pat.charAt(j);
if (ch == '\'') {
buf.append(ch); // double it
}
buf.append(ch);
private String duplicateSingleQuotes(String pat) {
String result = pat;
if (pat.indexOf('\'') != 0) {
StringBuilder buf = new StringBuilder();
for (int j = 0; j < pat.length(); ++j) {
char ch = pat.charAt(j);
if (ch == '\'') {
buf.append(ch); // double it
}
buf.append(ch);
}
result = buf.toString();
}
result = buf.toString();
}
return result;
return result;
}
/**
@ -1874,7 +1874,7 @@ public class MessageFormat extends UFormat {
DATE_MODIFIER_FULL = 4;
private void makeFormat(int position, int offsetNumber,
StringBuffer[] segments)
StringBuilder[] segments)
{
// get the argument number
// int argumentNumber;
@ -2064,7 +2064,7 @@ public class MessageFormat extends UFormat {
// PluralFormat and SelectFormat does not handle quotes.
// Remove quotes.
// TODO: Should PluralFormat and SelectFormat handle quotes?
StringBuffer unquotedPattern = new StringBuffer();
StringBuilder unquotedPattern = new StringBuilder();
String quotedPattern = segments[3].toString();
boolean inQuote = false;
for (int i = 0; i < quotedPattern.length(); ++i) {
@ -2111,7 +2111,7 @@ public class MessageFormat extends UFormat {
}
private static final void copyAndFixQuotes(String source, int start, int end,
StringBuffer target) {
StringBuilder target) {
// added 'gotLB' logic from ICU4C - questionable [alan]
boolean gotLB = false;
for (int i = start; i < end; ++i) {
@ -2230,7 +2230,7 @@ public class MessageFormat extends UFormat {
* @stable ICU 3.4
*/
public static String autoQuoteApostrophe(String pattern) {
StringBuffer buf = new StringBuffer(pattern.length() * 2);
StringBuilder buf = new StringBuilder(pattern.length() * 2);
int state = STATE_INITIAL;
int braceCount = 0;
for (int i = 0, j = pattern.length(); i < j; ++i) {
@ -2316,7 +2316,7 @@ public class MessageFormat extends UFormat {
return _createAttributedCharacterIterator("");
}
// Create a single AttributedString
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < iterators.length; i++) {
int index = iterators[i].getBeginIndex();
int end = iterators[i].getEndIndex();

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -129,7 +129,7 @@ final class NFRule {
// if the description does contain a matched pair of brackets,
// then it's really shorthand for two rules (with one exception)
NFRule rule2 = null;
StringBuffer sbuf = new StringBuffer();
StringBuilder sbuf = new StringBuilder();
// we'll actually only split the rule into two rules if its
// base value is an even multiple of its divisor (or it's one
@ -265,7 +265,7 @@ final class NFRule {
// if the rule descriptor begins with a digit, it's a descriptor
// for a normal rule
else if (descriptor.charAt(0) >= '0' && descriptor.charAt(0) <= '9') {
StringBuffer tempValue = new StringBuffer();
StringBuilder tempValue = new StringBuilder();
p = 0;
char c = ' ';
@ -557,7 +557,7 @@ final class NFRule {
* @return A textual description of the rule
*/
public String toString() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
// start with the rule descriptor. Special-case the special rules
if (baseValue == NEGATIVE_NUMBER_RULE) {
@ -600,7 +600,7 @@ final class NFRule {
// now, write the rule's rule text, inserting appropriate
// substitution tokens in the appropriate places
StringBuffer ruleTextCopy = new StringBuffer(ruleText);
StringBuilder ruleTextCopy = new StringBuilder(ruleText);
ruleTextCopy.insert(sub2.getPos(), sub2.toString());
ruleTextCopy.insert(sub1.getPos(), sub1.toString());
result.append(ruleTextCopy.toString());

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -319,7 +319,7 @@ final class NFRuleSet {
* constructed with, but it will produce the same results.
*/
public String toString() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
// the rule set name goes first...
result.append(name + ":\n");

View File

@ -331,7 +331,7 @@ public class PluralFormat extends UFormat {
// 0: Reading keyword.
// 1: Reading value for preceding keyword.
int state = 0;
StringBuffer token = new StringBuffer();
StringBuilder token = new StringBuilder();
String currentKeyword = null;
boolean readSpaceAfterKeyword = false;
for (int i = 0; i < pttrn.length(); ++i) {
@ -573,7 +573,7 @@ public class PluralFormat extends UFormat {
return "";
}
String formattedNumber = numberFormat.format(number);
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
int braceStack = 0;
int startIndex = 0;
for (int i = 0; i < message.length(); ++i) {
@ -633,7 +633,7 @@ public class PluralFormat extends UFormat {
* @stable ICU 3.8
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("locale=" + ulocale);
buf.append(", rules='" + pluralRules + "'");
buf.append(", pattern='" + pattern + "'");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2009, International Business Machines Corporation and *
* Copyright (C) 2001-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -69,7 +69,7 @@ class Quantifier implements UnicodeMatcher {
* Implement UnicodeMatcher API
*/
public String toPattern(boolean escapeUnprintable) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
result.append(matcher.toPattern(escapeUnprintable));
if (minCount == 0) {
if (maxCount == 1) {

View File

@ -308,7 +308,7 @@ final class RBBIDataWrapper {
}
dis.skip(This.fHeader.fRuleSource - pos);
pos = This.fHeader.fRuleSource;
StringBuffer sb = new StringBuffer(This.fHeader.fRuleSourceLen / 2);
StringBuilder sb = new StringBuilder(This.fHeader.fRuleSourceLen / 2);
for (i=0; i<This.fHeader.fRuleSourceLen; i+=2) {
sb.append(dis.readChar());
pos += 2;
@ -355,7 +355,7 @@ final class RBBIDataWrapper {
///CLOVER:OFF
/* Fixed width int-to-string conversion. */
static public String intToString(int n, int width) {
StringBuffer dest = new StringBuffer(width);
StringBuilder dest = new StringBuilder(width);
dest.append(n);
while (dest.length() < width) {
dest.insert(0, ' ');
@ -367,7 +367,7 @@ final class RBBIDataWrapper {
///CLOVER:OFF
/* Fixed width int-to-string conversion. */
static public String intToHexString(int n, int width) {
StringBuffer dest = new StringBuffer(width);
StringBuilder dest = new StringBuilder(width);
dest.append(Integer.toHexString(n));
while (dest.length() < width) {
dest.insert(0, ' ');
@ -408,7 +408,7 @@ final class RBBIDataWrapper {
* @param state
*/
private void dumpRow(short table[], int state) {
StringBuffer dest = new StringBuffer(fHeader.fCatCount*5 + 20);
StringBuilder dest = new StringBuilder(fHeader.fCatCount*5 + 20);
dest.append(intToString(state, 4));
int row = getRowIndex(state);
if (table[row+ACCEPTING] != 0) {

View File

@ -341,7 +341,7 @@ class RBBIRuleScanner {
// sets that just happen to contain only one character.
{
n = pushNewNode(RBBINode.setRef);
String s = (new StringBuffer().append((char) fC.fChar)).toString();
String s = String.valueOf((char)fC.fChar);
findSetFor(s, n, null);
n.fFirstPos = fScanIndex;
n.fLastPos = fNextIndex;
@ -664,7 +664,7 @@ class RBBIRuleScanner {
//
//----------------------------------------------------------------------------------------
static String stripRules(String rules) {
StringBuffer strippedRules = new StringBuffer();
StringBuilder strippedRules = new StringBuilder();
int rulesLength = rules.length();
for (int idx = 0; idx < rulesLength;) {
char ch = rules.charAt(idx++);

View File

@ -878,7 +878,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
// accumulate the descriptions of all the rule sets in a
// StringBuffer, then cast it to a String and return it
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i < ruleSets.length; i++) {
result.append(ruleSets[i].toString());
}
@ -1430,7 +1430,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
* @param specialName the name of the special rule text to extract
* @return the special rule text, or null if the rule was not found
*/
private String extractSpecial(StringBuffer description, String specialName) {
private String extractSpecial(StringBuilder description, String specialName) {
String result = null;
int lp = description.indexOf(specialName);
if (lp != -1) {
@ -1478,7 +1478,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
// description). This allows us to look for rule-set boundaries
// by searching for ";%" without having to worry about whitespace
// between the ; and the %
StringBuffer descBuf = stripWhitespace(description);
StringBuilder descBuf = stripWhitespace(description);
// check to see if there's a set of lenient-parse rules. If there
// is, pull them out into our temporary holding place for them,
@ -1638,10 +1638,10 @@ public class RuleBasedNumberFormat extends NumberFormat {
* @return The description with all the whitespace that follows semicolons
* taken out.
*/
private StringBuffer stripWhitespace(String description) {
private StringBuilder stripWhitespace(String description) {
// since we don't have a method that deletes characters (why?!!)
// create a new StringBuffer to copy the text into
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
// iterate through the characters...
int start = 0;

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2004, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -347,7 +347,7 @@ public abstract class SearchIterator
{
if (matchLength > 0) {
int limit = m_lastMatchStart_ + matchLength;
StringBuffer result = new StringBuffer(matchLength);
StringBuilder result = new StringBuilder(matchLength);
result.append(targetText.current());
targetText.next();
while (targetText.getIndex() < limit) {

View File

@ -281,8 +281,8 @@ public class SelectFormat extends Format{
this.pattern = pattern;
//Initialization
StringBuffer keyword = new StringBuffer();
StringBuffer phrase = new StringBuffer();
StringBuilder keyword = new StringBuilder();
StringBuilder phrase = new StringBuilder();
int braceCount = 0;
parsedValues = new HashMap<String, String>();
@ -536,7 +536,7 @@ public class SelectFormat extends Format{
* @provisional This API might change or be removed in a future release.
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("pattern='" + pattern + "'");
return buf.toString();
}

View File

@ -1140,7 +1140,7 @@ public class SimpleDateFormat extends DateFormat {
boolean isPrevQuote = false;
boolean inQuote = false;
StringBuffer text = new StringBuffer();
StringBuilder text = new StringBuilder();
char itemType = 0; // 0 for string literal, otherwise date/time pattern character
int itemLength = 1;
@ -2550,7 +2550,7 @@ public class SimpleDateFormat extends DateFormat {
* corresponding character in the to string.
*/
private String translatePattern(String pat, String from, String to) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
boolean inQuote = false;
for (int i = 0; i < pat.length(); ++i) {
char c = pat.charAt(i);

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2003-2008, International Business Machines Corporation and *
* Copyright (C) 2003-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -143,7 +143,7 @@ public class StringPrepParseException extends ParseException {
* @stable ICU 2.8
*/
public String toString(){
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(super.getMessage());
buf.append(". line: ");
buf.append(line);
@ -158,12 +158,11 @@ public class StringPrepParseException extends ParseException {
private int error;
/**
* The line on which the error occured. If the parse engine
* The line on which the error occurred. If the parse engine
* is not using this field, it should set it to zero. Otherwise
* it should be a positive integer. The default value of this field
* is -1. It will be set to 0 if the code populating this struct is not
* using line numbers.
* @stable ICU 2.8
*/
private int line;
@ -171,14 +170,12 @@ public class StringPrepParseException extends ParseException {
/**
* Textual context before the error. Null-terminated.
* May be the empty string if not implemented by parser.
* @stable ICU 2.8
*/
private StringBuffer preContext = new StringBuffer();
/**
* Textual context after the error. Null-terminated.
* May be the empty string if not implemented by parser.
* @stable ICU 2.8
*/
private StringBuffer postContext = new StringBuffer();

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -249,7 +249,7 @@ public class AnnualTimeZoneRule extends TimeZoneRule {
* @stable ICU 3.8
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(super.toString());
buf.append(", rule={" + dateTimeRule + "}");
buf.append(", startYear=" + startYear);

View File

@ -196,7 +196,7 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper>
* @stable ICU 3.2
*/
public String toString() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i < size; ++i) {
if (i != 0) result.append(" ");
result.append(Utility.hex(bytes[i]&0xFF,2));

View File

@ -3320,7 +3320,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
}
boolean inQuotes = false;
char prevChar = ' ';
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
StringCharacterIterator it = new StringCharacterIterator(pattern);
@ -4169,7 +4169,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
* @stable ICU 2.0
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
buffer.append(getClass().getName());
buffer.append("[time=");
buffer.append(isTimeSet ? String.valueOf(time) : "?");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -302,7 +302,7 @@ public class DateTimeRule implements Serializable {
int mins = time % 60;
int hours = time / 60;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("month=");
buf.append(MONSTR[month]);
buf.append(", date=");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -165,7 +165,7 @@ public class TimeArrayTimeZoneRule extends TimeZoneRule {
* @stable ICU 3.8
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(super.toString());
buf.append(", timeType=");
buf.append(timeType);

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -175,7 +175,7 @@ public abstract class TimeZoneRule implements Serializable {
* @stable ICU 3.8
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("name=" + name);
buf.append(", stdOffset=" + rawOffset);
buf.append(", dstSaving=" + dstSavings);

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -74,7 +74,7 @@ public class TimeZoneTransition {
* @stable ICU 3.8
*/
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("time=" + time);
buf.append(", from={" + from + "}");
buf.append(", to={" + to + "}");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -434,7 +434,7 @@ public class VTimeZone extends BasicTimeZone {
boolean eol = false;
boolean start = false;
boolean success = false;
StringBuffer line = new StringBuffer();
StringBuilder line = new StringBuilder();
while (true) {
int ch = reader.read();
if (ch == -1) {
@ -1841,7 +1841,7 @@ public class VTimeZone extends BasicTimeZone {
*/
private static String getDateTimeString(long time) {
int[] fields = Grego.timeToFields(time, null);
StringBuffer sb = new StringBuffer(15);
StringBuilder sb = new StringBuilder(15);
sb.append(numToString(fields[0], 4));
sb.append(numToString(fields[1] + 1, 2));
sb.append(numToString(fields[2], 2));
@ -1981,7 +1981,7 @@ public class VTimeZone extends BasicTimeZone {
* Convert milliseconds to RFC2445 utc-offset string
*/
private static String millisToOffset(int millis) {
StringBuffer sb = new StringBuffer(7);
StringBuilder sb = new StringBuilder(7);
if (millis >= 0) {
sb.append('+');
} else {
@ -2012,7 +2012,7 @@ public class VTimeZone extends BasicTimeZone {
if (len >= width) {
return str.substring(len - width, len);
}
StringBuffer sb = new StringBuffer(width);
StringBuilder sb = new StringBuilder(width);
for (int i = len; i < width; i++) {
sb.append('0');
}

View File

@ -338,7 +338,7 @@ public final class VersionInfo implements Comparable<VersionInfo>
*/
public String toString()
{
StringBuffer result = new StringBuffer(7);
StringBuilder result = new StringBuilder(7);
result.append(getMajor());
result.append('.');
result.append(getMinor());

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008, International Business Machines Corporation and *
* Copyright (C) 2008-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -124,7 +124,7 @@ public class ICULocaleServiceProvider {
String country = loc.getCountry();
String variant = loc.getVariant();
StringBuffer var = new StringBuffer(variant);
StringBuilder var = new StringBuilder(variant);
if (var.length() != 0) {
var.append("_");
}

View File

@ -195,7 +195,7 @@ class CompoundTransliterator extends Transliterator {
// If the direction is UTRANS_REVERSE then we may need to fix the
// ID.
if (direction == REVERSE && fixReverseID) {
StringBuffer newID = new StringBuffer();
StringBuilder newID = new StringBuilder();
for (i=0; i<count; ++i) {
if (i > 0) {
newID.append(ID_DELIM);
@ -244,7 +244,7 @@ class CompoundTransliterator extends Transliterator {
/**
* Append c to buf, unless buf is empty or buf already ends in c.
*/
private static void _smartAppend(StringBuffer buf, char c) {
private static void _smartAppend(StringBuilder buf, char c) {
if (buf.length() != 0 &&
buf.charAt(buf.length() - 1) != c) {
buf.append(c);
@ -268,7 +268,7 @@ class CompoundTransliterator extends Transliterator {
// handle compound RBT transliterators specially -- those for which
// compoundRBTIndex >= 0. For the transliterator at compoundRBTIndex,
// we do call toRules() recursively.
StringBuffer rulesSource = new StringBuffer();
StringBuilder rulesSource = new StringBuilder();
if (numAnonymousRBTs >= 1 && getFilter() != null) {
// If we are a compound RBT and if we have a global
// filter, then emit it at the top.

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2001-2004, International Business Machines
* Copyright (c) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -161,7 +161,7 @@ class EscapeTransliterator extends Transliterator {
int start = pos.start;
int limit = pos.limit;
StringBuffer buf = new StringBuffer(prefix);
StringBuilder buf = new StringBuilder(prefix);
int prefixLen = prefix.length();
boolean redoPrefix = false;

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2003, International Business Machines Corporation
* Copyright (c) 2002-2010, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -63,7 +63,7 @@ class FunctionReplacer implements UnicodeReplacer {
* UnicodeReplacer API
*/
public String toReplacerPattern(boolean escapeUnprintable) {
StringBuffer rule = new StringBuffer("&");
StringBuilder rule = new StringBuilder("&");
rule.append(translit.getID());
rule.append("( ");
rule.append(replacer.toReplacerPattern(escapeUnprintable));

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2001-2008, International Business Machines
* Copyright (C) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -85,7 +85,7 @@ final class NormalizationTransliterator extends Transliterator {
*/
public static NormalizationTransliterator getInstance(Normalizer.Mode m,
int opt) {
StringBuffer id = new StringBuffer("NF");
StringBuilder id = new StringBuilder("NF");
int choice = 0;
if(m==Normalizer.NFC){
id.append("C");

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -139,7 +139,7 @@ class TransliterationRuleSet {
rules = new TransliterationRule[v.size()];
v.copyInto(rules);
StringBuffer errors = null;
StringBuilder errors = null;
/* Check for masking. This is MUCH faster than our old check,
* which was each rule against each following rule, since we
@ -155,7 +155,7 @@ class TransliterationRuleSet {
TransliterationRule r2 = rules[k];
if (r1.masks(r2)) {
if (errors == null) {
errors = new StringBuffer();
errors = new StringBuilder();
} else {
errors.append("\n");
}
@ -225,7 +225,7 @@ class TransliterationRuleSet {
String toRules(boolean escapeUnprintable) {
int i;
int count = ruleVector.size();
StringBuffer ruleSource = new StringBuffer();
StringBuilder ruleSource = new StringBuilder();
for (i=0; i<count; ++i) {
if (i != 0) {
ruleSource.append('\n');

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2009, International Business Machines Corporation
* Copyright (c) 2002-2010, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -508,7 +508,7 @@ class TransliteratorIDParser {
public static String STVtoID(String source,
String target,
String variant) {
StringBuffer id = new StringBuffer(source);
StringBuilder id = new StringBuilder(source);
if (id.length() == 0) {
id.append(ANY);
}
@ -696,7 +696,7 @@ class TransliteratorIDParser {
String basicID = "";
String basicPrefix = "";
if (specs != null) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (dir == FORWARD) {
if (specs.sawSource) {
buf.append(specs.source).append(TARGET_SEP);
@ -735,7 +735,7 @@ class TransliteratorIDParser {
// If the original ID contained "Any-" then make the
// special inverse "Any-Foo"; otherwise make it "Foo".
// So "Any-NFC" => "Any-NFD" but "NFC" => "NFD".
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (specs.filter != null) {
buf.append(specs.filter);
}

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2001-2009, International Business Machines
* Copyright (c) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
@ -294,7 +294,7 @@ class TransliteratorParser {
if (s != null &&
s.length() > 0 &&
s.charAt(s.length() - 1) == '\\') {
StringBuffer b = new StringBuffer(s);
StringBuilder b = new StringBuilder(s);
do {
b.deleteCharAt(b.length()-1);
s = handleNextLine();
@ -910,7 +910,7 @@ class TransliteratorParser {
ruleArray.reset();
StringBuffer idBlockResult = new StringBuffer();
StringBuilder idBlockResult = new StringBuilder();
// The compound filter offset is an index into idBlockResult.
// If it is 0, then the compound filter occurred at the start,

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2001-2009, International Business Machines
* Copyright (c) 2001-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -665,7 +665,7 @@ class TransliteratorRegistry {
}
for (int pass=0; pass<2; ++pass) {
StringBuffer tag = new StringBuffer();
StringBuilder tag = new StringBuilder();
// First try either TransliteratorTo_xxx or
// TransliterateFrom_xxx, then try the bidirectional
// Transliterate_xxx. This precedence order is arbitrary

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1996-2004, International Business Machines Corporation and
* Copyright (C) 1996-2010, International Business Machines Corporation and
* others. All Rights Reserved.
*/
package com.ibm.icu.text;
@ -44,7 +44,7 @@ class UnicodeNameTransliterator extends Transliterator {
int cursor = offsets.start;
int limit = offsets.limit;
StringBuffer str = new StringBuffer();
StringBuilder str = new StringBuilder();
str.append(OPEN_DELIM);
int len;
String name;