mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 18:33:41 +00:00
8274525: Replace uses of StringBuffer with StringBuilder in java.xml
Reviewed-by: joehw, iris, naoto, dfuchs
This commit is contained in:
parent
4e7d7caa0c
commit
754bc82c4c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -461,13 +461,10 @@ public abstract class Entity {
|
||||
|
||||
/** 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);
|
||||
return str.toString();
|
||||
return "name=\"" + name + '"' +
|
||||
",ch=" + new String(ch) +
|
||||
",position=" + position +
|
||||
",count=" + count;
|
||||
|
||||
} // toString():String
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,7 +93,7 @@ public class StaxErrorReporter extends XMLErrorReporter {
|
||||
message = messageFormatter.formatMessage(fLocale, key, arguments);
|
||||
}
|
||||
else {
|
||||
StringBuffer str = new StringBuffer();
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(domain);
|
||||
str.append('#');
|
||||
str.append(key);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -142,8 +142,8 @@ public class XMLEventReaderImpl implements javax.xml.stream.XMLEventReader{
|
||||
return "";
|
||||
}
|
||||
|
||||
//create the string buffer and add initial data
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
//create the string builder and add initial data
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
if(data != null && data.length() > 0 ) {
|
||||
buffer.append(data);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -67,18 +67,11 @@ public class LocationImpl implements Location{
|
||||
}
|
||||
|
||||
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();
|
||||
return "Line number = " + getLineNumber() + "\n" +
|
||||
"Column number = " + getColumnNumber() + "\n" +
|
||||
"System Id = " + getSystemId() + "\n" +
|
||||
"Public Id = " + getPublicId() + "\n" +
|
||||
"CharacterOffset = " + getCharacterOffset() + "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -885,8 +885,7 @@ public abstract class Duration {
|
||||
* @return A non-{@code null} valid {@code String} representation of this {@code Duration}.
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
if (getSign() < 0) {
|
||||
buf.append('-');
|
||||
@ -946,15 +945,15 @@ public abstract class Duration {
|
||||
}
|
||||
|
||||
/* Insert decimal point */
|
||||
StringBuffer buf;
|
||||
StringBuilder buf;
|
||||
int insertionPoint = intString.length() - scale;
|
||||
if (insertionPoint == 0) { /* Point goes right before intVal */
|
||||
return "0." + intString;
|
||||
} else if (insertionPoint > 0) { /* Point goes inside intVal */
|
||||
buf = new StringBuffer(intString);
|
||||
buf = new StringBuilder(intString);
|
||||
buf.insert(insertionPoint, '.');
|
||||
} else { /* We must insert zeros between point and intVal */
|
||||
buf = new StringBuffer(3 - insertionPoint + intString.length());
|
||||
buf = new StringBuilder(3 - insertionPoint + intString.length());
|
||||
buf.append("0.");
|
||||
for (int i = 0; i < -insertionPoint; i++) {
|
||||
buf.append('0');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user