Replace StringBuffe with StringBuilder

Issues: SWF-1532
This commit is contained in:
Phillip Webb
2012-04-05 10:48:49 -07:00
parent 3f1c40188c
commit 58936414e4
16 changed files with 30 additions and 30 deletions

View File

@@ -41,11 +41,11 @@ public class CompositeStringExpression implements Expression {
}
public Object getValue(Object context) throws EvaluationException {
StringBuffer buffer = new StringBuffer(128);
StringBuilder value = new StringBuilder(128);
for (Expression expression : expressions) {
buffer.append(expression.getValue(context));
value.append(expression.getValue(context));
}
return buffer.toString();
return value.toString();
}
public void setValue(Object context, Object value) throws EvaluationException {

View File

@@ -199,7 +199,7 @@ public class MethodKey implements Serializable {
* Convenience method that returns the parameter types describing the signature of the method as a string.
*/
private String parameterTypesString() {
StringBuffer parameterTypesString = new StringBuffer();
StringBuilder parameterTypesString = new StringBuilder();
for (int i = 0; i < parameterTypes.length; i++) {
if (parameterTypes[i] == null) {
parameterTypesString.append("<any>");

View File

@@ -51,7 +51,7 @@ public class StaticConversionExecutorImplTests extends TestCase {
public void testIllegalType() {
try {
conversionExecutor.execute(new StringBuffer());
conversionExecutor.execute(new StringBuilder());
fail();
} catch (ConversionExecutionException e) {
// expected

View File

@@ -51,7 +51,7 @@ public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer
processIds = component.getClientId(context);
}
String childId = getElementId(context, component);
StringBuffer script = new StringBuffer();
StringBuilder script = new StringBuilder();
script.append("dojo.addOnLoad(function(){");
script.append("Spring.addDecoration(new Spring.AjaxEventDecoration({");
script.append("event:'" + event + "'");

View File

@@ -69,7 +69,7 @@ public class DojoElementDecorationRenderer extends BaseSpringJavascriptDecoratio
ResourceHelper.beginScriptBlock(context);
StringBuffer script = new StringBuffer();
StringBuilder script = new StringBuilder();
script.append(" dojo.addOnLoad(function(){dojo.query(" + selector + ").forEach(function(element){");
script.append(" Spring.addDecoration(new Spring.ElementDecoration({ ");
script.append(" elementId : element, ");

View File

@@ -8,7 +8,7 @@ public class DojoWidgetRenderer extends DojoElementDecorationRenderer {
protected String getDojoAttributesAsString(FacesContext context, UIComponent component) {
DojoWidget advisor = (DojoWidget) component;
StringBuffer attrs = new StringBuffer();
StringBuilder attrs = new StringBuilder();
for (int i = 0; i < advisor.getDojoAttributes().length; i++) {

View File

@@ -65,7 +65,7 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute,
Object attributeValue, String property) throws IOException {
StringBuffer onclick = new StringBuffer();
StringBuilder onclick = new StringBuilder();
if (attributeValue != null) {
String originalOnclick = attributeValue.toString().trim();
if (!originalOnclick.endsWith(";")) {
@@ -135,7 +135,7 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer
}
protected String encodeParamsAsObject(FacesContext context, UIComponent component) {
StringBuffer paramObj = new StringBuffer();
StringBuilder paramObj = new StringBuilder();
for (int i = 0; i < component.getChildCount(); i++) {
if (component.getChildren().get(i) instanceof UIParameter) {
UIParameter param = (UIParameter) component.getChildren().get(i);

View File

@@ -160,7 +160,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
} else {
super.encodeEnd(context, component);
StringBuffer decorationParams = new StringBuffer();
StringBuilder decorationParams = new StringBuilder();
decorationParams.append("{");
decorationParams.append("elementId : '" + component.getClientId(context) + "'");
@@ -183,7 +183,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
}
decorationParams.append("}");
StringBuffer advisorScript = new StringBuffer();
StringBuilder advisorScript = new StringBuilder();
advisorScript.append("Spring.addDecoration(new Spring.CommandLinkDecoration(" + decorationParams.toString()
+ "));");
ResourceHelper.beginScriptBlock(context);
@@ -220,7 +220,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
return "";
} else {
String params = encodeParamsAsArray(context, component);
StringBuffer onclick = new StringBuffer();
StringBuilder onclick = new StringBuilder();
onclick.append("this.submitFormFromLink('" + RendererUtils.getFormId(context, component) + "','"
+ component.getClientId(context) + "', " + params + "); return false;");
return onclick.toString();
@@ -228,7 +228,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
}
protected String encodeParamsAsArray(FacesContext context, UIComponent component) {
StringBuffer paramArray = new StringBuffer();
StringBuilder paramArray = new StringBuilder();
paramArray.append("[");
for (int i = 0; i < component.getChildCount(); i++) {
if (component.getChildren().get(i) instanceof UIParameter) {

View File

@@ -50,7 +50,7 @@ public class ValidateAllRenderer extends BaseSpringJavascriptDecorationRenderer
ResourceHelper.beginScriptBlock(context);
StringBuffer script = new StringBuffer();
StringBuilder script = new StringBuilder();
script.append("Spring.addDecoration(new Spring.ValidateAllDecoration({" + "event : 'onclick', "
+ "elementId : '" + advisedChild.getClientId(context) + "'}));");
writer.writeText(script, null);

View File

@@ -160,7 +160,7 @@ public class ResourceHelper {
public static void endCombineStyles(FacesContext facesContext) throws IOException {
List<String> combinedResources = getCombinedResources(facesContext);
StringBuffer combinedPath = new StringBuffer();
StringBuilder combinedPath = new StringBuilder();
for (int i = 0; i < combinedResources.size(); i++) {
String resourcePath = combinedResources.get(i);
if (i == 1) {

View File

@@ -103,7 +103,7 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler {
}
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
StringBuilder url = new StringBuilder();
url.append(request.getRequestURI());
url.append('?');
appendQueryParameter(url, FLOW_EXECUTION_KEY_PARAMETER, flowExecutionKey, getEncodingScheme(request));
@@ -128,7 +128,7 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler {
* </pre>
*/
public String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
StringBuilder url = new StringBuilder();
if (request.getPathInfo() != null) {
url.append(request.getContextPath());
url.append(request.getServletPath());
@@ -168,7 +168,7 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler {
}
}
protected <T> void appendQueryParameters(StringBuffer url, Map<String, T> parameters, String encodingScheme) {
protected <T> void appendQueryParameters(StringBuilder url, Map<String, T> parameters, String encodingScheme) {
Iterator<Map.Entry<String, T>> entries = parameters.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<?, ?> entry = entries.next();
@@ -181,7 +181,7 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler {
// internal helpers
private void appendQueryParameter(StringBuffer url, Object key, Object value, String encodingScheme) {
private void appendQueryParameter(StringBuilder url, Object key, Object value, String encodingScheme) {
String encodedKey = encode(key, encodingScheme);
String encodedValue = encode(value, encodingScheme);
url.append(encodedKey).append('=').append(encodedValue);

View File

@@ -89,7 +89,7 @@ public class FilenameFlowUrlHandler extends DefaultFlowUrlHandler {
* </pre>
*/
public String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
StringBuilder url = new StringBuilder();
String pathInfo = request.getPathInfo();
if (pathInfo != null) {
url.append(request.getContextPath());

View File

@@ -44,7 +44,7 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
}
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
StringBuilder url = new StringBuilder();
url.append(request.getRequestURI());
url.append('?');
appendQueryParameter(url, "_flowId", flowId);
@@ -54,7 +54,7 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
}
public String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
StringBuilder url = new StringBuilder();
url.append(request.getRequestURI());
url.append('?');
appendQueryParameter(url, "_flowId", flowId);
@@ -65,7 +65,7 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
return url.toString();
}
private <T> void appendQueryParameters(StringBuffer url, Map<String, T> parameters) {
private <T> void appendQueryParameters(StringBuilder url, Map<String, T> parameters) {
Iterator<Map.Entry<String, T>> entries = parameters.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, T> entry = entries.next();
@@ -76,7 +76,7 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
}
}
private void appendQueryParameter(StringBuffer url, Object key, Object value) {
private void appendQueryParameter(StringBuilder url, Object key, Object value) {
String encodedKey = encode(key);
String encodedValue = encode(value);
url.append(encodedKey).append('=').append(encodedValue);

View File

@@ -81,7 +81,7 @@ public class CompositeFlowExecutionKey extends FlowExecutionKey {
}
public String toString() {
return new StringBuffer().append(EXECUTION_ID_PREFIX).append(executionId).append(SNAPSHOT_ID_PREFIX)
return new StringBuilder().append(EXECUTION_ID_PREFIX).append(executionId).append(SNAPSHOT_ID_PREFIX)
.append(snapshotId).toString();
}
@@ -112,4 +112,4 @@ public class CompositeFlowExecutionKey extends FlowExecutionKey {
String snapshotId = encodedKey.substring(snapshotStart + SNAPSHOT_ID_PREFIX.length());
return new String[] { executionId, snapshotId };
}
}
}

View File

@@ -432,7 +432,7 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd
private void sendContextRelativeRedirect(String location, HttpServletRequest request, HttpServletResponse response)
throws IOException {
StringBuffer url = new StringBuffer(request.getContextPath());
StringBuilder url = new StringBuilder(request.getContextPath());
if (!location.startsWith("/")) {
url.append('/');
}
@@ -442,7 +442,7 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd
private void sendServletRelativeRedirect(String location, HttpServletRequest request, HttpServletResponse response)
throws IOException {
StringBuffer url = new StringBuffer(request.getContextPath());
StringBuilder url = new StringBuilder(request.getContextPath());
url.append(request.getServletPath());
if (!location.startsWith("/")) {
url.append('/');

View File

@@ -52,7 +52,7 @@ public class SecurityRule {
* @return comma separated String
*/
public static String securityAttributesToCommaDelimitedList(Collection<?> attributes) {
StringBuffer attrs = new StringBuffer();
StringBuilder attrs = new StringBuilder();
Iterator<?> attributeIt = attributes.iterator();
while (attributeIt.hasNext()) {
if (attrs.length() != 0) {