# HG changeset patch # User Otavio Santana # Date 1419326151 7200 # Tue Dec 23 07:15:51 2014 -0200 # Node ID 6f48e171b60b0e0e063cce255f0c579d9d9f8a86 # Parent 8beb27f2f1bb6846c05b610b178a3f086222abbd uses StringBuilder instead StringBuffer diff --git a/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java b/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java --- a/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java +++ b/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java @@ -1234,7 +1234,7 @@ protected static short[][] unpackFromStrings(String[] sa) { // Concatanate initialization strings. - StringBuffer sb = new StringBuffer(sa[0]); + StringBuilder sb = new StringBuilder(sa[0]); for (int i=1; i 0) { - buf.append("implements\t\t"); + sb.append("implements\t\t"); for(int i=0; i < size; i++) { - buf.append(interface_names[i]); + sb.append(interface_names[i]); if(i < size - 1) - buf.append(", "); + sb.append(", "); } - buf.append('\n'); + sb.append('\n'); } - buf.append("filename\t\t" + file_name + '\n'); - buf.append("compiled from\t\t" + source_file_name + '\n'); - buf.append("compiler version\t" + major + "." + minor + '\n'); - buf.append("access flags\t\t" + access_flags + '\n'); - buf.append("constant pool\t\t" + constant_pool.getLength() + " entries\n"); - buf.append("ACC_SUPER flag\t\t" + isSuper() + "\n"); + sb.append("filename\t\t" + file_name + '\n'); + sb.append("compiled from\t\t" + source_file_name + '\n'); + sb.append("compiler version\t" + major + "." + minor + '\n'); + sb.append("access flags\t\t" + access_flags + '\n'); + sb.append("constant pool\t\t" + constant_pool.getLength() + " entries\n"); + sb.append("ACC_SUPER flag\t\t" + isSuper() + "\n"); if(attributes.length > 0) { - buf.append("\nAttribute(s):\n"); + sb.append("\nAttribute(s):\n"); for(int i=0; i < attributes.length; i++) - buf.append(indent(attributes[i])); + sb.append(indent(attributes[i])); } if(fields.length > 0) { - buf.append("\n" + fields.length + " fields:\n"); + sb.append("\n" + fields.length + " fields:\n"); for(int i=0; i < fields.length; i++) - buf.append("\t" + fields[i] + '\n'); + sb.append("\t" + fields[i] + '\n'); } if(methods.length > 0) { - buf.append("\n" + methods.length + " methods:\n"); + sb.append("\n" + methods.length + " methods:\n"); for(int i=0; i < methods.length; i++) - buf.append("\t" + methods[i] + '\n'); + sb.append("\t" + methods[i] + '\n'); } - return buf.toString(); + return sb.toString(); } private static final String indent(Object obj) { StringTokenizer tok = new StringTokenizer(obj.toString(), "\n"); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); - while(tok.hasMoreTokens()) - buf.append("\t" + tok.nextToken() + "\n"); + while(tok.hasMoreTokens()) { + sb.append('\t').append(tok.nextToken()).append('\n'); + } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java @@ -158,8 +158,8 @@ * @return String representation. */ public final String toString() { - StringBuffer buf = new StringBuffer(); - StringBuffer line = new StringBuffer(); + StringBuilder sb = new StringBuilder(); + StringBuilder line = new StringBuilder(); for(int i=0; i < line_number_table_length; i++) { line.append(line_number_table[i].toString()); @@ -169,14 +169,14 @@ if(line.length() > 72) { line.append('\n'); - buf.append(line); + sb.append(line); line.setLength(0); } } - buf.append(line); + sb.append(line); - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java @@ -169,16 +169,16 @@ * @return String representation. */ public final String toString() { - StringBuffer buf = new StringBuffer(""); + StringBuilder sb = new StringBuilder(""); for(int i=0; i < local_variable_table_length; i++) { - buf.append(local_variable_table[i].toString()); + sb.append(local_variable_table[i].toString()); if(i < local_variable_table_length - 1) - buf.append('\n'); + sb.append('\n'); } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java @@ -170,7 +170,7 @@ return ch == '/' || ch == ';'; } - private static final void matchIdent(MyByteArrayInputStream in, StringBuffer buf) { + private static final void matchIdent(MyByteArrayInputStream in, StringBuilder builder) { int ch; if((ch = in.read()) == -1) @@ -180,18 +180,18 @@ //System.out.println("return from ident:" + (char)ch); if(!identStart(ch)) { - StringBuffer buf2 = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int count = 1; while(Character.isJavaIdentifierPart((char)ch)) { - buf2.append((char)ch); + sb.append((char) ch); count++; ch = in.read(); } if(ch == ':') { // Ok, formal parameter in.skip("Ljava/lang/Object".length()); - buf.append(buf2); + builder.append(sb); ch = in.read(); in.unread(); @@ -204,17 +204,17 @@ return; } - StringBuffer buf2 = new StringBuffer(); + StringBuilder sb = new StringBuilder(); ch = in.read(); do { - buf2.append((char)ch); + sb.append((char) ch); ch = in.read(); //System.out.println("within ident:"+ (char)ch); } while((ch != -1) && (Character.isJavaIdentifierPart((char)ch) || (ch == '/'))); - buf.append(buf2.toString().replace('/', '.')); + builder.append(sb.toString().replace('/', '.')); //System.out.println("regular return ident:"+ (char)ch + ":" + buf2); @@ -223,17 +223,17 @@ } private static final void matchGJIdent(MyByteArrayInputStream in, - StringBuffer buf) + StringBuilder builder) { int ch; - matchIdent(in, buf); + matchIdent(in, builder); ch = in.read(); if((ch == '<') || ch == '(') { // Parameterized or method //System.out.println("Enter <"); - buf.append((char)ch); - matchGJIdent(in, buf); + builder.append((char) ch); + matchGJIdent(in, builder); while(((ch = in.read()) != '>') && (ch != ')')) { // List of parameters if(ch == -1) @@ -241,21 +241,21 @@ " reaching EOF"); //System.out.println("Still no >"); - buf.append(", "); + builder.append(", "); in.unread(); - matchGJIdent(in, buf); // Recursive call + matchGJIdent(in, builder); // Recursive call } //System.out.println("Exit >"); - buf.append((char)ch); + builder.append((char) ch); } else in.unread(); ch = in.read(); if(identStart(ch)) { in.unread(); - matchGJIdent(in, buf); + matchGJIdent(in, builder); } else if(ch == ')') { in.unread(); return; @@ -266,11 +266,11 @@ public static String translate(String s) { //System.out.println("Sig:" + s); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); - matchGJIdent(new MyByteArrayInputStream(s), buf); + matchGJIdent(new MyByteArrayInputStream(s), sb); - return buf.toString(); + return sb.toString(); } public static final boolean isFormalParameterList(String s) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java @@ -145,18 +145,18 @@ * @return String representation. */ public final String toString() { - StringBuffer buf = new StringBuffer("StackMap("); + StringBuilder sb = new StringBuilder("StackMap("); for(int i=0; i < map_length; i++) { - buf.append(map[i].toString()); + sb.append(map[i].toString()); if(i < map_length - 1) - buf.append(", "); + sb.append(", "); } - buf.append(')'); + sb.append(')'); - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java @@ -133,35 +133,35 @@ * @return String representation. */ public final String toString() { - StringBuffer buf = new StringBuffer("(offset=" + byte_code_offset); + StringBuilder sb = new StringBuilder("(offset=" + byte_code_offset); if(number_of_locals > 0) { - buf.append(", locals={"); + sb.append(", locals={"); for(int i=0; i < number_of_locals; i++) { - buf.append(types_of_locals[i]); + sb.append(types_of_locals[i]); if(i < number_of_locals - 1) - buf.append(", "); + sb.append(", "); } - buf.append("}"); + sb.append("}"); } if(number_of_stack_items > 0) { - buf.append(", stack items={"); + sb.append(", stack items={"); for(int i=0; i < number_of_stack_items; i++) { - buf.append(types_of_stack_items[i]); + sb.append(types_of_stack_items[i]); if(i < number_of_stack_items - 1) - buf.append(", "); + sb.append(", "); } - buf.append("}"); + sb.append('}'); } - buf.append(")"); + sb.append(')'); - return buf.toString(); + return sb.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java @@ -156,12 +156,12 @@ * @return String representation. */ public final String toString() { - StringBuffer buf = new StringBuffer("Synthetic"); + StringBuilder sb = new StringBuilder("Synthetic"); if(length > 0) - buf.append(" " + Utility.toHexString(bytes)); + sb.append(' ').append(Utility.toHexString(bytes)); - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java @@ -109,7 +109,7 @@ public static final String accessToString(int access_flags, boolean for_class) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int p = 0; for(int i=0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags @@ -124,11 +124,11 @@ if(for_class && ((p == Constants.ACC_SUPER) || (p == Constants.ACC_INTERFACE))) continue; - buf.append(Constants.ACCESS_NAMES[i] + " "); + sb.append(Constants.ACCESS_NAMES[i]).append(' '); } } - return buf.toString().trim(); + return sb.toString().trim(); } /** @@ -156,7 +156,7 @@ ConstantPool constant_pool, int index, int length, boolean verbose) { - StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient + StringBuilder sb = new StringBuilder(code.length * 20); // Should be sufficient ByteSequence stream = new ByteSequence(code); try { @@ -166,16 +166,16 @@ for(int i=0; stream.available() > 0; i++) { if((length < 0) || (i < length)) { String indices = fillup(stream.getIndex() + ":", 6, true, ' '); - buf.append(indices + codeToString(stream, constant_pool, verbose) + '\n'); + sb.append(indices + codeToString(stream, constant_pool, verbose) + '\n'); } } } catch(IOException e) { - System.out.println(buf.toString()); + System.out.println(sb.toString()); e.printStackTrace(); throw new ClassFormatException("Byte code error: " + e); } - return buf.toString(); + return sb.toString(); } public static final String codeToString(byte[] code, @@ -202,7 +202,7 @@ int index, vindex, constant; int[] match, jump_table; int no_pad_bytes=0, offset; - StringBuffer buf = new StringBuffer(Constants.OPCODE_NAMES[opcode]); + StringBuilder sb = new StringBuilder(Constants.OPCODE_NAMES[opcode]); /* Special case: Skip (0-3) padding bytes, i.e., the * following bytes are 4-byte-aligned @@ -233,18 +233,18 @@ offset = bytes.getIndex() - 12 - no_pad_bytes - 1; default_offset += offset; - buf.append("\tdefault = " + default_offset + ", low = " + low + - ", high = " + high + "("); + sb.append("\tdefault = ").append(default_offset).append(", low = ").append(low); + sb.append(", high = ").append(high).append('('); jump_table = new int[high - low + 1]; for(int i=0; i < jump_table.length; i++) { jump_table[i] = offset + bytes.readInt(); - buf.append(jump_table[i]); + sb.append(jump_table[i]); if(i < jump_table.length - 1) - buf.append(", "); + sb.append(", "); } - buf.append(")"); + sb.append(")"); break; @@ -259,20 +259,20 @@ jump_table = new int[npairs]; default_offset += offset; - buf.append("\tdefault = " + default_offset + ", npairs = " + npairs + - " ("); + sb.append("\tdefault = " + default_offset + ", npairs = " + npairs + + " ("); for(int i=0; i < npairs; i++) { match[i] = bytes.readInt(); jump_table[i] = offset + bytes.readInt(); - buf.append("(" + match[i] + ", " + jump_table[i] + ")"); + sb.append("(" + match[i] + ", " + jump_table[i] + ")"); if(i < npairs - 1) - buf.append(", "); + sb.append(", "); } - buf.append(")"); + sb.append(")"); } break; @@ -284,13 +284,13 @@ case Constants.IFNONNULL: case Constants.IFNULL: case Constants.IF_ACMPEQ: case Constants.IF_ACMPNE: case Constants.IF_ICMPEQ: case Constants.IF_ICMPGE: case Constants.IF_ICMPGT: case Constants.IF_ICMPLE: case Constants.IF_ICMPLT: case Constants.IF_ICMPNE: - buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readShort())); + sb.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readShort())); break; /* 32-bit wide jumps */ case Constants.GOTO_W: case Constants.JSR_W: - buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readInt())); + sb.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readInt())); break; /* Index byte references local variable (register) @@ -305,7 +305,7 @@ else vindex = bytes.readUnsignedByte(); - buf.append("\t\t%" + vindex); + sb.append("\t\t%" + vindex); break; /* @@ -315,53 +315,53 @@ */ case Constants.WIDE: wide = true; - buf.append("\t(wide)"); + sb.append("\t(wide)"); break; /* Array of basic type. */ case Constants.NEWARRAY: - buf.append("\t\t<" + Constants.TYPE_NAMES[bytes.readByte()] + ">"); + sb.append("\t\t<" + Constants.TYPE_NAMES[bytes.readByte()] + ">"); break; /* Access object/class fields. */ case Constants.GETFIELD: case Constants.GETSTATIC: case Constants.PUTFIELD: case Constants.PUTSTATIC: index = bytes.readUnsignedShort(); - buf.append("\t\t" + - constant_pool.constantToString(index, Constants.CONSTANT_Fieldref) + - (verbose? " (" + index + ")" : "")); + sb.append("\t\t" + + constant_pool.constantToString(index, Constants.CONSTANT_Fieldref) + + (verbose ? " (" + index + ")" : "")); break; /* Operands are references to classes in constant pool */ case Constants.NEW: case Constants.CHECKCAST: - buf.append("\t"); + sb.append("\t"); case Constants.INSTANCEOF: index = bytes.readUnsignedShort(); - buf.append("\t<" + constant_pool.constantToString(index, - Constants.CONSTANT_Class) + - ">" + (verbose? " (" + index + ")" : "")); + sb.append("\t<" + constant_pool.constantToString(index, + Constants.CONSTANT_Class) + + ">" + (verbose ? " (" + index + ")" : "")); break; /* Operands are references to methods in constant pool */ case Constants.INVOKESPECIAL: case Constants.INVOKESTATIC: case Constants.INVOKEVIRTUAL: index = bytes.readUnsignedShort(); - buf.append("\t" + constant_pool.constantToString(index, - Constants.CONSTANT_Methodref) + - (verbose? " (" + index + ")" : "")); + sb.append("\t" + constant_pool.constantToString(index, + Constants.CONSTANT_Methodref) + + (verbose ? " (" + index + ")" : "")); break; case Constants.INVOKEINTERFACE: index = bytes.readUnsignedShort(); int nargs = bytes.readUnsignedByte(); // historical, redundant - buf.append("\t" + - constant_pool.constantToString(index, - Constants.CONSTANT_InterfaceMethodref) + - (verbose? " (" + index + ")\t" : "") + nargs + "\t" + - bytes.readUnsignedByte()); // Last byte is a reserved space + sb.append("\t" + + constant_pool.constantToString(index, + Constants.CONSTANT_InterfaceMethodref) + + (verbose ? " (" + index + ")\t" : "") + nargs + "\t" + + bytes.readUnsignedByte()); // Last byte is a reserved space break; /* Operands are references to items in constant pool @@ -369,18 +369,18 @@ case Constants.LDC_W: case Constants.LDC2_W: index = bytes.readUnsignedShort(); - buf.append("\t\t" + constant_pool.constantToString - (index, constant_pool.getConstant(index).getTag()) + - (verbose? " (" + index + ")" : "")); + sb.append("\t\t" + constant_pool.constantToString + (index, constant_pool.getConstant(index).getTag()) + + (verbose ? " (" + index + ")" : "")); break; case Constants.LDC: index = bytes.readUnsignedByte(); - buf.append("\t\t" + - constant_pool.constantToString - (index, constant_pool.getConstant(index).getTag()) + - (verbose? " (" + index + ")" : "")); + sb.append("\t\t" + + constant_pool.constantToString + (index, constant_pool.getConstant(index).getTag()) + + (verbose ? " (" + index + ")" : "")); break; /* Array of references. @@ -388,9 +388,9 @@ case Constants.ANEWARRAY: index = bytes.readUnsignedShort(); - buf.append("\t\t<" + compactClassName(constant_pool.getConstantString - (index, Constants.CONSTANT_Class), false) + - ">" + (verbose? " (" + index + ")": "")); + sb.append("\t\t<" + compactClassName(constant_pool.getConstantString + (index, Constants.CONSTANT_Class), false) + + ">" + (verbose ? " (" + index + ")" : "")); break; /* Multidimensional array of references. @@ -399,9 +399,9 @@ index = bytes.readUnsignedShort(); int dimensions = bytes.readUnsignedByte(); - buf.append("\t<" + compactClassName(constant_pool.getConstantString - (index, Constants.CONSTANT_Class), false) + - ">\t" + dimensions + (verbose? " (" + index + ")" : "")); + sb.append("\t<" + compactClassName(constant_pool.getConstantString + (index, Constants.CONSTANT_Class), false) + + ">\t" + dimensions + (verbose ? " (" + index + ")" : "")); } break; @@ -417,27 +417,27 @@ vindex = bytes.readUnsignedByte(); constant = bytes.readByte(); } - buf.append("\t\t%" + vindex + "\t" + constant); + sb.append("\t\t%" + vindex + "\t" + constant); break; default: if(Constants.NO_OF_OPERANDS[opcode] > 0) { for(int i=0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++) { - buf.append("\t\t"); + sb.append("\t\t"); switch(Constants.TYPE_OF_OPERANDS[opcode][i]) { - case Constants.T_BYTE: buf.append(bytes.readByte()); break; - case Constants.T_SHORT: buf.append(bytes.readShort()); break; - case Constants.T_INT: buf.append(bytes.readInt()); break; + case Constants.T_BYTE: sb.append(bytes.readByte()); break; + case Constants.T_SHORT: sb.append(bytes.readShort()); break; + case Constants.T_INT: sb.append(bytes.readInt()); break; default: // Never reached System.err.println("Unreachable default case reached!"); - buf.setLength(0); + sb.setLength(0); } } } } - return buf.toString(); + return sb.toString(); } public static final String codeToString(ByteSequence bytes, ConstantPool constant_pool) @@ -541,7 +541,7 @@ public final static String methodTypeToSignature(String ret, String[] argv) throws ClassFormatException { - StringBuffer buf = new StringBuffer("("); + StringBuilder sb = new StringBuilder('('); String str; if(argv != null) @@ -551,14 +551,14 @@ if(str.endsWith("V")) // void can't be a method argument throw new ClassFormatException("Invalid type: " + argv[i]); - buf.append(str); + sb.append(str); } str = getSignature(ret); - buf.append(")" + str); + sb.append(')').append(str); - return buf.toString(); + return sb.toString(); } /** @@ -693,7 +693,7 @@ LocalVariableTable vars) throws ClassFormatException { - StringBuffer buf = new StringBuffer("("); + StringBuilder sb = new StringBuilder('('); String type; int index; int var_index = (access.indexOf("static") >= 0)? 0 : 1; @@ -706,22 +706,22 @@ while(signature.charAt(index) != ')') { String param_type = signatureToString(signature.substring(index), chopit); - buf.append(param_type); + sb.append(param_type); if(vars != null) { LocalVariable l = vars.getLocalVariable(var_index); if(l != null) - buf.append(" " + l.getName()); + sb.append(' ').append(l.getName()); } else - buf.append(" arg" + var_index); + sb.append(" arg").append(var_index); if("double".equals(param_type) || "long".equals(param_type)) var_index += 2; else var_index++; - buf.append(", "); + sb.append(", "); index += consumed_chars; // update position } @@ -734,13 +734,13 @@ throw new ClassFormatException("Invalid method signature: " + signature); } - if(buf.length() > 1) // Tack off the extra ", " - buf.setLength(buf.length() - 2); + if(sb.length() > 1) // Tack off the extra ", " + sb.setLength(sb.length() - 2); - buf.append(")"); + sb.append(")"); return access + ((access.length() > 0)? " " : "") + // May be an empty string - type + " " + name + buf.toString(); + type + " " + name + sb.toString(); } // Guess what this does @@ -758,7 +758,7 @@ */ public static final String replace(String str, String old, String new_) { int index, old_index; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); try { if((index = str.indexOf(old)) != -1) { // `old' found in str @@ -766,14 +766,14 @@ // While we have something to replace while((index = str.indexOf(old, old_index)) != -1) { - buf.append(str.substring(old_index, index)); // append prefix - buf.append(new_); // append replacement + sb.append(str.substring(old_index, index)); // append prefix + sb.append(new_); // append replacement old_index = index + old.length(); // Skip `old'.length chars } - buf.append(str.substring(old_index)); // append rest of string - str = buf.toString(); + sb.append(str.substring(old_index)); // append rest of string + str = sb.toString(); } } catch(StringIndexOutOfBoundsException e) { // Should not occur System.err.println(e); @@ -893,7 +893,7 @@ * @return byte code signature */ public static String getSignature(String type) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); char[] chars = type.toCharArray(); boolean char_found = false, delim = false; int index = -1; @@ -1056,7 +1056,7 @@ * @return bytes as hexidecimal string, e.g. 00 FA 12 ... */ public static final String toHexString(byte[] bytes) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for(int i=0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); @@ -1144,26 +1144,26 @@ if(obj == null) return null; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if(braces) - buf.append('{'); + sb.append('{'); for(int i=0; i < obj.length; i++) { if(obj[i] != null) { - buf.append((quote? "\"" : "") + obj[i].toString() + (quote? "\"" : "")); + sb.append((quote ? "\"" : "")).append(obj[i].toString()).append((quote ? "\"" : "")); } else { - buf.append("null"); + sb.append("null"); } if(i < obj.length - 1) { - buf.append(", "); + sb.append(", "); } } if(braces) - buf.append('}'); + sb.append('}'); - return buf.toString(); + return sb.toString(); } /** @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _) @@ -1373,25 +1373,25 @@ */ public static final String convertString(String label) { char[] ch = label.toCharArray(); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(int i=0; i < ch.length; i++) { switch(ch[i]) { case '\n': - buf.append("\\n"); break; + sb.append("\\n"); break; case '\r': - buf.append("\\r"); break; + sb.append("\\r"); break; case '\"': - buf.append("\\\""); break; + sb.append("\\\""); break; case '\'': - buf.append("\\'"); break; + sb.append("\\'"); break; case '\\': - buf.append("\\\\"); break; + sb.append("\\\\"); break; default: - buf.append(ch[i]); break; + sb.append(ch[i]); break; } } - return buf.toString(); + return sb.toString(); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ArrayType.java @@ -113,13 +113,13 @@ break; } - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(int i=0; i < this.dimensions; i++) - buf.append('['); + sb.append('['); - buf.append(basic_type.getSignature()); + sb.append(basic_type.getSignature()); - signature = buf.toString(); + signature = sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ConstantPoolGen.java @@ -702,12 +702,13 @@ * @return String representation. */ public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); - for(int i=1; i < index; i++) - buf.append(i + ")" + constants[i] + "\n"); + for(int i=1; i < index; i++) { + sb.append(i).append(')').append(constants[i]).append('\n'); + } - return buf.toString(); + return sb.toString(); } /** Import constant from another ConstantPool and return new index. diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldGen.java @@ -293,13 +293,14 @@ signature = type.toString(); name = getName(); - StringBuffer buf = new StringBuffer(access + signature + " " + name); + StringBuilder sb = new StringBuilder(); + sb.append(access).append(signature).append(' ').append(name); String value = getInitValue(); if(value != null) - buf.append(" = " + value); + sb.append(" = ").append(value); - return buf.toString(); + return sb.toString(); } /** @return deep copy of this field diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java @@ -739,25 +739,25 @@ for(InstructionHandle ih=first; ih != null; ih = ih.next) ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets - StringBuffer buf = new StringBuffer("{ "); + StringBuilder sb = new StringBuilder("{ "); for(InstructionHandle ih=first; ih != null; ih = next) { next = ih.next; length--; if(ih.hasTargeters()) { // Still got targeters? target_vec.add(ih); - buf.append(ih.toString(true) + " "); + sb.append(ih.toString(true)).append(' '); ih.next = ih.prev = null; } else ih.dispose(); } - buf.append("}"); + sb.append("}"); if(!target_vec.isEmpty()) { InstructionHandle[] targeted = new InstructionHandle[target_vec.size()]; target_vec.toArray(targeted); - throw new TargetLostException(targeted, buf.toString()); + throw new TargetLostException(targeted, sb.toString()); } } @@ -1017,13 +1017,13 @@ * @return String containing all instructions in this list. */ public String toString(boolean verbose) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(InstructionHandle ih=start; ih != null; ih = ih.next) { - buf.append(ih.toString(verbose) + "\n"); + sb.append(ih.toString(verbose)).append('\n'); } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/MethodGen.java @@ -1063,14 +1063,14 @@ signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable(cp)); - StringBuffer buf = new StringBuffer(signature); + StringBuilder sb = new StringBuilder(signature); if(throws_vec.size() > 0) { for(Iterator e = throws_vec.iterator(); e.hasNext(); ) - buf.append("\n\t\tthrows " + e.next()); + sb.append("\n\t\tthrows ").append(e.next()); } - return buf.toString(); + return sb.toString(); } /** @return deep copy of this method diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Type.java @@ -136,16 +136,16 @@ * @return method signature for given type(s). */ public static String getMethodSignature(Type return_type, Type[] arg_types) { - StringBuffer buf = new StringBuffer("("); + StringBuilder sb = new StringBuilder("("); int length = (arg_types == null)? 0 : arg_types.length; for(int i=0; i < length; i++) - buf.append(arg_types[i].getSignature()); + sb.append(arg_types[i].getSignature()); - buf.append(')'); - buf.append(return_type.getSignature()); + sb.append(')'); + sb.append(return_type.getSignature()); - return buf.toString(); + return sb.toString(); } private static int consumed_chars=0; // Remember position in string, see getArgumentTypes @@ -276,14 +276,14 @@ } public static String getSignature(java.lang.reflect.Method meth) { - StringBuffer sb = new StringBuffer("("); + StringBuilder sb = new StringBuilder('('); Class[] params = meth.getParameterTypes(); // avoid clone for(int j = 0; j < params.length; j++) { sb.append(getType(params[j]).getSignature()); } - sb.append(")"); + sb.append(')'); sb.append(getType(meth.getReturnType()).getSignature()); return sb.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELFactory.java @@ -268,20 +268,20 @@ Select s = (Select)bi; branches.add(bi); - StringBuffer args = new StringBuffer("new int[] { "); + StringBuilder sb = new StringBuilder("new int[] { "); int[] matchs = s.getMatchs(); for(int i=0; i < matchs.length; i++) { - args.append(matchs[i]); + sb.append(matchs[i]); if(i < matchs.length - 1) - args.append(", "); + sb.append(", "); } - args.append(" }"); + sb.append(" }"); _out.print(" Select " + name + " = new " + - bi.getName().toUpperCase() + "(" + args + + bi.getName().toUpperCase() + "(" + sb + ", new InstructionHandle[] { "); for(int i=0; i < matchs.length; i++) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/BCELifier.java @@ -233,19 +233,19 @@ if(flags == 0) return "0"; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(int i=0, pow=1; i <= Constants.MAX_ACC_FLAG; i++) { if((flags & pow) != 0) { if((pow == Constants.ACC_SYNCHRONIZED) && for_class) - buf.append("ACC_SUPER | "); + sb.append("ACC_SUPER | "); else - buf.append("ACC_" + Constants.ACCESS_NAMES[i].toUpperCase() + " | "); + sb.append("ACC_").append(Constants.ACCESS_NAMES[i].toUpperCase()).append(" | "); } pow <<= 1; } - String str = buf.toString(); + String str = sb.toString(); return str.substring(0, str.length() - 3); } @@ -253,16 +253,16 @@ if(arg_types.length == 0) return "Type.NO_ARGS"; - StringBuffer args = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(int i=0; i < arg_types.length; i++) { - args.append(printType(arg_types[i])); + sb.append(printType(arg_types[i])); if(i < arg_types.length - 1) - args.append(", "); + sb.append(", "); } - return "new Type[] { " + args.toString() + " }"; + return "new Type[] { " + sb.toString() + " }"; } static String printType(Type type) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/Class2HTML.java @@ -215,23 +215,23 @@ } static String toHTML(String str) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); try { // Filter any characters HTML doesn't like such as < and > in particular for(int i=0; i < str.length(); i++) { char ch; switch(ch=str.charAt(i)) { - case '<': buf.append("<"); break; - case '>': buf.append(">"); break; - case '\n': buf.append("\\n"); break; - case '\r': buf.append("\\r"); break; - default: buf.append(ch); + case '<': sb.append("<"); break; + case '>': sb.append(">"); break; + case '\n': sb.append("\\n"); break; + case '\r': sb.append("\\r"); break; + default: sb.append(ch); } } } catch(StringIndexOutOfBoundsException e) {} // Never occurs - return buf.toString(); + return sb.toString(); } private void writeMainHTML(AttributeHTML attribute_html) throws IOException { diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassPath.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassPath.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassPath.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ClassPath.java @@ -191,16 +191,16 @@ list.add(ext_path + File.separatorChar + extensions[i]); } - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(Iterator e = list.iterator(); e.hasNext(); ) { - buf.append((String)e.next()); + sb.append((String) e.next()); if(e.hasNext()) - buf.append(File.pathSeparatorChar); + sb.append(File.pathSeparatorChar); } - return buf.toString().intern(); + return sb.toString().intern(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java @@ -157,15 +157,15 @@ String type = Utility.methodSignatureReturnType(signature, false); String ret_type = Class2HTML.referenceType(type); - StringBuffer buf = new StringBuffer("("); + StringBuilder sb = new StringBuilder('('); for(int i=0; i < args.length; i++) { - buf.append(Class2HTML.referenceType(args[i])); + sb.append(Class2HTML.referenceType(args[i])); if(i < args.length - 1) - buf.append(", "); + sb.append(", "); } - buf.append(")"); + sb.append(')'); - String arg_types = buf.toString(); + String arg_types = sb.toString(); if(method_class.equals(class_name)) // Method is local to class ref = "= OFFSET) { if(make_string) - buf.append(Constants.OPCODE_NAMES[ch - OFFSET]); + sb.append(Constants.OPCODE_NAMES[ch - OFFSET]); else - buf.append((int)(ch - OFFSET)); + sb.append((int)(ch - OFFSET)); } else - buf.append(ch); + sb.append(ch); } - return buf.toString(); + return sb.toString(); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RE.java b/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RE.java --- a/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RE.java +++ b/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RE.java @@ -497,7 +497,7 @@ */ public static String simplePatternToFullRegularExpression(String pattern) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; i < pattern.length(); i++) { char c = pattern.charAt(i); @@ -1599,7 +1599,7 @@ public String subst(String substituteIn, String substitution, int flags) { // String to return - StringBuffer ret = new StringBuffer(); + StringBuilder ret = new StringBuilder(); // Start at position 0 and search the whole string int pos = 0; diff --git a/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RECompiler.java b/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RECompiler.java --- a/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RECompiler.java +++ b/src/java.xml/share/classes/com/sun/org/apache/regexp/internal/RECompiler.java @@ -298,7 +298,7 @@ } // Get min ('m' of {m,n}) number - StringBuffer number = new StringBuffer(); + StringBuilder number = new StringBuilder(); while (idx < len && Character.isDigit(pattern.charAt(idx))) { number.append(pattern.charAt(idx++)); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltBase.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltBase.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltBase.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltBase.java @@ -49,13 +49,13 @@ if (value == null) { NodeList nodelist = n.getChildNodes(); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < nodelist.getLength(); i++) { Node childNode = nodelist.item(i); - buf.append(toString(childNode)); + sb.append(toString(childNode)); } - return buf.toString(); + return sb.toString(); } else return value; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java @@ -82,14 +82,14 @@ // Format for date and time. SimpleDateFormat dateFormat = new SimpleDateFormat(dt); - StringBuffer buff = new StringBuffer(dateFormat.format(datetime)); + StringBuilder sb = new StringBuilder(dateFormat.format(datetime)); // Must also include offset from UTF. // Get the offset (in milliseconds). int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); // If there is no offset, we have "Coordinated // Universal Time." if (offset == 0) - buff.append("Z"); + sb.append('Z'); else { // Convert milliseconds to hours and minutes @@ -97,9 +97,9 @@ // In a few cases, the time zone may be +/-hh:30. int min = offset%(60*60*1000); char posneg = hrs < 0? '-': '+'; - buff.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min)); + sb.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min)); } - return buff.toString(); + return sb.toString(); } /** @@ -1088,7 +1088,7 @@ { int quoteSemaphore = 0; int i = 0; - StringBuffer result = new StringBuffer(pattern.length()); + StringBuilder result = new StringBuilder(pattern.length()); while (i < pattern.length()) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltStrings.java @@ -122,7 +122,7 @@ */ public static String concat(NodeList nl) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); @@ -155,7 +155,7 @@ if (pattern == null || pattern.length() == 0) return ""; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len = (int)length; int numAdded = 0; int index = 0; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java @@ -830,22 +830,22 @@ Class clazz = ObjectFactory.findProviderClass(XALAN1_VERSION_CLASS, true); // Found Xalan-J 1.x, grab it's version fields - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Field f = clazz.getField("PRODUCT"); - buf.append(f.get(null)); - buf.append(';'); + sb.append(f.get(null)); + sb.append(';'); f = clazz.getField("LANGUAGE"); - buf.append(f.get(null)); - buf.append(';'); + sb.append(f.get(null)); + sb.append(';'); f = clazz.getField("S_VERSION"); - buf.append(f.get(null)); - buf.append(';'); - h.put(VERSION + "xalan1", buf.toString()); + sb.append(f.get(null)); + sb.append(';'); + h.put(VERSION + "xalan1", sb.toString()); } catch (Exception e1) { @@ -862,11 +862,11 @@ Class clazz = ObjectFactory.findProviderClass(XALAN2_VERSION_CLASS, true); // Found Xalan-J 2.x, grab it's version fields - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Field f = clazz.getField("S_VERSION"); - buf.append(f.get(null)); + sb.append(f.get(null)); - h.put(VERSION + "xalan2x", buf.toString()); + h.put(VERSION + "xalan2x", sb.toString()); } catch (Exception e2) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java @@ -196,14 +196,14 @@ } public String toString() { - StringBuffer buf = new StringBuffer("attribute-set: "); + StringBuilder sb = new StringBuilder("attribute-set: "); // Translate all local attributes final Enumeration attributes = elements(); while (attributes.hasMoreElements()) { final XslAttribute attribute = (XslAttribute)attributes.nextElement(); - buf.append(attribute); + sb.append(attribute); } - return(buf.toString()); + return(sb.toString()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java @@ -84,7 +84,7 @@ */ String t = null; String lookahead = null; - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int state = OUT_EXPR; while (tokenizer.hasMoreTokens()) { @@ -104,11 +104,11 @@ case OUT_EXPR: lookahead = tokenizer.nextToken(); if (lookahead.equals("{")) { - buffer.append(lookahead); // replace {{ by { + sb.append(lookahead); // replace {{ by { lookahead = null; } else { - buffer.append(DELIMITER); + sb.append(DELIMITER); state = IN_EXPR; } break; @@ -125,7 +125,7 @@ case OUT_EXPR: lookahead = tokenizer.nextToken(); if (lookahead.equals("}")) { - buffer.append(lookahead); // replace }} by } + sb.append(lookahead); // replace }} by } lookahead = null; } else { @@ -134,12 +134,12 @@ } break; case IN_EXPR: - buffer.append(DELIMITER); + sb.append(DELIMITER); state = OUT_EXPR; break; case IN_EXPR_SQUOTES: case IN_EXPR_DQUOTES: - buffer.append(t); + sb.append(t); break; } break; @@ -155,7 +155,7 @@ case IN_EXPR_DQUOTES: break; } - buffer.append(t); + sb.append(t); break; case '\"': switch (state) { @@ -169,15 +169,15 @@ case IN_EXPR_SQUOTES: break; } - buffer.append(t); + sb.append(t); break; default: - buffer.append(t); + sb.append(t); break; } } else { - buffer.append(t); + sb.append(t); } } @@ -190,7 +190,7 @@ /* * Second pass: split up buffer into literal and non-literal expressions. */ - tokenizer = new StringTokenizer(buffer.toString(), DELIMITER, true); + tokenizer = new StringTokenizer(sb.toString(), DELIMITER, true); while (tokenizer.hasMoreTokens()) { t = tokenizer.nextToken(); @@ -218,14 +218,14 @@ } public String toString() { - final StringBuffer buffer = new StringBuffer("AVT:["); + final StringBuilder sb = new StringBuilder("AVT:["); final int count = elementCount(); for (int i = 0; i < count; i++) { - buffer.append(elementAt(i).toString()); + sb.append(elementAt(i).toString()); if (i < count - 1) - buffer.append(' '); + sb.append(' '); } - return buffer.append(']').toString(); + return sb.append(']').toString(); } public void translate(ClassGenerator classGen, MethodGenerator methodGen) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java @@ -142,8 +142,11 @@ il.append(methodGen.loadCurrentNode()); // Initialize prefix of method signature - StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG - + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG); + StringBuilder methodSig = new StringBuilder(); + methodSig.append('(').append(DOM_INTF_SIG) + .append(NODE_ITERATOR_SIG) + .append(TRANSLET_OUTPUT_SIG) + .append(NODE_SIG); // If calling a simply named template, push actual arguments if (_calleeTemplate != null) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java @@ -805,17 +805,17 @@ il.append(arg.getType().LOAD(paramTemp[i].getIndex()))); } - final StringBuffer buffer = new StringBuffer(); - buffer.append('('); + final StringBuilder sb = new StringBuilder(); + sb.append('('); for (int i = 0; i < paramTypes.length; i++) { - buffer.append(getSignature(paramTypes[i])); + sb.append(getSignature(paramTypes[i])); } - buffer.append(')'); - buffer.append("V"); + sb.append(')'); + sb.append('V'); index = cpg.addMethodref(clazz, - "", - buffer.toString()); + "", + sb.toString()); il.append(new INVOKESPECIAL(index)); // Convert the return type back to our internal type @@ -844,24 +844,24 @@ exp.getType().translateTo(classGen, methodGen, paramTypes[i]); } - final StringBuffer buffer = new StringBuffer(); - buffer.append('('); + final StringBuilder sb = new StringBuilder(); + sb.append('('); for (int i = 0; i < paramTypes.length; i++) { - buffer.append(getSignature(paramTypes[i])); + sb.append(getSignature(paramTypes[i])); } - buffer.append(')'); - buffer.append(getSignature(_chosenMethod.getReturnType())); + sb.append(')'); + sb.append(getSignature(_chosenMethod.getReturnType())); if (_thisArgument != null && _clazz.isInterface()) { index = cpg.addInterfaceMethodref(clazz, - _fname.getLocalPart(), - buffer.toString()); + _fname.getLocalPart(), + sb.toString()); il.append(new INVOKEINTERFACE(index, n+1)); } else { index = cpg.addMethodref(clazz, - _fname.getLocalPart(), - buffer.toString()); + _fname.getLocalPart(), + sb.toString()); il.append(_thisArgument != null ? (InvokeInstruction) new INVOKEVIRTUAL(index) : (InvokeInstruction) new INVOKESTATIC(index)); } @@ -984,10 +984,10 @@ */ static final String getSignature(Class clazz) { if (clazz.isArray()) { - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); Class cl = clazz; while (cl.isArray()) { - sb.append("["); + sb.append('['); cl = cl.getComponentType(); } sb.append(getSignature(cl)); @@ -1036,7 +1036,7 @@ * Compute the JVM method descriptor for the method. */ static final String getSignature(Method meth) { - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); sb.append('('); final Class[] params = meth.getParameterTypes(); // avoid clone for (int j = 0; j < params.length; j++) { @@ -1050,7 +1050,7 @@ * Compute the JVM constructor descriptor for the constructor. */ static final String getSignature(Constructor cons) { - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); sb.append('('); final Class[] params = cons.getParameterTypes(); // avoid clone for (int j = 0; j < params.length; j++) { @@ -1063,7 +1063,7 @@ * Return the signature of the current method */ private String getMethodSignature(Vector argsType) { - final StringBuffer buf = new StringBuffer(_className); + final StringBuilder buf = new StringBuilder(_className); buf.append('.').append(_fname.getLocalPart()).append('('); int nArgs = argsType.size(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Output.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Output.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Output.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Output.java @@ -241,7 +241,7 @@ _cdata = null; } else { - StringBuffer expandedNames = new StringBuffer(); + StringBuilder expandedNames = new StringBuilder(); StringTokenizer tokens = new StringTokenizer(_cdata); // Make sure to store names in expanded form diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Step.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Step.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Step.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Step.java @@ -524,7 +524,7 @@ * Returns a string representation of this step. */ public String toString() { - final StringBuffer buffer = new StringBuffer("step(\""); + final StringBuilder buffer = new StringBuilder("step(\""); buffer.append(Axis.getNames(_axis)).append("\", ").append(_nodeType); if (_predicates != null) { final int n = _predicates.size(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/StepPattern.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/StepPattern.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/StepPattern.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/StepPattern.java @@ -150,15 +150,15 @@ } public String toString() { - final StringBuffer buffer = new StringBuffer("stepPattern(\""); - buffer.append(Axis.getNames(_axis)) + final StringBuilder sb = new StringBuilder("stepPattern(\""); + sb.append(Axis.getNames(_axis)) .append("\", ") .append(_isEpsilon ? ("epsilon{" + Integer.toString(_nodeType) + "}") : Integer.toString(_nodeType)); if (_predicates != null) - buffer.append(", ").append(_predicates.toString()); - return buffer.append(')').toString(); + sb.append(", ").append(_predicates.toString()); + return sb.append(')').toString(); } private int analyzeCases() { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java @@ -101,7 +101,7 @@ */ public String toString() { final int count = _patterns.size(); - final StringBuffer result = new StringBuffer(); + final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { final LocationPathPattern pattern = diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java @@ -146,7 +146,7 @@ final SymbolTable stable = parser.getSymbolTable(); StringTokenizer list = new StringTokenizer(_elementList); - StringBuffer elements = new StringBuffer(Constants.EMPTYSTRING); + StringBuilder elements = new StringBuilder(Constants.EMPTYSTRING); while (list.hasMoreElements()) { String token = list.nextToken(); @@ -166,7 +166,7 @@ } if (list.hasMoreElements()) - elements.append(" "); + elements.append(' '); } _elementList = elements.toString(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java @@ -129,7 +129,7 @@ } // Prepend prefix to local name - final StringBuffer newName = new StringBuffer(prefix); + final StringBuilder newName = new StringBuilder(prefix); if (prefix != EMPTYSTRING) { newName.append(':'); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java @@ -260,7 +260,7 @@ } private String formatLine() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (_url != null) { result.append(_url); result.append(": "); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java @@ -70,7 +70,7 @@ } public String toString() { - StringBuffer result = new StringBuffer("method{"); + StringBuilder result = new StringBuilder("method{"); if (_argsType != null) { final int count = _argsType.size(); for (int i=0; ilastArgSig to the end of the argument list. */ public String toSignature(String lastArgSig) { - final StringBuffer buffer = new StringBuffer(); - buffer.append('('); + final StringBuilder sb = new StringBuilder(); + sb.append('('); if (_argsType != null) { final int n = _argsType.size(); for (int i = 0; i < n; i++) { - buffer.append(((Type)_argsType.elementAt(i)).toSignature()); + sb.append(((Type) _argsType.elementAt(i)).toSignature()); } } - return buffer + return sb .append(lastArgSig) .append(')') .append(_resultType.toSignature()) diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java @@ -95,9 +95,7 @@ } public String toSignature() { - final StringBuffer result = new StringBuffer("L"); - result.append(_javaClassName.replace('.', '/')).append(';'); - return result.toString(); + return "L" + _javaClassName.replace('.', '/') + ';'; } public com.sun.org.apache.bcel.internal.generic.Type toJCType() { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java @@ -85,7 +85,7 @@ */ public static String toJavaName(String name) { if (name.length() > 0) { - final StringBuffer result = new StringBuffer(); + final StringBuilder result = new StringBuilder(); char ch = name.charAt(0); result.append(Character.isJavaIdentifierStart(ch) ? ch : '_'); @@ -138,7 +138,7 @@ public static String replace(String base, String delim, String[] str) { final int len = base.length(); - final StringBuffer result = new StringBuffer(); + final StringBuilder result = new StringBuilder(); for (int i = 0; i < len; i++) { final char ch = base.charAt(i); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java @@ -632,11 +632,11 @@ if (_size == 1) _text = _textArray[0]; else { - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < _size; i++) { - buffer.append(_textArray[i]); + sb.append(_textArray[i]); } - _text = buffer.toString(); + _text = sb.toString(); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java @@ -286,19 +286,19 @@ public String toString() { int i; int max = size() - 1; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Enumeration k = keys(); Enumeration e = elements(); - buf.append("{"); + sb.append('{'); for (i = 0; i <= max; i++) { String s1 = k.nextElement().toString(); String s2 = e.nextElement().toString(); - buf.append(s1).append('=').append(s2); - if (i < max) buf.append(", "); + sb.append(s1).append('=').append(s2); + if (i < max) sb.append(", "); } - buf.append("}"); - return buf.toString(); + sb.append('}'); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java @@ -268,7 +268,7 @@ } } else { - StringBuffer errorMessage = new StringBuffer(); + StringBuilder errorMessage = new StringBuilder(); Vector errors = _parser.getErrors(); final int count = errors.size(); for (int i = 0; i < count; i++) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java @@ -466,7 +466,7 @@ if (node == null || data == null) return (data == null)?"":data; - StringBuffer value = new StringBuffer(data); + StringBuilder value = new StringBuilder(data); while (node != null) { if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE){ data = ((EntityReferenceImpl)node).getEntityRefValue(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java @@ -95,7 +95,7 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/EntityReferenceImpl.java @@ -224,7 +224,7 @@ return value; } else { - StringBuffer buff = new StringBuffer(value); + StringBuilder sb = new StringBuilder(value); ChildNode next = firstChild.nextSibling; while (next != null){ @@ -238,11 +238,11 @@ // invalid to have other types of nodes in attr value return null; } - buff.append(value); + sb.append(value); next = next.nextSibling; } - return buff.toString(); + return sb.toString(); } } return ""; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/RangeImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/RangeImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/RangeImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/RangeImpl.java @@ -779,7 +779,7 @@ Node node = fStartContainer; Node stopNode = fEndContainer; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (fStartContainer.getNodeType() == Node.TEXT_NODE || fStartContainer.getNodeType() == Node.CDATA_SECTION_NODE ) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java @@ -1054,11 +1054,11 @@ //storing elemnetPointer for particular element depth if(DEBUG_SKIP_ALGORITHM){ - StringBuffer sb = new StringBuffer() ; + StringBuilder sb = new StringBuilder() ; sb.append(" Storing element information ") ; - sb.append(" fElementPointer = " + fElementPointer) ; - sb.append(" fElementRawname = " + fElementQName.rawname) ; - sb.append(" fElementStack.fDepth = " + fElementStack.fDepth); + sb.append(" fElementPointer = ").append(fElementPointer) ; + sb.append(" fElementRawname = ").append(fElementQName.rawname) ; + sb.append(" fElementStack.fDepth = ").append(fElementStack.fDepth); System.out.println(sb.toString()) ; } @@ -1101,12 +1101,12 @@ if(canStore(depth, i)){ fPointerInfo[depth][i] = elementPointer ; if(DEBUG_SKIP_ALGORITHM){ - StringBuffer sb = new StringBuffer() ; + StringBuilder sb = new StringBuilder() ; sb.append(" Pointer information ") ; - sb.append(" fElementPointer = " + fElementPointer) ; - sb.append(" fElementStack.fDepth = " + fElementStack.fDepth); - sb.append(" column = " + i ) ; - System.out.println(sb.toString()) ; + sb.append(" fElementPointer = ").append(fElementPointer) ; + sb.append(" fElementStack.fDepth = ").append(fElementStack.fDepth); + sb.append(" column = ").append(i); + System.out.println(sb.toString()); } return i; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -1826,12 +1826,12 @@ userDir = userDir.replace(separator, '/'); int len = userDir.length(), ch; - StringBuffer buffer = new StringBuffer(len*3); + StringBuilder sb = new StringBuilder(len*3); // change C:/blah to /C:/blah if (len >= 2 && userDir.charAt(1) == ':') { ch = Character.toUpperCase(userDir.charAt(0)); if (ch >= 'A' && ch <= 'Z') { - buffer.append('/'); + sb.append('/'); } } @@ -1843,13 +1843,13 @@ if (ch >= 128) break; if (gNeedEscaping[ch]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[ch]); - buffer.append(gAfterEscaping2[ch]); + sb.append('%'); + sb.append(gAfterEscaping1[ch]); + sb.append(gAfterEscaping2[ch]); // record the fact that it's escaped } else { - buffer.append((char)ch); + sb.append((char) ch); } } @@ -1872,26 +1872,26 @@ // for non-ascii character: make it positive, then escape if (b < 0) { ch = b + 256; - buffer.append('%'); - buffer.append(gHexChs[ch >> 4]); - buffer.append(gHexChs[ch & 0xf]); + sb.append('%'); + sb.append(gHexChs[ch >> 4]); + sb.append(gHexChs[ch & 0xf]); } else if (gNeedEscaping[b]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[b]); - buffer.append(gAfterEscaping2[b]); + sb.append('%'); + sb.append(gAfterEscaping1[b]); + sb.append(gAfterEscaping2[b]); } else { - buffer.append((char)b); + sb.append((char) b); } } } // change blah/blah to blah/blah/ if (!userDir.endsWith("/")) - buffer.append('/'); - - gUserDirURI = new URI("file", "", buffer.toString(), null, null); + sb.append('/'); + + gUserDirURI = new URI("file", "", sb.toString(), null, null); return gUserDirURI; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java @@ -398,7 +398,7 @@ message = messageFormatter.formatMessage(fLocale, key, arguments); } else { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); str.append(domain); str.append('#'); str.append(key); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java @@ -1314,20 +1314,20 @@ // character reference must be a valid XML character if (isInvalid(value)) { - StringBuffer errorBuf = new StringBuffer(fStringBuffer3.length + 1); - if (hex) errorBuf.append('x'); - errorBuf.append(fStringBuffer3.ch, fStringBuffer3.offset, fStringBuffer3.length); + StringBuilder errorSB = new StringBuilder(fStringBuffer3.length + 1); + if (hex) errorSB.append('x'); + errorSB.append(fStringBuffer3.ch, fStringBuffer3.offset, fStringBuffer3.length); reportFatalError("InvalidCharRef", - new Object[]{errorBuf.toString()}); + new Object[]{errorSB.toString()}); } } catch (NumberFormatException e) { // Conversion failed, let -1 value drop through. // If we end up here, the character reference was invalid. - StringBuffer errorBuf = new StringBuffer(fStringBuffer3.length + 1); - if (hex) errorBuf.append('x'); - errorBuf.append(fStringBuffer3.ch, fStringBuffer3.offset, fStringBuffer3.length); + StringBuilder sb = new StringBuilder(fStringBuffer3.length + 1); + if (hex) sb.append('x'); + sb.append(fStringBuffer3.ch, fStringBuffer3.offset, fStringBuffer3.length); reportFatalError("InvalidCharRef", - new Object[]{errorBuf.toString()}); + new Object[]{sb.toString()}); } // append corresponding chars to the given buffer diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java @@ -840,7 +840,7 @@ "parser must be on START_ELEMENT to read next text", getLocation()); } int eventType = next(); - StringBuffer content = new StringBuffer(); + StringBuilder content = new StringBuilder(); while(eventType != XMLStreamConstants.END_ELEMENT ) { if(eventType == XMLStreamConstants.CHARACTERS || eventType == XMLStreamConstants.CDATA @@ -903,20 +903,20 @@ } public String toString(){ - StringBuffer sbuffer = new StringBuffer() ; - sbuffer.append("Line number = " + getLineNumber()); - sbuffer.append("\n") ; - sbuffer.append("Column number = " + getColumnNumber()); - sbuffer.append("\n") ; - sbuffer.append("System Id = " + getSystemId()); - sbuffer.append("\n") ; - sbuffer.append("Public Id = " + getPublicId()); - sbuffer.append("\n") ; - sbuffer.append("Location Uri= " + getLocationURI()); - sbuffer.append("\n") ; - sbuffer.append("CharacterOffset = " + getCharacterOffset()); - sbuffer.append("\n") ; - return sbuffer.toString(); + StringBuilder sb = new StringBuilder() ; + sb.append("Line number = ").append(getLineNumber()); + sb.append('\n') ; + sb.append("Column number = ").append(getColumnNumber()); + sb.append('\n') ; + sb.append("System Id = ").append(getSystemId()); + sb.append('\n') ; + sb.append("Public Id = ").append(getPublicId()); + sb.append('\n') ; + sb.append("Location Uri= ").append(getLocationURI()); + sb.append('\n') ; + sb.append("CharacterOffset = ").append(getCharacterOffset()); + sb.append('\n') ; + return sb.toString(); } } ; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java @@ -514,10 +514,8 @@ // To get the DTD scanner to end at the right place we have to fool // it into thinking that it reached the end of the internal subset // in a real document. - StringBuffer buffer = new StringBuffer(internalSubset.length() + 2); - buffer.append(internalSubset).append("]>"); XMLInputSource is = new XMLInputSource(null, baseSystemId, - null, new StringReader(buffer.toString()), null); + null, new StringReader(internalSubset + "]>"), null); fEntityManager.startDocumentEntity(is); fDTDScanner.scanDTDInternalSubset(true, false, systemId != null); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java @@ -1384,10 +1384,10 @@ } if (!found) { - StringBuffer enumValueString = new StringBuffer(); + StringBuilder enumValueString = new StringBuilder(); if (enumVals != null) for (int i = 0; i < enumVals.length; i++) { - enumValueString.append(enumVals[i]+" "); + enumValueString.append(enumVals[i]).append(' '); } fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_ATTRIBUTE_VALUE_NOT_IN_LIST", @@ -1753,16 +1753,16 @@ return attrDecl.simpleType.list ? XMLSymbols.fENTITIESSymbol : XMLSymbols.fENTITYSymbol; } case XMLSimpleType.TYPE_ENUMERATION: { - StringBuffer buffer = new StringBuffer(); - buffer.append('('); + StringBuilder sb = new StringBuilder(); + sb.append('('); for (int i=0; i 0) { - buffer.append('|'); + sb.append('|'); } - buffer.append(attrDecl.simpleType.enumeration[i]); + sb.append(attrDecl.simpleType.enumeration[i]); } - buffer.append(')'); - return fSymbolTable.addSymbol(buffer.toString()); + sb.append(')'); + return fSymbolTable.addSymbol(sb.toString()); } case XMLSimpleType.TYPE_ID: { return XMLSymbols.fIDSymbol; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMAny.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMAny.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMAny.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMAny.java @@ -148,21 +148,18 @@ public String toString() { - StringBuffer strRet = new StringBuffer(); - strRet.append("("); - strRet.append("##any:uri="); - strRet.append(fURI); - strRet.append(')'); + StringBuilder sb = new StringBuilder(); + sb.append("("); + sb.append("##any:uri="); + sb.append(fURI); + sb.append(')'); if (fPosition >= 0) { - strRet.append - ( - " (Pos:" - + new Integer(fPosition).toString() - + ")" - ); + sb.append(" (Pos:") + .append(Integer.toString(fPosition)) + .append(')'); } - return strRet.toString(); + return sb.toString(); } // protected diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMLeaf.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMLeaf.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMLeaf.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMLeaf.java @@ -141,22 +141,19 @@ public String toString() { - StringBuffer strRet = new StringBuffer(fElement.toString()); - strRet.append(" ("); - strRet.append(fElement.uri); - strRet.append(','); - strRet.append(fElement.localpart); - strRet.append(')'); + StringBuilder sb = new StringBuilder(fElement.toString()); + sb.append(" ("); + sb.append(fElement.uri); + sb.append(','); + sb.append(fElement.localpart); + sb.append(')'); if (fPosition >= 0) { - strRet.append - ( - " (Pos:" - + new Integer(fPosition).toString() - + ")" - ); + sb.append(" (Pos:") + .append(Integer.toString(fPosition)) + .append(')'); } - return strRet.toString(); + return sb.toString(); } // protected diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMStateSet.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMStateSet.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMStateSet.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMStateSet.java @@ -115,14 +115,14 @@ // ------------------------------------------------------------------- public String toString() { - StringBuffer strRet = new StringBuffer(); + StringBuilder strRet = new StringBuilder(); try { - strRet.append("{"); + strRet.append('{'); for (int index = 0; index < fBitCount; index++) { if (getBit(index)) - strRet.append(" " + index); + strRet.append(' ').append(index); } strRet.append(" }"); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java @@ -105,7 +105,7 @@ // and non-ASCII characters (whose value >= 128). private static String encode(String anyURI){ int len = anyURI.length(), ch; - StringBuffer buffer = new StringBuffer(len*3); + StringBuilder sb = new StringBuilder(len*3); // for each character in the anyURI int i = 0; @@ -115,12 +115,12 @@ if (ch >= 128) break; if (gNeedEscaping[ch]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[ch]); - buffer.append(gAfterEscaping2[ch]); + sb.append('%'); + sb.append(gAfterEscaping1[ch]); + sb.append(gAfterEscaping2[ch]); } else { - buffer.append((char)ch); + sb.append((char) ch); } } @@ -143,25 +143,25 @@ // for non-ascii character: make it positive, then escape if (b < 0) { ch = b + 256; - buffer.append('%'); - buffer.append(gHexChs[ch >> 4]); - buffer.append(gHexChs[ch & 0xf]); + sb.append('%'); + sb.append(gHexChs[ch >> 4]); + sb.append(gHexChs[ch & 0xf]); } else if (gNeedEscaping[b]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[b]); - buffer.append(gAfterEscaping2[b]); + sb.append('%'); + sb.append(gAfterEscaping1[b]); + sb.append(gAfterEscaping2[b]); } else { - buffer.append((char)b); + sb.append((char) b); } } } // If encoding happened, create a new string; // otherwise, return the orginal one. - if (buffer.length() != len) { - return buffer.toString(); + if (sb.length() != len) { + return sb.toString(); } else { return anyURI; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java @@ -62,15 +62,15 @@ public synchronized String toString() { if (canonical == null) { int len = data.length; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (len > 0) { - buf.append(data[0].toString()); + sb.append(data[0].toString()); } for (int i = 1; i < len; i++) { - buf.append(' '); - buf.append(data[i].toString()); + sb.append(' '); + sb.append(data[i].toString()); } - canonical = buf.toString(); + canonical = sb.toString(); } return canonical; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java @@ -307,31 +307,31 @@ //otherwise the 2 combined values are the same if(pvalue > val.pvalue) { int expDiff = pvalue - val.pvalue; - StringBuffer buffer = new StringBuffer(ivalue); - StringBuffer fbuffer = new StringBuffer(fvalue); + StringBuilder sb = new StringBuilder(ivalue); + StringBuilder fsb = new StringBuilder(fvalue); for(int i = 0;i < expDiff; i++) { if(i < fracDigits) { - buffer.append(fvalue.charAt(i)); - fbuffer.deleteCharAt(i); + sb.append(fvalue.charAt(i)); + fsb.deleteCharAt(i); } else - buffer.append('0'); + sb.append('0'); } - return compareDecimal(buffer.toString(), val.ivalue, fbuffer.toString(), val.fvalue); + return compareDecimal(sb.toString(), val.ivalue, fsb.toString(), val.fvalue); } else { int expDiff = val.pvalue - pvalue; - StringBuffer buffer = new StringBuffer(val.ivalue); - StringBuffer fbuffer = new StringBuffer(val.fvalue); + StringBuilder sb = new StringBuilder(val.ivalue); + StringBuilder fsb = new StringBuilder(val.fvalue); for(int i = 0;i < expDiff; i++) { if(i < val.fracDigits) { - buffer.append(val.fvalue.charAt(i)); - fbuffer.deleteCharAt(i); + sb.append(val.fvalue.charAt(i)); + fsb.deleteCharAt(i); } else - buffer.append('0'); + sb.append('0'); } - return compareDecimal(ivalue, buffer.toString(), fvalue, fbuffer.toString()); + return compareDecimal(ivalue, sb.toString(), fvalue, fsb.toString()); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java @@ -1934,31 +1934,31 @@ } catch(InvalidDatatypeValueException invalidValue) { } } - StringBuffer typesBuffer = new StringBuffer(); + StringBuilder typesBuilder = new StringBuilder(); XSSimpleTypeDecl decl; for(int i = 0;i < fMemberTypes.length; i++) { if(i != 0) - typesBuffer.append(" | "); + typesBuilder.append(" | "); decl = fMemberTypes[i]; if(decl.fTargetNamespace != null) { - typesBuffer.append('{'); - typesBuffer.append(decl.fTargetNamespace); - typesBuffer.append('}'); + typesBuilder.append('{'); + typesBuilder.append(decl.fTargetNamespace); + typesBuilder.append('}'); } - typesBuffer.append(decl.fTypeName); + typesBuilder.append(decl.fTypeName); if(decl.fEnumeration != null) { Vector v = decl.fEnumeration; - typesBuffer.append(" : ["); + typesBuilder.append(" : ["); for(int j = 0;j < v.size(); j++) { if(j != 0) - typesBuffer.append(','); - typesBuffer.append(v.elementAt(j)); + typesBuilder.append(','); + typesBuilder.append(v.elementAt(j)); } - typesBuffer.append(']'); + typesBuilder.append(']'); } } throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", - new Object[]{content, fTypeName, typesBuffer.toString()}); + new Object[]{content, fTypeName, typesBuilder.toString()}); } }//getActualValue() @@ -1984,7 +1984,7 @@ if (len == 0 || ws == WS_PRESERVE) return content; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (ws == WS_REPLACE) { char ch; // when it's replace, just replace #x9, #xa, #xd by #x20 diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java @@ -104,13 +104,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java @@ -106,13 +106,13 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { str.append('&'); } - str.append(String.valueOf(arguments[i])); + str.append(arguments[i]); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java @@ -101,14 +101,14 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer buf=new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i=0;i0){ - buf.append("|"); + sb.append('|'); } - buf.append(fLocationPaths[i].toString()); + sb.append(fLocationPaths[i].toString()); } - return buf.toString(); + return sb.toString(); } // toString():String // @@ -402,7 +402,7 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < steps.length; i++) { if (i > 0 && (steps[i-1].axis.type!=Axis.DESCENDANT && steps[i].axis.type!=Axis.DESCENDANT) ){ diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/REUtil.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/REUtil.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/REUtil.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/REUtil.java @@ -110,7 +110,7 @@ } static final String createOptionString(int options) { - StringBuffer sb = new StringBuffer(9); + StringBuilder sb = new StringBuilder(9); if ((options & RegularExpression.PROHIBIT_FIXED_STRING_OPTIMIZATION) != 0) sb.append((char)'F'); if ((options & RegularExpression.PROHIBIT_HEAD_CHARACTER_OPTIMIZATION) != 0) @@ -138,7 +138,7 @@ static String stripExtendedComment(String regex) { int len = regex.length(); - StringBuffer buffer = new StringBuffer(len); + StringBuilder sb = new StringBuilder(len); int offset = 0; while (offset < len) { int ch = regex.charAt(offset++); @@ -160,17 +160,17 @@ if ((next = regex.charAt(offset)) == '#' || next == '\t' || next == '\n' || next == '\f' || next == '\r' || next == ' ') { - buffer.append((char)next); + sb.append((char) next); offset ++; } else { // Other escaped character. - buffer.append((char)'\\'); - buffer.append((char)next); + sb.append((char) '\\'); + sb.append((char) next); offset ++; } } else // As is. - buffer.append((char)ch); + sb.append((char)ch); } - return buffer.toString(); + return sb.toString(); } // ================================================================ diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java @@ -552,7 +552,7 @@ else if (this == Token.token_spaces) ret = "\\s"; else { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < this.ranges.length; i += 2) { if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(","); @@ -575,7 +575,7 @@ else if (this == Token.token_not_spaces) ret = "\\S"; else { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("[^"); for (int i = 0; i < this.ranges.length; i += 2) { if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(","); @@ -587,7 +587,7 @@ sb.append(escapeCharInCharClass(this.ranges[i+1])); } } - sb.append("]"); + sb.append(']'); ret = sb.toString(); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java @@ -820,7 +820,7 @@ //REVISIT: do we really need to support block names as in Unicode 3.1 // or we can just create all the names in IsBLOCKNAME format (XML Schema REC)? // - StringBuffer buffer = new StringBuffer(50); + StringBuilder sb = new StringBuilder(50); for (int i = 0; i < Token.blockNames.length; i ++) { Token r1 = Token.createRange(); int location; @@ -846,16 +846,16 @@ } Token.categories.put(n, r1); Token.categories2.put(n, Token.complementRanges(r1)); - buffer.setLength(0); - buffer.append("Is"); + sb.setLength(0); + sb.append("Is"); if (n.indexOf(' ') >= 0) { for (int ci = 0; ci < n.length(); ci ++) - if (n.charAt(ci) != ' ') buffer.append((char)n.charAt(ci)); + if (n.charAt(ci) != ' ') sb.append((char)n.charAt(ci)); } else { - buffer.append(n); + sb.append(n); } - Token.setAlias(buffer.toString(), n, true); + Token.setAlias(sb.toString(), n, true); } // TR#18 1.2 diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java @@ -3290,7 +3290,7 @@ } private String expectedStr(Vector expected) { - StringBuffer ret = new StringBuffer("{"); + StringBuilder ret = new StringBuilder("{"); int size = expected.size(); for (int i = 0; i < size; i++) { if (i > 0) @@ -3726,7 +3726,7 @@ } // construct value string - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < length; i++) { if (i > 0) { str.append(','); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java @@ -137,15 +137,7 @@ public String toString() { if (fDescription == null) { if (fTargetNamespace != null) { - StringBuffer buffer = new StringBuffer( - fTargetNamespace.length() + - ((fName != null) ? fName.length() : 4) + 3); - buffer.append('"'); - buffer.append(fTargetNamespace); - buffer.append('"'); - buffer.append(':'); - buffer.append(fName); - fDescription = buffer.toString(); + fDescription = "\"" + fTargetNamespace + '"' + ':' + fName; } else { fDescription = fName; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java @@ -149,23 +149,23 @@ public String toString() { // REVISIT: Commented code may help to eliminate redundant parentheses (test first before committing) if (fDescription == null) { - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (fCompositor == MODELGROUP_ALL) - buffer.append("all("); + sb.append("all("); else //if (fMinOccurs != 1 || fMaxOccurs != 1) - buffer.append('('); + sb.append('('); if (fParticleCount > 0) - buffer.append(fParticles[0].toString()); + sb.append(fParticles[0].toString()); for (int i = 1; i < fParticleCount; i++) { if (fCompositor == MODELGROUP_CHOICE) - buffer.append('|'); + sb.append('|'); else - buffer.append(','); - buffer.append(fParticles[i].toString()); + sb.append(','); + sb.append(fParticles[i].toString()); } //if (fCompositor == MODELGROUP_ALL || fMinOccurs != 1 || fMaxOccurs != 1) - buffer.append(')'); - fDescription = buffer.toString(); + sb.append(')'); + fDescription = sb.toString(); } return fDescription; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java @@ -479,36 +479,36 @@ private String fDescription = null; public String toString() { if (fDescription == null) { - StringBuffer buffer = new StringBuffer(); - buffer.append("WC["); + StringBuilder sb = new StringBuilder(); + sb.append("WC["); switch (fType) { case NSCONSTRAINT_ANY: - buffer.append(SchemaSymbols.ATTVAL_TWOPOUNDANY); + sb.append(SchemaSymbols.ATTVAL_TWOPOUNDANY); break; case NSCONSTRAINT_NOT: - buffer.append(SchemaSymbols.ATTVAL_TWOPOUNDOTHER); - buffer.append(":\""); + sb.append(SchemaSymbols.ATTVAL_TWOPOUNDOTHER); + sb.append(":\""); if (fNamespaceList[0] != null) - buffer.append(fNamespaceList[0]); - buffer.append("\""); + sb.append(fNamespaceList[0]); + sb.append("\""); break; case NSCONSTRAINT_LIST: if (fNamespaceList.length == 0) break; - buffer.append("\""); + sb.append("\""); if (fNamespaceList[0] != null) - buffer.append(fNamespaceList[0]); - buffer.append("\""); + sb.append(fNamespaceList[0]); + sb.append("\""); for (int i = 1; i < fNamespaceList.length; i++) { - buffer.append(",\""); + sb.append(",\""); if (fNamespaceList[i] != null) - buffer.append(fNamespaceList[i]); - buffer.append("\""); + sb.append(fNamespaceList[i]); + sb.append("\""); } break; } - buffer.append(']'); - fDescription = buffer.toString(); + sb.append(']'); + fDescription = sb.toString(); } return fDescription; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java @@ -138,7 +138,7 @@ // Unless xpath starts with a descendant node -Achille Fokoue // ... or a '.' or a '/' - NG // And we also need to prefix exprs to the right of | with ./ - NG - StringBuffer modifiedXPath = new StringBuffer(xpath.length()+5); + StringBuilder modifiedXPath = new StringBuilder(xpath.length()+5); int unionIndex = -1; do { if(!(XMLChar.trim(xpath).startsWith("/") || XMLChar.trim(xpath).startsWith("."))) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/XPathMatcher.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/XPathMatcher.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/XPathMatcher.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/identity/XPathMatcher.java @@ -419,7 +419,7 @@ /*** return fLocationPath.toString(); /***/ - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); String s = super.toString(); int index2 = s.lastIndexOf('.'); if (index2 != -1) { @@ -453,7 +453,7 @@ /** Normalizes text. */ private String normalize(String s) { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); int length = s.length(); for (int i = 0; i < length; i++) { char c = s.charAt(i); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMLeaf.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMLeaf.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMLeaf.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMLeaf.java @@ -98,7 +98,7 @@ } public String toString() { - StringBuffer strRet = new StringBuffer(fLeaf.toString()); + StringBuilder strRet = new StringBuilder(fLeaf.toString()); if (fPosition >= 0) { strRet.append ( diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java @@ -427,7 +427,7 @@ private static String escapeAttValue(String original, int from) { int i; final int length = original.length(); - StringBuffer newVal = new StringBuffer(length); + StringBuilder newVal = new StringBuilder(length); newVal.append(original.substring(0, from)); for (i = from; i < length; ++i) { char currChar = original.charAt(i); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java @@ -1625,7 +1625,7 @@ if (len == 0 || ws == XSSimpleType.WS_PRESERVE) return content; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (ws == XSSimpleType.WS_REPLACE) { char ch; // when it's replace, just replace #x9, #xa, #xd by #x20 diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java @@ -145,8 +145,8 @@ Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA]; // optimize for case where there are no local attributes if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) { - StringBuffer localStrBuffer = new StringBuffer(64); - localStrBuffer.append(" "); + StringBuilder localStrBuilder = new StringBuilder(64); + localStrBuilder.append(' '); // Vector should contain rawname value pairs int i = 0; while (i < annotationLocalAttrs.size()) { @@ -166,24 +166,24 @@ i++; // skip the next value, too continue; } - localStrBuffer.append(rawname) + localStrBuilder.append(rawname) .append("=\""); String value = (String)annotationLocalAttrs.elementAt(i++); // search for pesky "s and 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java @@ -938,13 +938,13 @@ if (type.equals("NOTATION") || type.equals("ENUMERATION")) { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); if (type.equals("NOTATION")) { str.append(type); str.append(" ("); } else { - str.append("("); + str.append('('); } for (int i = 0; i < enumeration.length; i++) { str.append(enumeration[i]); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/AugmentationsImpl.java @@ -194,21 +194,21 @@ } public String toString() { - StringBuffer buff = new StringBuffer(); - buff.append("SmallContainer - fNumEntries == " + fNumEntries); + StringBuilder sb = new StringBuilder(); + sb.append("SmallContainer - fNumEntries == ").append(fNumEntries); for (int i = 0; i < SIZE_LIMIT*2; i=i+2) { - buff.append("\nfAugmentations["); - buff.append(i); - buff.append("] == "); - buff.append(fAugmentations[i]); - buff.append("; fAugmentations["); - buff.append(i+1); - buff.append("] == "); - buff.append(fAugmentations[i+1]); + sb.append("\nfAugmentations["); + sb.append(i); + sb.append("] == "); + sb.append(fAugmentations[i]); + sb.append("; fAugmentations["); + sb.append(i + 1); + sb.append("] == "); + sb.append(fAugmentations[i + 1]); } - return buff.toString(); + return sb.toString(); } class SmallContainerKeyEnumeration implements Enumeration { @@ -271,19 +271,19 @@ } public String toString() { - StringBuffer buff = new StringBuffer(); - buff.append("LargeContainer"); + StringBuilder sb = new StringBuilder(); + sb.append("LargeContainer"); Enumeration keys = fAugmentations.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); - buff.append("\nkey == "); - buff.append(key); - buff.append("; value == "); - buff.append(fAugmentations.get(key)); + sb.append("\nkey == "); + sb.append(key); + sb.append("; value == "); + sb.append(fAugmentations.get(key)); } - return buff.toString(); + return sb.toString(); } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMUtil.java @@ -722,7 +722,7 @@ } // concatenate children text - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); Node child = node.getFirstChild(); while (child != null) { short type = child.getNodeType(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java @@ -89,7 +89,7 @@ if (msg == null) { msg = key; if (arguments.length > 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/NamespaceSupport.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/NamespaceSupport.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/NamespaceSupport.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/NamespaceSupport.java @@ -423,13 +423,13 @@ } public String toString(){ - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i=0;i 0) { - StringBuffer str = new StringBuffer(msg); + StringBuilder str = new StringBuilder(msg); str.append('?'); for (int i = 0; i < arguments.length; i++) { if (i > 0) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLEntityDescriptionImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLEntityDescriptionImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLEntityDescriptionImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLEntityDescriptionImpl.java @@ -151,7 +151,7 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); if (fEntityName != null) { str.append(fEntityName); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java @@ -204,7 +204,7 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); if (fPublicId != null) { str.append(fPublicId); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/QName.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/QName.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/QName.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/QName.java @@ -210,31 +210,31 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); boolean comma = false; if (prefix != null) { - str.append("prefix=\""+prefix+'"'); + str.append("prefix=\"").append(prefix).append('"'); comma = true; } if (localpart != null) { if (comma) { str.append(','); } - str.append("localpart=\""+localpart+'"'); + str.append("localpart=\"").append(localpart).append('"'); comma = true; } if (rawname != null) { if (comma) { str.append(','); } - str.append("rawname=\""+rawname+'"'); + str.append("rawname=\"").append(rawname).append('"'); comma = true; } if (uri != null) { if (comma) { str.append(','); } - str.append("uri=\""+uri+'"'); + str.append("uri=\"").append(uri).append('"'); } return str.toString(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParseException.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParseException.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParseException.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParseException.java @@ -141,7 +141,7 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); if (fPublicId != null) { str.append(fPublicId); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/DTMException.java @@ -216,11 +216,11 @@ */ public String getMessageAndLocation() { - StringBuffer sbuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String message = super.getMessage(); if (null != message) { - sbuffer.append(message); + sb.append(message); } if (null != locator) { @@ -229,22 +229,22 @@ int column = locator.getColumnNumber(); if (null != systemID) { - sbuffer.append("; SystemID: "); - sbuffer.append(systemID); + sb.append("; SystemID: "); + sb.append(systemID); } if (0 != line) { - sbuffer.append("; Line#: "); - sbuffer.append(line); + sb.append("; Line#: "); + sb.append(line); } if (0 != column) { - sbuffer.append("; Column#: "); - sbuffer.append(column); + sb.append("; Column#: "); + sb.append(column); } } - return sbuffer.toString(); + return sb.toString(); } /** @@ -256,27 +256,27 @@ public String getLocationAsString() { if (null != locator) { - StringBuffer sbuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String systemID = locator.getSystemId(); int line = locator.getLineNumber(); int column = locator.getColumnNumber(); if (null != systemID) { - sbuffer.append("; SystemID: "); - sbuffer.append(systemID); + sb.append("; SystemID: "); + sb.append(systemID); } if (0 != line) { - sbuffer.append("; Line#: "); - sbuffer.append(line); + sb.append("; Line#: "); + sb.append(line); } if (0 != column) { - sbuffer.append("; Column#: "); - sbuffer.append(column); + sb.append("; Column#: "); + sb.append(column); } - return sbuffer.toString(); + return sb.toString(); } else { return null; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java @@ -1194,7 +1194,7 @@ if (origPath != null && origPath.length() != 0 && origPath.indexOf('%') != -1) { // Locate the escape characters StringTokenizer tokenizer = new StringTokenizer(origPath, "%"); - StringBuffer result = new StringBuffer(origPath.length()); + StringBuilder result = new StringBuilder(origPath.length()); int size = tokenizer.countTokens(); result.append(tokenizer.nextToken()); for(int i = 1; i < size; ++i) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java @@ -2550,7 +2550,7 @@ Vector v = new Vector(); int l = s.length(); boolean inCurly = false; - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); // parse through string, breaking on whitespaces. I do this instead // of a tokenizer so I can track whitespace inside of curly brackets, @@ -2563,10 +2563,10 @@ { if (!inCurly) { - if (buf.length() > 0) + if (sb.length() > 0) { - addCdataSectionElement(buf.toString(), v); - buf.setLength(0); + addCdataSectionElement(sb.toString(), v); + sb.setLength(0); } continue; } @@ -2576,13 +2576,13 @@ else if ('}' == c) inCurly = false; - buf.append(c); + sb.append(c); } - if (buf.length() > 0) + if (sb.length() > 0) { - addCdataSectionElement(buf.toString(), v); - buf.setLength(0); + addCdataSectionElement(sb.toString(), v); + sb.setLength(0); } // call the official, public method to set the collected names setCdataSectionElements(v); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java @@ -1319,7 +1319,7 @@ { if (m_tracer != null) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append('<'); sb.append(elementName); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/SystemIDResolver.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/SystemIDResolver.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/SystemIDResolver.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/SystemIDResolver.java @@ -192,27 +192,27 @@ */ private static String replaceChars(String str) { - StringBuffer buf = new StringBuffer(str); - int length = buf.length(); + StringBuilder sb = new StringBuilder(str); + int length = sb.length(); for (int i = 0; i < length; i++) { - char currentChar = buf.charAt(i); + char currentChar = sb.charAt(i); // Replace space with "%20" if (currentChar == ' ') { - buf.setCharAt(i, '%'); - buf.insert(i+1, "20"); + sb.setCharAt(i, '%'); + sb.insert(i + 1, "20"); length = length + 2; i = i + 2; } // Replace backslash with forward slash else if (currentChar == '\\') { - buf.setCharAt(i, '/'); + sb.setCharAt(i, '/'); } } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java @@ -385,13 +385,13 @@ int line = locator.getLineNumber(); int column = locator.getColumnNumber(); pw.println("line: " + getSourceLine(url, line)); - StringBuffer buf = new StringBuffer("line: "); + StringBuilder sb = new StringBuilder("line: "); for (int i = 1; i < column; i++) { - buf.append(' '); + sb.append(' '); } - buf.append('^'); - pw.println(buf.toString()); + sb.append('^'); + pw.println(sb.toString()); } catch (Exception e) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/SystemIDResolver.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/SystemIDResolver.java --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/SystemIDResolver.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/SystemIDResolver.java @@ -185,27 +185,27 @@ */ private static String replaceChars(String str) { - StringBuffer buf = new StringBuffer(str); - int length = buf.length(); + StringBuilder sb = new StringBuilder(str); + int length = sb.length(); for (int i = 0; i < length; i++) { - char currentChar = buf.charAt(i); + char currentChar = sb.charAt(i); // Replace space with "%20" if (currentChar == ' ') { - buf.setCharAt(i, '%'); - buf.insert(i+1, "20"); + sb.setCharAt(i, '%'); + sb.insert(i + 1, "20"); length = length + 2; i = i + 2; } // Replace backslash with forward slash else if (currentChar == '\\') { - buf.setCharAt(i, '/'); + sb.setCharAt(i, '/'); } } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java --- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java @@ -1284,77 +1284,77 @@ public static String getAnalysisString(int analysis) { - StringBuffer buf = new StringBuffer(); - buf.append("count: ").append(getStepCount(analysis)).append(' '); + StringBuilder sb = new StringBuilder(); + sb.append("count: ").append(getStepCount(analysis)).append(' '); if((analysis & BIT_NODETEST_ANY) != 0) { - buf.append("NTANY|"); + sb.append("NTANY|"); } if((analysis & BIT_PREDICATE) != 0) { - buf.append("PRED|"); + sb.append("PRED|"); } if((analysis & BIT_ANCESTOR) != 0) { - buf.append("ANC|"); + sb.append("ANC|"); } if((analysis & BIT_ANCESTOR_OR_SELF) != 0) { - buf.append("ANCOS|"); + sb.append("ANCOS|"); } if((analysis & BIT_ATTRIBUTE) != 0) { - buf.append("ATTR|"); + sb.append("ATTR|"); } if((analysis & BIT_CHILD) != 0) { - buf.append("CH|"); + sb.append("CH|"); } if((analysis & BIT_DESCENDANT) != 0) { - buf.append("DESC|"); + sb.append("DESC|"); } if((analysis & BIT_DESCENDANT_OR_SELF) != 0) { - buf.append("DESCOS|"); + sb.append("DESCOS|"); } if((analysis & BIT_FOLLOWING) != 0) { - buf.append("FOL|"); + sb.append("FOL|"); } if((analysis & BIT_FOLLOWING_SIBLING) != 0) { - buf.append("FOLS|"); + sb.append("FOLS|"); } if((analysis & BIT_NAMESPACE) != 0) { - buf.append("NS|"); + sb.append("NS|"); } if((analysis & BIT_PARENT) != 0) { - buf.append("P|"); + sb.append("P|"); } if((analysis & BIT_PRECEDING) != 0) { - buf.append("PREC|"); + sb.append("PREC|"); } if((analysis & BIT_PRECEDING_SIBLING) != 0) { - buf.append("PRECS|"); + sb.append("PRECS|"); } if((analysis & BIT_SELF) != 0) { - buf.append(".|"); + sb.append(".|"); } if((analysis & BIT_FILTER) != 0) { - buf.append("FLT|"); + sb.append("FLT|"); } if((analysis & BIT_ROOT) != 0) { - buf.append("R|"); + sb.append("R|"); } - return buf.toString(); + return sb.toString(); } /** Set to true for diagnostics about walker creation */ diff --git a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncConcat.java b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncConcat.java --- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncConcat.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncConcat.java @@ -46,7 +46,7 @@ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); // Compiler says we must have at least two arguments. sb.append(m_arg0.execute(xctxt).str()); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncTranslate.java b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncTranslate.java --- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncTranslate.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncTranslate.java @@ -53,7 +53,7 @@ // A vector to contain the new characters. We'll use it to construct // the result string. - StringBuffer sbuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < theFirstStringLength; i++) { @@ -65,14 +65,14 @@ // Didn't find the character in the second string, so it // is not translated. - sbuffer.append(theCurrentChar); + sb.append(theCurrentChar); } else if (theIndex < theThirdStringLength) { // OK, there's a corresponding character in the // third string, so do the translation... - sbuffer.append(theThirdString.charAt(theIndex)); + sb.append(theThirdString.charAt(theIndex)); } else { @@ -85,6 +85,6 @@ } } - return new XString(sbuffer.toString()); + return new XString(sb.toString()); } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/patterns/StepPattern.java b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/patterns/StepPattern.java --- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/patterns/StepPattern.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/patterns/StepPattern.java @@ -789,89 +789,89 @@ public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (StepPattern pat = this; pat != null; pat = pat.m_relativePathPattern) { if (pat != this) - buf.append("/"); + sb.append('/'); - buf.append(Axis.getNames(pat.m_axis)); - buf.append("::"); + sb.append(Axis.getNames(pat.m_axis)); + sb.append("::"); if (0x000005000 == pat.m_whatToShow) { - buf.append("doc()"); + sb.append("doc()"); } else if (DTMFilter.SHOW_BYFUNCTION == pat.m_whatToShow) { - buf.append("function()"); + sb.append("function()"); } else if (DTMFilter.SHOW_ALL == pat.m_whatToShow) { - buf.append("node()"); + sb.append("node()"); } else if (DTMFilter.SHOW_TEXT == pat.m_whatToShow) { - buf.append("text()"); + sb.append("text()"); } else if (DTMFilter.SHOW_PROCESSING_INSTRUCTION == pat.m_whatToShow) { - buf.append("processing-instruction("); + sb.append("processing-instruction("); if (null != pat.m_name) { - buf.append(pat.m_name); + sb.append(pat.m_name); } - buf.append(")"); + sb.append(')'); } else if (DTMFilter.SHOW_COMMENT == pat.m_whatToShow) { - buf.append("comment()"); + sb.append("comment()"); } else if (null != pat.m_name) { if (DTMFilter.SHOW_ATTRIBUTE == pat.m_whatToShow) { - buf.append("@"); + sb.append("@"); } if (null != pat.m_namespace) { - buf.append("{"); - buf.append(pat.m_namespace); - buf.append("}"); + sb.append('{'); + sb.append(pat.m_namespace); + sb.append('}'); } - buf.append(pat.m_name); + sb.append(pat.m_name); } else if (DTMFilter.SHOW_ATTRIBUTE == pat.m_whatToShow) { - buf.append("@"); + sb.append("@"); } else if ((DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT) == pat.m_whatToShow) { - buf.append("doc-root()"); + sb.append("doc-root()"); } else { - buf.append('?').append(Integer.toHexString(pat.m_whatToShow)); + sb.append('?').append(Integer.toHexString(pat.m_whatToShow)); } if (null != pat.m_predicates) { for (int i = 0; i < pat.m_predicates.length; i++) { - buf.append("["); - buf.append(pat.m_predicates[i]); - buf.append("]"); + sb.append('['); + sb.append(pat.m_predicates[i]); + sb.append(']'); } } } - return buf.toString(); + return sb.toString(); } /** Set to true to send diagnostics about pattern matches to the consol. */ diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/Entity.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/Entity.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/Entity.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/Entity.java @@ -457,11 +457,11 @@ /** Returns a string representation of this object. */ public String toString() { - StringBuffer str = new StringBuffer(); - str.append("name=\""+name+'"'); - str.append(",ch="+ new String(ch)); - str.append(",position="+position); - str.append(",count="+count); + StringBuilder str = new StringBuilder(); + str.append("name=\"").append(name).append('"'); + str.append(",ch=").append(ch); + str.append(",position=").append(position); + str.append(",count=").append(count); return str.toString(); } // toString():String diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxErrorReporter.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxErrorReporter.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxErrorReporter.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxErrorReporter.java @@ -93,7 +93,7 @@ message = messageFormatter.formatMessage(fLocale, key, arguments); } else { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); str.append(domain); str.append('#'); str.append(key); diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java @@ -437,12 +437,12 @@ userDir = userDir.replace(separator, '/'); int len = userDir.length(), ch; - StringBuffer buffer = new StringBuffer(len*3); + StringBuilder sb = new StringBuilder(len*3); // change C:/blah to /C:/blah if (len >= 2 && userDir.charAt(1) == ':') { ch = Character.toUpperCase(userDir.charAt(0)); if (ch >= 'A' && ch <= 'Z') { - buffer.append('/'); + sb.append('/'); } } @@ -454,13 +454,13 @@ if (ch >= 128) break; if (gNeedEscaping[ch]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[ch]); - buffer.append(gAfterEscaping2[ch]); + sb.append('%'); + sb.append(gAfterEscaping1[ch]); + sb.append(gAfterEscaping2[ch]); // record the fact that it's escaped } else { - buffer.append((char)ch); + sb.append((char) ch); } } @@ -483,26 +483,26 @@ // for non-ascii character: make it positive, then escape if (b < 0) { ch = b + 256; - buffer.append('%'); - buffer.append(gHexChs[ch >> 4]); - buffer.append(gHexChs[ch & 0xf]); + sb.append('%'); + sb.append(gHexChs[ch >> 4]); + sb.append(gHexChs[ch & 0xf]); } else if (gNeedEscaping[b]) { - buffer.append('%'); - buffer.append(gAfterEscaping1[b]); - buffer.append(gAfterEscaping2[b]); + sb.append('%'); + sb.append(gAfterEscaping1[b]); + sb.append(gAfterEscaping2[b]); } else { - buffer.append((char)b); + sb.append((char) b); } } } // change blah/blah to blah/blah/ if (!userDir.endsWith("/")) - buffer.append('/'); + sb.append('/'); - gEscapedUserDir = buffer.toString(); + gEscapedUserDir = sb.toString(); return gEscapedUserDir; } diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEventReaderImpl.java @@ -143,9 +143,9 @@ } //create the string buffer and add initial data - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if(data != null && data.length() > 0 ) { - buffer.append(data); + sb.append(data); } //get the next event -- we should stop at END_ELEMENT but it can be any thing //things are worse when implementing this function in XMLEventReader because @@ -174,11 +174,11 @@ } //add the data to the buffer if(data != null && data.length() > 0 ) { - buffer.append(data); + sb.append(data); } event = nextEvent(); } - return buffer.toString(); + return sb.toString(); }//if (fPeekedEvent != null) //if there was no peeked, delegate everything to fXMLReader diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.java @@ -396,16 +396,16 @@ XMLSymbols.fENTITYSymbol; } case XMLSimpleType.TYPE_ENUMERATION: { - StringBuffer buffer = new StringBuffer(); - buffer.append('('); + StringBuilder sb = new StringBuilder(); + sb.append('('); for (int i = 0; i < attrDecl.simpleType.enumeration.length; i++) { if (i > 0) { - buffer.append("|"); + sb.append('|'); } - buffer.append(attrDecl.simpleType.enumeration[i]); + sb.append(attrDecl.simpleType.enumeration[i]); } - buffer.append(')'); - return fSymbolTable.addSymbol(buffer.toString()); + sb.append(')'); + return fSymbolTable.addSymbol(sb.toString()); } case XMLSimpleType.TYPE_ID: { return XMLSymbols.fIDSymbol; diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/events/LocationImpl.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/events/LocationImpl.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/events/LocationImpl.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/events/LocationImpl.java @@ -67,18 +67,18 @@ } public String toString(){ - StringBuffer sbuffer = new StringBuffer() ; - sbuffer.append("Line number = " + getLineNumber()); - sbuffer.append("\n") ; - sbuffer.append("Column number = " + getColumnNumber()); - sbuffer.append("\n") ; - sbuffer.append("System Id = " + getSystemId()); - sbuffer.append("\n") ; - sbuffer.append("Public Id = " + getPublicId()); - sbuffer.append("\n") ; - sbuffer.append("CharacterOffset = " + getCharacterOffset()); - sbuffer.append("\n") ; - return sbuffer.toString(); + StringBuilder sb = new StringBuilder() ; + sb.append("Line number = ").append(getLineNumber()); + sb.append('\n') ; + sb.append("Column number = ").append(getColumnNumber()); + sb.append('\n') ; + sb.append("System Id = ").append(getSystemId()); + sb.append('\n') ; + sb.append("Public Id = ").append(getPublicId()); + sb.append('\n') ; + sb.append("CharacterOffset = ").append(getCharacterOffset()); + sb.append('\n') ; + return sb.toString(); } } diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/events/StartElementEvent.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/events/StartElementEvent.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/events/StartElementEvent.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/events/StartElementEvent.java @@ -127,7 +127,7 @@ */ public String toString() { - StringBuffer startElement = new StringBuffer(); + StringBuilder startElement = new StringBuilder(); // open element startElement.append("<"); diff --git a/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java b/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java --- a/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java +++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java @@ -1623,7 +1623,7 @@ } if (tmpPrefix == null) { - StringBuffer genPrefix = new StringBuffer("zdef"); + StringBuilder genPrefix = new StringBuilder("zdef"); for (int i = 0; i < 1; i++) { genPrefix.append(fPrefixGen.nextInt()); @@ -1795,7 +1795,7 @@ } //No namespace mapping found , so declare prefix. - StringBuffer genPrefix = new StringBuffer("zdef"); + StringBuilder genPrefix = new StringBuilder("zdef"); for (int k = 0; k < 1; k++) { genPrefix.append(fPrefixGen.nextInt()); diff --git a/src/java.xml/share/classes/javax/xml/datatype/Duration.java b/src/java.xml/share/classes/javax/xml/datatype/Duration.java --- a/src/java.xml/share/classes/javax/xml/datatype/Duration.java +++ b/src/java.xml/share/classes/javax/xml/datatype/Duration.java @@ -892,45 +892,45 @@ */ public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (getSign() < 0) { - buf.append('-'); + sb.append('-'); } - buf.append('P'); + sb.append('P'); BigInteger years = (BigInteger) getField(DatatypeConstants.YEARS); if (years != null) { - buf.append(years + "Y"); + sb.append(years).append('Y'); } BigInteger months = (BigInteger) getField(DatatypeConstants.MONTHS); if (months != null) { - buf.append(months + "M"); + sb.append(months).append('M'); } BigInteger days = (BigInteger) getField(DatatypeConstants.DAYS); if (days != null) { - buf.append(days + "D"); + sb.append(days).append('D'); } BigInteger hours = (BigInteger) getField(DatatypeConstants.HOURS); BigInteger minutes = (BigInteger) getField(DatatypeConstants.MINUTES); BigDecimal seconds = (BigDecimal) getField(DatatypeConstants.SECONDS); if (hours != null || minutes != null || seconds != null) { - buf.append('T'); + sb.append('T'); if (hours != null) { - buf.append(hours + "H"); + sb.append(hours).append('H'); } if (minutes != null) { - buf.append(minutes + "M"); + sb.append(minutes).append('M'); } if (seconds != null) { - buf.append(toString(seconds) + "S"); + sb.append(toString(seconds)).append('S'); } } - return buf.toString(); + return sb.toString(); } /** diff --git a/src/java.xml/share/classes/javax/xml/transform/TransformerException.java b/src/java.xml/share/classes/javax/xml/transform/TransformerException.java --- a/src/java.xml/share/classes/javax/xml/transform/TransformerException.java +++ b/src/java.xml/share/classes/javax/xml/transform/TransformerException.java @@ -212,11 +212,11 @@ */ public String getMessageAndLocation() { - StringBuffer sbuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String message = super.getMessage(); if (null != message) { - sbuffer.append(message); + sb.append(message); } if (null != locator) { @@ -225,22 +225,22 @@ int column = locator.getColumnNumber(); if (null != systemID) { - sbuffer.append("; SystemID: "); - sbuffer.append(systemID); + sb.append("; SystemID: "); + sb.append(systemID); } if (0 != line) { - sbuffer.append("; Line#: "); - sbuffer.append(line); + sb.append("; Line#: "); + sb.append(line); } if (0 != column) { - sbuffer.append("; Column#: "); - sbuffer.append(column); + sb.append("; Column#: "); + sb.append(column); } } - return sbuffer.toString(); + return sb.toString(); } /** @@ -252,27 +252,27 @@ public String getLocationAsString() { if (null != locator) { - StringBuffer sbuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String systemID = locator.getSystemId(); int line = locator.getLineNumber(); int column = locator.getColumnNumber(); if (null != systemID) { - sbuffer.append("; SystemID: "); - sbuffer.append(systemID); + sb.append("; SystemID: "); + sb.append(systemID); } if (0 != line) { - sbuffer.append("; Line#: "); - sbuffer.append(line); + sb.append("; Line#: "); + sb.append(line); } if (0 != column) { - sbuffer.append("; Column#: "); - sbuffer.append(column); + sb.append("; Column#: "); + sb.append(column); } - return sbuffer.toString(); + return sb.toString(); } else { return null; }