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