Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace StringBuffer with StringBuilder

  • Loading branch information...
commit 555d6a73a24663065180c86d985928cd0924f3d2 1 parent 6e8f581
@rolfl rolfl authored
Showing with 40 additions and 40 deletions.
  1. +1 −1  contrib/src/java/org/jdom2/contrib/beans/TestIndexed.java
  2. +1 −1  contrib/src/java/org/jdom2/contrib/input/scanner/ElementScanner.java
  3. +1 −1  contrib/src/java/org/jdom2/contrib/input/scanner/XPathMatcher.java
  4. +1 −1  contrib/src/java/org/jdom2/contrib/schema/ValidationError.java
  5. +1 −1  core/src/java/org/jdom2/CDATA.java
  6. +1 −1  core/src/java/org/jdom2/Comment.java
  7. +1 −1  core/src/java/org/jdom2/DataConversionException.java
  8. +1 −1  core/src/java/org/jdom2/DocType.java
  9. +1 −1  core/src/java/org/jdom2/Document.java
  10. +3 −3 core/src/java/org/jdom2/Element.java
  11. +1 −1  core/src/java/org/jdom2/EntityRef.java
  12. +12 −12 core/src/java/org/jdom2/IllegalAddException.java
  13. +2 −2 core/src/java/org/jdom2/IllegalDataException.java
  14. +2 −2 core/src/java/org/jdom2/IllegalNameException.java
  15. +1 −1  core/src/java/org/jdom2/IllegalTargetException.java
  16. +1 −1  core/src/java/org/jdom2/Text.java
  17. +1 −1  core/src/java/org/jdom2/filter/AndFilter.java
  18. +1 −1  core/src/java/org/jdom2/filter/NegateFilter.java
  19. +1 −1  core/src/java/org/jdom2/filter/OrFilter.java
  20. +3 −3 core/src/java/org/jdom2/input/sax/TextBuffer.java
  21. +1 −1  test/src/java/org/jdom2/test/cases/TestAttribute.java
  22. +1 −1  test/src/java/org/jdom2/test/cases/TestCDATA.java
  23. +1 −1  test/src/java/org/jdom2/test/cases/TestComment.java
View
2  contrib/src/java/org/jdom2/contrib/beans/TestIndexed.java
@@ -112,7 +112,7 @@ public void setMeasurements(int[] measurements) {
@Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("TestIndexed[name='" + name + "'");
for (int i = 0; i < toppings.size(); ++i) {
buf.append(", topping=" + toppings.get(i));
View
2  contrib/src/java/org/jdom2/contrib/input/scanner/ElementScanner.java
@@ -188,7 +188,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
/**
* The path of the being parsed element.
*/
- private StringBuffer currentPath = new StringBuffer();
+ private StringBuilder currentPath = new StringBuilder();
/**
* The matching rules active for the current path. It includes
View
2  contrib/src/java/org/jdom2/contrib/input/scanner/XPathMatcher.java
@@ -230,7 +230,7 @@ protected static String getPathPatternAsRE(String expr)
expr.substring(0, expr.lastIndexOf('[')): expr;
int length = path.length();
- StringBuffer re = new StringBuffer(2 * length);
+ StringBuilder re = new StringBuilder(2 * length);
char previous = (char)0;
for (int i=0; i<length; i++) {
View
2  contrib/src/java/org/jdom2/contrib/schema/ValidationError.java
@@ -143,7 +143,7 @@ public Object getNode() {
*/
@Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append('[');
if (this.severity == WARNING) {
View
2  core/src/java/org/jdom2/CDATA.java
@@ -202,7 +202,7 @@ public void append(final Text text) {
*/
@Override
public String toString() {
- return new StringBuffer(64)
+ return new StringBuilder(64)
.append("[CDATA: ")
.append(getText())
.append("]")
View
2  core/src/java/org/jdom2/Comment.java
@@ -155,7 +155,7 @@ protected Comment setParent(Parent parent) {
*/
@Override
public String toString() {
- return new StringBuffer()
+ return new StringBuilder()
.append("[Comment: ")
.append(new org.jdom2.output.XMLOutputter().outputString(this))
.append("]")
View
2  core/src/java/org/jdom2/DataConversionException.java
@@ -76,7 +76,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param dataType type the conversion was attempting to create
*/
public DataConversionException(String name, String dataType) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The XML construct ")
.append(name)
.append(" could not be converted to a ")
View
2  core/src/java/org/jdom2/DocType.java
@@ -287,7 +287,7 @@ public String getInternalSubset() {
*/
@Override
public String toString() {
- return new StringBuffer()
+ return new StringBuilder()
.append("[DocType: ")
.append(new org.jdom2.output.XMLOutputter().outputString(this))
.append("]")
View
2  core/src/java/org/jdom2/Document.java
@@ -621,7 +621,7 @@ public Document setContent(Content child) {
*/
@Override
public String toString() {
- StringBuffer stringForm = new StringBuffer()
+ StringBuilder stringForm = new StringBuilder()
.append("[Document: ");
DocType docType = getDocType();
View
6 core/src/java/org/jdom2/Element.java
@@ -449,7 +449,7 @@ public void removeNamespaceDeclaration(final Namespace additionalNamespace) {
*/
@Override
public String getValue() {
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
for (Content child : getContent()) {
if (child instanceof Element || child instanceof Text) {
@@ -521,7 +521,7 @@ public String getText() {
}
// Else build String up
- final StringBuffer textContent = new StringBuffer();
+ final StringBuilder textContent = new StringBuilder();
boolean hasText = false;
for (int i = 0; i < content.size(); i++) {
@@ -1344,7 +1344,7 @@ public boolean removeAttribute(final Attribute attribute) {
*/
@Override
public String toString() {
- final StringBuffer stringForm = new StringBuffer(64)
+ final StringBuilder stringForm = new StringBuilder(64)
.append("[Element: <")
.append(getQualifiedName());
View
2  core/src/java/org/jdom2/EntityRef.java
@@ -232,7 +232,7 @@ public EntityRef setSystemID(String systemID) {
*/
@Override
public String toString() {
- return new StringBuffer()
+ return new StringBuilder()
.append("[EntityRef: ")
.append("&")
.append(name)
View
24 core/src/java/org/jdom2/IllegalAddException.java
@@ -78,7 +78,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, Attribute added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The attribute \"")
.append(added.getQualifiedName())
.append("\" could not be added to the element \"")
@@ -99,7 +99,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, Element added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The element \"")
.append(added.getQualifiedName())
.append("\" could not be added as a child of \"")
@@ -118,7 +118,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The element \"")
.append(added.getQualifiedName())
.append("\" could not be added as the root of the document: ")
@@ -138,7 +138,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
IllegalAddException(Element base, ProcessingInstruction added,
String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The PI \"")
.append(added.getTarget())
.append("\" could not be added as content to \"")
@@ -158,7 +158,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
IllegalAddException(ProcessingInstruction added,
String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The PI \"")
.append(added.getTarget())
.append("\" could not be added to the top level of the document: ")
@@ -177,7 +177,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, Comment added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The comment \"")
.append(added.getText())
.append("\" could not be added as content to \"")
@@ -198,7 +198,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, CDATA added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The CDATA \"")
.append(added.getText())
.append("\" could not be added as content to \"")
@@ -220,7 +220,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, Text added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The Text \"")
.append(added.getText())
.append("\" could not be added as content to \"")
@@ -239,7 +239,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Comment added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The comment \"")
.append(added.getText())
.append("\" could not be added to the top level of the document: ")
@@ -258,7 +258,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, EntityRef added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The entity reference\"")
.append(added.getName())
.append("\" could not be added as content to \"")
@@ -279,7 +279,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(Element base, Namespace added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The namespace xmlns")
.append(added.getPrefix().equals("") ? "="
: ":" + added.getPrefix() + "=")
@@ -301,7 +301,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason cause of the problem
*/
IllegalAddException(DocType added, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The DOCTYPE ")
.append(added.toString())
.append(" could not be added to the document: ")
View
4 core/src/java/org/jdom2/IllegalDataException.java
@@ -77,7 +77,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason <code>String</code> message or reason data is illegal.
*/
IllegalDataException(String data, String construct, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The data \"")
.append(data)
.append("\" is not legal for a JDOM ")
@@ -97,7 +97,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param construct <code>String</code> construct that data is illegal for.
*/
IllegalDataException(String data, String construct) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The data \"")
.append(data)
.append("\" is not legal for a JDOM ")
View
4 core/src/java/org/jdom2/IllegalNameException.java
@@ -79,7 +79,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason <code>String</code> message or reason name is illegal.
*/
IllegalNameException(String name, String construct, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The name \"")
.append(name)
.append("\" is not legal for JDOM/XML ")
@@ -100,7 +100,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* that <code>name</code> was supplied to.
*/
IllegalNameException(String name, String construct) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The name \"")
.append(name)
.append("\" is not legal for JDOM/XML ")
View
2  core/src/java/org/jdom2/IllegalTargetException.java
@@ -76,7 +76,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* @param reason <code>String</code> message or reason target is illegal.
*/
IllegalTargetException(String target, String reason) {
- super(new StringBuffer()
+ super(new StringBuilder()
.append("The target \"")
.append(target)
.append("\" is not legal for JDOM/XML Processing Instructions: ")
View
2  core/src/java/org/jdom2/Text.java
@@ -245,7 +245,7 @@ public String getValue() {
*/
@Override
public String toString() {
- return new StringBuffer(64)
+ return new StringBuilder(64)
.append("[Text: ")
.append(getText())
.append("]")
View
2  core/src/java/org/jdom2/filter/AndFilter.java
@@ -122,7 +122,7 @@ public int hashCode() {
@Override
public String toString() {
- return new StringBuffer(64)
+ return new StringBuilder(64)
.append("[AndFilter: ")
.append(left.toString())
.append(",\n")
View
2  core/src/java/org/jdom2/filter/NegateFilter.java
@@ -111,7 +111,7 @@ public int hashCode() {
@Override
public String toString() {
- return new StringBuffer(64)
+ return new StringBuilder(64)
.append("[NegateFilter: ")
.append(filter.toString())
.append("]")
View
2  core/src/java/org/jdom2/filter/OrFilter.java
@@ -121,7 +121,7 @@ public int hashCode() {
@Override
public String toString() {
- return new StringBuffer(64)
+ return new StringBuilder(64)
.append("[OrFilter: ")
.append(left.toString())
.append(",\n")
View
6 core/src/java/org/jdom2/input/sax/TextBuffer.java
@@ -58,15 +58,15 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.util.ArrayCopy;
/**
- * A non-public utility class similar to StringBuffer but optimized for XML
+ * A non-public utility class similar to StringBuilder but optimized for XML
* parsing where the common case is that you get only one chunk of characters
* per text section. TextBuffer stores the first chunk of characters in a
* String, which can just be returned directly if no second chunk is received.
- * Subsequent chunks are stored in a supplemental char array (like StringBuffer
+ * Subsequent chunks are stored in a supplemental char array (like StringBuilder
* uses). In this case, the returned text will be the first String chunk,
* concatenated with the subsequent chunks stored in the char array. This
* provides optimal performance in the common case, while still providing very
- * good performance in the uncommon case. Furthermore, avoiding StringBuffer
+ * good performance in the uncommon case. Furthermore, avoiding StringBuilder
* means that no extra unused char array space will be kept around after parsing
* is through.
*
View
2  test/src/java/org/jdom2/test/cases/TestAttribute.java
@@ -656,7 +656,7 @@ public void test_TCM__OrgJdomAttribute_setValue_String() {
try {
final char c= 0x11;
- final StringBuffer buffer = new StringBuffer("hhhh");
+ final StringBuilder buffer = new StringBuilder("hhhh");
buffer.setCharAt(2, c);
attribute.setValue(buffer.toString());
fail("Attribute setValue didn't catch invalid comment string");
View
2  test/src/java/org/jdom2/test/cases/TestCDATA.java
@@ -209,7 +209,7 @@ public void test_TCM__orgJdomText_setText_String() {
cdata.setText(otherString);
try {
final char c= 0x11;
- final StringBuffer buffer = new StringBuffer("hhhh");
+ final StringBuilder buffer = new StringBuilder("hhhh");
buffer.setCharAt(2, c);
cdata.setText(buffer.toString());
View
2  test/src/java/org/jdom2/test/cases/TestComment.java
@@ -186,7 +186,7 @@ public void test_TCM__OrgJdomComment_setText_String() {
}
try {
char c= 0x11;
- StringBuffer b= new StringBuffer("hhhh");
+ StringBuilder b= new StringBuilder("hhhh");
b.setCharAt(2, c);
theComment.setText(b.toString());
fail("Comment setText didn't catch invalid comment string");
Please sign in to comment.
Something went wrong with that request. Please try again.