1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Add checkstyle rule for StringBuilder.append(char)

And replace all instances where String.Builder.append() is called with a
String of length one with append(char).

Also adds StringUtils.toStringBuilder(Collection, String).
This commit is contained in:
Florian Schmaus 2015-07-21 08:19:15 +02:00
parent 19ebcb814b
commit e0e4fd9b12
46 changed files with 159 additions and 142 deletions

View file

@ -91,11 +91,11 @@ public class AgentStatus implements ExtensionElement {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\"");
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append('"');
if (workgroupJID != null) {
buf.append(" jid=\"").append(workgroupJID).append("\"");
buf.append(" jid=\"").append(workgroupJID).append('"');
}
buf.append(">");
buf.append('>');
if (maxChats != -1) {
buf.append("<max-chats>").append(maxChats).append("</max-chats>");
}
@ -197,22 +197,22 @@ public class AgentStatus implements ExtensionElement {
buf.append("<chat ");
if (sessionID != null) {
buf.append(" sessionID=\"").append(sessionID).append("\"");
buf.append(" sessionID=\"").append(sessionID).append('"');
}
if (userID != null) {
buf.append(" userID=\"").append(userID).append("\"");
buf.append(" userID=\"").append(userID).append('"');
}
if (date != null) {
buf.append(" startTime=\"").append(UTC_FORMAT.format(date)).append("\"");
buf.append(" startTime=\"").append(UTC_FORMAT.format(date)).append('"');
}
if (email != null) {
buf.append(" email=\"").append(email).append("\"");
buf.append(" email=\"").append(email).append('"');
}
if (username != null) {
buf.append(" username=\"").append(username).append("\"");
buf.append(" username=\"").append(username).append('"');
}
if (question != null) {
buf.append(" question=\"").append(question).append("\"");
buf.append(" question=\"").append(question).append('"');
}
buf.append("/>");

View file

@ -108,7 +108,7 @@ public final class QueueDetails implements ExtensionElement {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">");
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">");
synchronized (users) {
for (Iterator<QueueUser> i=users.iterator(); i.hasNext(); ) {
@ -136,7 +136,7 @@ public final class QueueDetails implements ExtensionElement {
buf.append("</user>");
}
}
buf.append("</").append(ELEMENT_NAME).append(">");
buf.append("</").append(ELEMENT_NAME).append('>');
return buf.toString();
}

View file

@ -98,7 +98,7 @@ public class QueueOverview implements ExtensionElement {
public String toXML () {
StringBuilder buf = new StringBuilder();
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">");
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">");
if (userCount != -1) {
buf.append("<count>").append(userCount).append("</count>");
@ -112,7 +112,7 @@ public class QueueOverview implements ExtensionElement {
if (status != null) {
buf.append("<status>").append(status).append("</status>");
}
buf.append("</").append(ELEMENT_NAME).append(">");
buf.append("</").append(ELEMENT_NAME).append('>');
return buf.toString();
}

View file

@ -57,7 +57,7 @@ public class SessionID implements ExtensionElement {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\" ");
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\" ");
buf.append("id=\"").append(this.getSessionID());
buf.append("\"/>");

View file

@ -59,7 +59,7 @@ public class UserID implements ExtensionElement {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\" ");
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\" ");
buf.append("id=\"").append(this.getUserID());
buf.append("\"/>");

View file

@ -62,7 +62,7 @@ public class WorkgroupInformation implements ExtensionElement {
StringBuilder buf = new StringBuilder();
buf.append('<').append(ELEMENT_NAME);
buf.append(" jid=\"").append(getWorkgroupJID()).append("\"");
buf.append(" jid=\"").append(getWorkgroupJID()).append('"');
buf.append(" xmlns=\"").append(NAMESPACE).append("\" />");
return buf.toString();

View file

@ -66,7 +66,7 @@ public class GenericSettings extends IQ {
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
buf.append(">");
buf.append('>');
if (ModelUtil.hasLength(getQuery())) {
buf.append("<query>" + getQuery() + "</query>");
}

View file

@ -305,30 +305,30 @@ public class MessageEvent implements ExtensionElement {
*/
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">");
// Note: Cancellation events don't specify any tag. They just send the packetID
// Add the offline tag if the sender requests to be notified of offline events or if
// the target is offline
if (isOffline())
buf.append("<").append(MessageEvent.OFFLINE).append("/>");
buf.append('<').append(MessageEvent.OFFLINE).append("/>");
// Add the delivered tag if the sender requests to be notified when the message is
// delivered or if the target notifies that the message has been delivered
if (isDelivered())
buf.append("<").append(MessageEvent.DELIVERED).append("/>");
buf.append('<').append(MessageEvent.DELIVERED).append("/>");
// Add the displayed tag if the sender requests to be notified when the message is
// displayed or if the target notifies that the message has been displayed
if (isDisplayed())
buf.append("<").append(MessageEvent.DISPLAYED).append("/>");
buf.append('<').append(MessageEvent.DISPLAYED).append("/>");
// Add the composing tag if the sender requests to be notified when the target is
// composing a reply or if the target notifies that he/she is composing a reply
if (isComposing())
buf.append("<").append(MessageEvent.COMPOSING).append("/>");
buf.append('<').append(MessageEvent.COMPOSING).append("/>");
// Add the id tag only if the MessageEvent is a notification message (not a request)
if (getStanzaId() != null)
buf.append("<id>").append(getStanzaId()).append("</id>");
buf.append("</").append(getElementName()).append(">");
buf.append("</").append(getElementName()).append('>');
return buf.toString();
}

View file

@ -100,11 +100,11 @@ public class RemoteRosterEntry {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<item jid=\"").append(user).append("\"");
buf.append("<item jid=\"").append(user).append('"');
if (name != null) {
buf.append(" name=\"").append(name).append("\"");
buf.append(" name=\"").append(name).append('"');
}
buf.append(">");
buf.append('>');
synchronized (groupNames) {
for (String groupName : groupNames) {
buf.append("<group>").append(groupName).append("</group>");

View file

@ -165,14 +165,14 @@ public class RosterExchange implements ExtensionElement {
*/
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">");
// Loop through all roster entries and append them to the string buffer
for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
RemoteRosterEntry remoteRosterEntry = i.next();
buf.append(remoteRosterEntry.toXML());
}
buf.append("</").append(getElementName()).append(">");
buf.append("</").append(getElementName()).append('>');
return buf.toString();
}