Commit cf69f53f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Replaced StringBuffer with StringBuilder. JM-202


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1113 b35dd754-fafc-0310-a699-88a17e54d16e
parent 0b93d18e
......@@ -80,7 +80,7 @@ public class AuthCheckFilter implements Filter {
}
private String getRedirectURL(HttpServletRequest request, String optionalParams) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
try {
StringBuffer rURL = request.getRequestURL();
int pos = rURL.lastIndexOf("/");
......
......@@ -186,7 +186,7 @@ public class SidebarTag extends BodyTagSupport {
// Top level menu items
if (AdminConsole.getModel().elements().size() > 0) {
JspWriter out = pageContext.getOut();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
Element current = null;
Element subcurrent = null;
......
......@@ -129,7 +129,7 @@ public class TabsTag extends BodyTagSupport {
if (tabs.size() > 0) {
JspWriter out = pageContext.getOut();
// Build up the output in a buffer (is probably faster than a bunch of out.write's)
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("<ul>");
String body = getBodyContent().getString();
// For each tab, print out an <LI>.
......
......@@ -649,7 +649,7 @@ public class DbConnectionManager {
new DbConnectionManager().getClass().getResourceAsStream(resourceName)));
boolean done = false;
while (!done) {
StringBuffer command = new StringBuffer();
StringBuilder command = new StringBuilder();
while (true) {
String line = in.readLine();
if (line == null) {
......
......@@ -137,7 +137,7 @@ public class EmbeddedConnectionProvider implements ConnectionProvider {
con = connectionPool.getConnection();
boolean done = false;
while (!done) {
StringBuffer command = new StringBuffer();
StringBuilder command = new StringBuilder();
while (true) {
String line = in.readLine();
if (line == null) {
......
......@@ -11,10 +11,6 @@
package org.jivesoftware.database;
import org.jivesoftware.database.AbstractConnection;
import org.jivesoftware.database.CallableStatementWrapper;
import org.jivesoftware.database.PreparedStatementWrapper;
import java.sql.*;
import java.util.Enumeration;
import java.util.Hashtable;
......@@ -397,7 +393,7 @@ public class ProfiledConnection extends AbstractConnection {
return _sql;
}
StringBuffer sql = new StringBuffer(_sql);
StringBuilder sql = new StringBuilder(_sql);
boolean inValue = false;
boolean afterEquals = false;
boolean hasQuotes = false;
......@@ -565,7 +561,7 @@ public class ProfiledConnection extends AbstractConnection {
private static String reformatQuery(String _sql) {
int length = _sql.length();
int charAdded = 0;
StringBuffer sql = new StringBuffer(_sql);
StringBuilder sql = new StringBuilder(_sql);
for (int x = 0; x < length; x++) {
char c = _sql.charAt(x);
......
......@@ -96,7 +96,7 @@ public class ClientSession extends Session {
Writer writer = connection.getWriter();
// Build the start packet response
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("<?xml version='1.0' encoding='");
sb.append(CHARSET);
sb.append("'?>");
......
......@@ -57,7 +57,7 @@ public class ComponentSession extends Session {
Writer writer = connection.getWriter();
// Default answer header in case of an error
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("<?xml version='1.0' encoding='");
sb.append(CHARSET);
sb.append("'?>");
......@@ -120,7 +120,7 @@ public class ComponentSession extends Session {
try {
// Build the start packet response
sb = new StringBuffer();
sb = new StringBuilder();
sb.append("<?xml version='1.0' encoding='");
sb.append(CHARSET);
sb.append("'?>");
......@@ -143,7 +143,7 @@ public class ComponentSession extends Session {
if (!anticipatedDigest.equalsIgnoreCase(digest)) {
// The credentials supplied by the initiator are not valid (answer an error
// and close the connection)
sb = new StringBuffer();
sb = new StringBuilder();
// Include the conflict error in the response
sb.append("<stream:error>");
sb.append("<not-authorized xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\"/>");
......
......@@ -733,7 +733,7 @@ public class JiveGlobals {
// If still null, finding messengerHome failed.
if (messengerHome == null) {
failedLoading = true;
StringBuffer msg = new StringBuffer();
StringBuilder msg = new StringBuilder();
msg.append("Critical Error! The messengerHome directory could not be loaded, \n");
msg.append("which will prevent the application from working correctly.\n\n");
msg.append("You must set messengerHome in one of four ways:\n");
......
......@@ -71,7 +71,7 @@ public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider {
Element response = responseElement.createCopy();
Date current = new Date();
response.element("utc").setText(UTC_FORMAT.format(current));
StringBuffer display = new StringBuffer(DATE_FORMAT.format(current));
StringBuilder display = new StringBuilder(DATE_FORMAT.format(current));
display.append(' ');
display.append(TIME_FORMAT.format(current));
response.element("display").setText(display.toString());
......
......@@ -143,7 +143,7 @@ public class IQvCardHandler extends IQHandler {
* @return The name concatenating the values with the ':' character
*/
private String createName(List nameStack) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
Iterator iter = nameStack.iterator();
while (iter.hasNext()) {
if (buf.length() > 0) {
......
......@@ -111,7 +111,7 @@ public class LdapManager {
this.searchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter");
}
else {
StringBuffer filter = new StringBuffer();
StringBuilder filter = new StringBuilder();
filter.append("(").append(usernameField).append("={0})");
this.searchFilter = filter.toString();
}
......@@ -739,7 +739,7 @@ public class LdapManager {
*/
public void setSearchFilter(String searchFilter) {
if (searchFilter == null || "".equals(searchFilter)) {
StringBuffer filter = new StringBuffer();
StringBuilder filter = new StringBuilder();
filter.append("(").append(usernameField).append("={0})");
this.searchFilter = filter.toString();
JiveGlobals.deleteXMLProperty("ldap.searchFilter");
......
......@@ -304,7 +304,7 @@ public class LdapUserProvider implements UserProvider {
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
constraints.setReturningAttributes(new String[] { manager.getUsernameField() });
StringBuffer filter = new StringBuffer();
StringBuilder filter = new StringBuilder();
if (fields.size() > 1) {
filter.append("(|");
}
......
......@@ -931,7 +931,7 @@ public class MUCPersistenceManager {
* @return an integer based on the binary representation of the roles to broadcast.
*/
private static int marshallRolesToBroadcast(MUCRoom room) {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
buffer.append((room.canBroadcastPresence("moderator") ? "1" : "0"));
buffer.append((room.canBroadcastPresence("participant") ? "1" : "0"));
buffer.append((room.canBroadcastPresence("visitor") ? "1" : "0"));
......
......@@ -1009,7 +1009,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
* @return a comma delimtted String of the array values.
*/
private static String fromArray(String [] array) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int i=0; i<array.length; i++) {
buf.append(array[i]);
if (i != array.length-1) {
......
......@@ -296,7 +296,7 @@ public class SocketReadThread extends Thread {
}
else {
Writer writer = connection.getWriter();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("<?xml version='1.0' encoding='");
sb.append(CHARSET);
sb.append("'?>");
......
......@@ -412,7 +412,7 @@ public class DefaultUserProvider implements UserProvider {
try {
con = DbConnectionManager.getConnection();
stmt = con.createStatement();
StringBuffer sql = new StringBuffer();
StringBuilder sql = new StringBuilder();
sql.append("SELECT username FROM jiveUser WHERE");
boolean first = true;
if (fields.contains("Username")) {
......
......@@ -124,7 +124,7 @@ public class LinkedList {
*/
public String toString() {
LinkedListNode node = head.next;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
while (node != head) {
buf.append(node.toString()).append(", ");
node = node.next;
......
......@@ -112,7 +112,7 @@ public class LocaleUtils {
*/
private static String getTimeZoneName(String zoneID, Date now, Locale locale) {
TimeZone zone = TimeZone.getTimeZone(zoneID);
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
// Add in the GMT part to the name. First, figure out the offset.
int offset = zone.getRawOffset();
if (zone.inDaylightTime(now) && zone.useDaylightTime()) {
......
......@@ -51,7 +51,7 @@ public class StringUtils {
char[] string2 = string.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(string2.length);
StringBuilder buf = new StringBuilder(string2.length);
buf.append(string2, 0, i).append(newString2);
i += oLength;
int j = i;
......@@ -88,7 +88,7 @@ public class StringUtils {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
......@@ -128,7 +128,7 @@ public class StringUtils {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
......@@ -165,7 +165,7 @@ public class StringUtils {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
......@@ -198,7 +198,7 @@ public class StringUtils {
int last = 0;
char[] input = in.toCharArray();
int len = input.length;
StringBuffer out = new StringBuffer((int)(len * 1.3));
StringBuilder out = new StringBuilder((int)(len * 1.3));
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
......@@ -245,7 +245,7 @@ public class StringUtils {
int last = 0;
char[] input = in.toCharArray();
int len = input.length;
StringBuffer out = new StringBuffer((int)(len * 1.3));
StringBuilder out = new StringBuilder((int)(len * 1.3));
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
......@@ -336,7 +336,7 @@ public class StringUtils {
* @return generated hex string
*/
public static final String encodeHex(byte[] bytes) {
StringBuffer buf = new StringBuffer(bytes.length * 2);
StringBuilder buf = new StringBuilder(bytes.length * 2);
int i;
for (i = 0; i < bytes.length; i++) {
......@@ -451,7 +451,7 @@ public class StringUtils {
public static String encodeBase64(byte[] data) {
int c;
int len = data.length;
StringBuffer ret = new StringBuffer(((len / 3) + 1) * 4);
StringBuilder ret = new StringBuilder(((len / 3) + 1) * 4);
for (int i = 0; i < len; ++i) {
c = (data[i] >> 2) & 0x3f;
ret.append(cvt.charAt(c));
......@@ -509,7 +509,7 @@ public class StringUtils {
public static String decodeBase64(byte[] data) {
int c, c1;
int len = data.length;
StringBuffer ret = new StringBuffer((len * 3) / 4);
StringBuilder ret = new StringBuilder((len * 3) / 4);
for (int i = 0; i < len; ++i) {
c = cvt.indexOf(data[i]);
++i;
......@@ -717,7 +717,7 @@ public class StringUtils {
locale = JiveGlobals.getLocale();
}
StringBuffer buf = new StringBuffer(input);
StringBuilder buf = new StringBuilder(input);
boolean endOfLine = false;
int lineStart = 0;
......@@ -789,13 +789,13 @@ public class StringUtils {
int i = 0;
int last = 0;
int len = input.length;
StringBuffer out = null;
StringBuilder out = null;
for (; i < len; i++) {
ch = input[i];
if (ch == '\'') {
if (out == null) {
out = new StringBuffer(len + 2);
out = new StringBuilder(len + 2);
}
if (i > last) {
out.append(input, last, i - last);
......@@ -831,7 +831,7 @@ public class StringUtils {
int last = 0;
char[] input = string.toCharArray();
int len = input.length;
StringBuffer out = new StringBuffer((int)(len * 1.3));
StringBuilder out = new StringBuilder((int)(len * 1.3));
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
......@@ -902,7 +902,7 @@ public class StringUtils {
if (string == null || string.length() > length) {
return string;
}
StringBuffer buf = new StringBuffer(length);
StringBuilder buf = new StringBuilder(length);
buf.append(zeroArray, 0, length - string.length()).append(string);
return buf.toString();
}
......
......@@ -59,7 +59,7 @@ public class UniqueFileStrategy
* @return File the calculated file name
*/
public File nextFile() {
final StringBuffer sb = new StringBuffer();
final StringBuilder sb = new StringBuilder();
sb.append(m_baseFile);
if (m_formatter == null) {
sb.append(System.currentTimeMillis());
......
......@@ -275,7 +275,7 @@ public class BroadcastPlugin implements Plugin, Component {
* to all users.
*/
public void setGlobalAllowedUsers(Collection<String> allowedUsers) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (String jid : allowedUsers) {
buf.append(jid).append(",");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment