StringBuffer -> StringBuilder

This commit is contained in:
Arjen Poutsma
2010-02-02 15:17:39 +00:00
parent 47432854e8
commit 6da1403564
11 changed files with 138 additions and 124 deletions

View File

@@ -1,9 +1,25 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.client.support.interceptor;
import org.xml.sax.SAXParseException;
import org.springframework.ws.client.WebServiceClientException;
import org.xml.sax.SAXParseException;
/**
* Exception thrown whenever a validation error occurs on the client-side.
*
@@ -17,8 +33,6 @@ public class WebServiceValidationException extends WebServiceClientException {
/**
* Create a new instance of the <code>WebServiceValidationException</code> class.
*
* @param msg the detail message
*/
public WebServiceValidationException(SAXParseException[] validationErrors) {
super(createMessage(validationErrors));
@@ -26,12 +40,12 @@ public class WebServiceValidationException extends WebServiceClientException {
}
private static String createMessage(SAXParseException[] validationErrors) {
StringBuffer buffer = new StringBuffer("XML validation error on response: ");
StringBuilder builder = new StringBuilder("XML validation error on response: ");
for (int i = 0; i < validationErrors.length; i++) {
buffer.append(validationErrors[i].getMessage());
for (SAXParseException validationError : validationErrors) {
builder.append(validationError.getMessage());
}
return buffer.toString();
return builder.toString();
}
/** Returns the validation errors. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,16 +26,16 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.springframework.util.Assert;
import org.springframework.ws.pox.PoxMessage;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
import org.springframework.xml.namespace.QNameUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* Implementation of the <code>PoxMessage</code> interface that is based on a DOM Document.
*
@@ -91,13 +91,13 @@ public class DomPoxMessage implements PoxMessage {
}
public String toString() {
StringBuffer buffer = new StringBuffer("DomPoxMessage ");
StringBuilder builder = new StringBuilder("DomPoxMessage ");
Element root = document.getDocumentElement();
if (root != null) {
buffer.append(' ');
buffer.append(QNameUtils.getQNameForNode(root));
builder.append(' ');
builder.append(QNameUtils.getQNameForNode(root));
}
return buffer.toString();
return builder.toString();
}
public void writeTo(OutputStream outputStream) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -131,7 +131,7 @@ public class RandomGuid {
/** Method to generate the random GUID. */
private void getRandomGuid(boolean secure) {
MessageDigest md5;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
StringBuilder sbValueBeforeMD5 = new StringBuilder();
try {
md5 = MessageDigest.getInstance("MD5");
@@ -166,15 +166,15 @@ public class RandomGuid {
md5.update(valueBeforeMD5.getBytes());
byte[] array = md5.digest();
StringBuffer sb = new StringBuffer();
for (int j = 0; j < array.length; ++j) {
int b = array[j] & 0xFF;
StringBuilder builder = new StringBuilder();
for (byte anArray : array) {
int b = anArray & 0xFF;
if (b < 0x10) {
sb.append('0');
builder.append('0');
}
sb.append(Integer.toHexString(b));
builder.append(Integer.toHexString(b));
}
guid = sb.toString();
guid = builder.toString();
}
/**
@@ -183,17 +183,17 @@ public class RandomGuid {
*/
public String toString() {
String raw = guid.toUpperCase();
StringBuffer sb = new StringBuffer();
sb.append(raw.substring(0, 8));
sb.append("-");
sb.append(raw.substring(8, 12));
sb.append("-");
sb.append(raw.substring(12, 16));
sb.append("-");
sb.append(raw.substring(16, 20));
sb.append("-");
sb.append(raw.substring(20));
return sb.toString();
StringBuilder builder = new StringBuilder();
builder.append(raw.substring(0, 8));
builder.append("-");
builder.append(raw.substring(8, 12));
builder.append("-");
builder.append(raw.substring(12, 16));
builder.append("-");
builder.append(raw.substring(16, 20));
builder.append("-");
builder.append(raw.substring(20));
return builder.toString();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,17 @@ import java.util.Iterator;
import javax.activation.DataHandler;
import javax.xml.stream.XMLStreamException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.mime.Attachment;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
@@ -36,17 +47,6 @@ import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.mime.Attachment;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
/**
* AXIOM-specific implementation of the {@link SoapMessage} interface. Created via the {@link AxiomSoapMessageFactory},
* wraps a {@link SOAPMessage}.
@@ -299,7 +299,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
}
public String toString() {
StringBuffer buffer = new StringBuffer("AxiomSoapMessage");
StringBuilder builder = new StringBuilder("AxiomSoapMessage");
if (payloadCaching) {
try {
SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope();
@@ -308,8 +308,8 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
if (body != null) {
OMElement bodyElement = body.getFirstElement();
if (bodyElement != null) {
buffer.append(' ');
buffer.append(bodyElement.getQName());
builder.append(' ');
builder.append(bodyElement.getQName());
}
}
}
@@ -318,7 +318,7 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
// ignore
}
}
return buffer.toString();
return builder.toString();
}
private class AxiomAttachmentIterator implements Iterator {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,20 +25,6 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -53,6 +39,20 @@ import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportInputStream;
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Axiom-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}
* interface. Creates {@link org.springframework.ws.soap.axiom.AxiomSoapMessage AxiomSoapMessages}.
@@ -325,14 +325,14 @@ public class AxiomSoapMessageFactory implements SoapMessageFactory, Initializing
}
public String toString() {
StringBuffer buffer = new StringBuffer("AxiomSoapMessageFactory[");
StringBuilder builder = new StringBuilder("AxiomSoapMessageFactory[");
if (soapFactory instanceof SOAP11Factory) {
buffer.append("SOAP 1.1");
builder.append("SOAP 1.1");
}
else if (soapFactory instanceof SOAP12Factory) {
buffer.append("SOAP 1.2");
builder.append("SOAP 1.2");
}
buffer.append(']');
return buffer.toString();
builder.append(']');
return builder.toString();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -199,12 +199,12 @@ public class SaajSoapMessage extends AbstractSoapMessage {
String[] oldContentTypes = mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE);
String oldContentType =
!ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] : getVersion().getContentType();
StringBuffer buffer = new StringBuffer(CONTENT_TYPE_XOP);
buffer.append(";type=");
buffer.append('"');
buffer.append(oldContentType);
buffer.append('"');
mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, buffer.toString());
StringBuilder builder = new StringBuilder(CONTENT_TYPE_XOP);
builder.append(";type=");
builder.append('"');
builder.append(oldContentType);
builder.append('"');
mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, builder.toString());
}
private void convertPartToXop() {
@@ -212,12 +212,12 @@ public class SaajSoapMessage extends AbstractSoapMessage {
String[] oldContentTypes = saajPart.getMimeHeader(TransportConstants.HEADER_CONTENT_TYPE);
String oldContentType =
!ObjectUtils.isEmpty(oldContentTypes) ? oldContentTypes[0] : getVersion().getContentType();
StringBuffer buffer = new StringBuffer(CONTENT_TYPE_XOP);
buffer.append(";type=");
buffer.append('"');
buffer.append(oldContentType);
buffer.append('"');
saajPart.setMimeHeader(TransportConstants.HEADER_CONTENT_TYPE, buffer.toString());
StringBuilder builder = new StringBuilder(CONTENT_TYPE_XOP);
builder.append(";type=");
builder.append('"');
builder.append(oldContentType);
builder.append('"');
saajPart.setMimeHeader(TransportConstants.HEADER_CONTENT_TYPE, builder.toString());
}
public Iterator getAttachments() throws AttachmentException {
@@ -265,7 +265,7 @@ public class SaajSoapMessage extends AbstractSoapMessage {
}
public String toString() {
StringBuffer buffer = new StringBuffer("SaajSoapMessage");
StringBuilder builder = new StringBuilder("SaajSoapMessage");
try {
SOAPEnvelope envelope = getImplementation().getEnvelope(saajMessage);
if (envelope != null) {
@@ -273,8 +273,8 @@ public class SaajSoapMessage extends AbstractSoapMessage {
if (body != null) {
SOAPElement bodyElement = getImplementation().getFirstBodyElement(body);
if (bodyElement != null) {
buffer.append(' ');
buffer.append(getImplementation().getName(bodyElement));
builder.append(' ');
builder.append(getImplementation().getName(bodyElement));
}
}
}
@@ -282,7 +282,7 @@ public class SaajSoapMessage extends AbstractSoapMessage {
catch (SOAPException ex) {
// ignore
}
return buffer.toString();
return builder.toString();
}
private static class SaajAttachmentIterator implements Iterator {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,9 +27,6 @@ import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.StringUtils;
import org.springframework.ws.WebServiceMessage;
@@ -40,6 +37,9 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportInputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* SAAJ-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}.
* Wraps a SAAJ {@link MessageFactory}. This factory will use SAAJ 1.3 when found, or fall back to SAAJ 1.2 or even
@@ -224,13 +224,13 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
}
public String toString() {
StringBuffer buffer = new StringBuffer("SaajSoapMessageFactory[");
buffer.append(SaajUtils.getSaajVersionString());
StringBuilder builder = new StringBuilder("SaajSoapMessageFactory[");
builder.append(SaajUtils.getSaajVersionString());
if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) {
buffer.append(',');
buffer.append(messageFactoryProtocol);
builder.append(',');
builder.append(messageFactoryProtocol);
}
buffer.append(']');
return buffer.toString();
builder.append(']');
return builder.toString();
}
}

View File

@@ -45,15 +45,15 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect
}
public final String getErrorMessage() throws IOException {
StringBuffer buffer = new StringBuffer();
StringBuilder builder = new StringBuilder();
String responseMessage = getResponseMessage();
if (StringUtils.hasLength(responseMessage)) {
buffer.append(responseMessage);
builder.append(responseMessage);
}
buffer.append(" [");
buffer.append(getResponseCode());
buffer.append(']');
return buffer.toString();
builder.append(" [");
builder.append(getResponseCode());
builder.append(']');
return builder.toString();
}
/*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +27,6 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerAdapter;
@@ -41,6 +36,11 @@ import org.springframework.xml.transform.TransformerObjectSupport;
import org.springframework.xml.xpath.XPathExpression;
import org.springframework.xml.xpath.XPathExpressionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
/**
* Adapter to use the <code>WsdlDefinition</code> interface with the generic <code>DispatcherServlet</code>.
* <p/>
@@ -161,7 +161,7 @@ public class WsdlDefinitionHandlerAdapter extends TransformerObjectSupport imple
* This method is only called when the <code>transformLocations</code> property is true.
*/
protected String transformLocation(String location, HttpServletRequest request) {
StringBuffer url = new StringBuffer(request.getScheme());
StringBuilder url = new StringBuilder(request.getScheme());
url.append("://").append(request.getServerName()).append(':').append(request.getServerPort());
if (location.startsWith("/")) {
// a relative path, prepend the context path

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +23,12 @@ import javax.wsdl.xml.WSDLWriter;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.wsdl.WsdlDefinitionException;
import org.w3c.dom.Document;
/**
* Implementation of the <code>Wsdl11Definition</code> based on WSDL4J. A {@link javax.wsdl.Definition} can be given as
* as constructor argument, or set using a property.
@@ -98,12 +98,12 @@ public class Wsdl4jDefinition implements Wsdl11Definition {
}
public String toString() {
StringBuffer buffer = new StringBuffer("Wsdl4jDefinition");
StringBuilder builder = new StringBuilder("Wsdl4jDefinition");
if (definition != null && StringUtils.hasLength(definition.getTargetNamespace())) {
buffer.append('{');
buffer.append(definition.getTargetNamespace());
buffer.append('}');
builder.append('{');
builder.append(definition.getTargetNamespace());
builder.append('}');
}
return buffer.toString();
return builder.toString();
}
}

View File

@@ -139,12 +139,12 @@ public class MockWebServiceMessage implements FaultAwareWebServiceMessage {
}
public String toString() {
StringBuffer buffer = new StringBuffer("MockWebServiceMessage {");
StringBuilder builder = new StringBuilder("MockWebServiceMessage {");
if (content != null) {
buffer.append(content);
builder.append(content);
}
buffer.append('}');
return buffer.toString();
builder.append('}');
return builder.toString();
}
private class StringBufferWriter extends Writer {