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:
parent
19ebcb814b
commit
e0e4fd9b12
46 changed files with 159 additions and 142 deletions
|
@ -201,7 +201,7 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
buf.optAttribute("desc", description);
|
||||
if (description != null && description.trim().length() > 0) {
|
||||
buf.append(" desc=\"");
|
||||
buf.append(description).append("\"");
|
||||
buf.append(description).append('"');
|
||||
}
|
||||
buf.optBooleanAttribute("delivered", delivered);
|
||||
buf.optAttribute("uri", uri);
|
||||
|
|
|
@ -155,27 +155,27 @@ public class AMPExtension implements ExtensionElement {
|
|||
@Override
|
||||
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('"');
|
||||
if (status != null) {
|
||||
buf.append(" status=\"").append(status.toString()).append("\"");
|
||||
buf.append(" status=\"").append(status.toString()).append('"');
|
||||
}
|
||||
if (to != null) {
|
||||
buf.append(" to=\"").append(to).append("\"");
|
||||
buf.append(" to=\"").append(to).append('"');
|
||||
}
|
||||
if (from != null) {
|
||||
buf.append(" from=\"").append(from).append("\"");
|
||||
buf.append(" from=\"").append(from).append('"');
|
||||
}
|
||||
if (perHop) {
|
||||
buf.append(" per-hop=\"true\"");
|
||||
}
|
||||
buf.append(">");
|
||||
buf.append('>');
|
||||
|
||||
// Loop through all the rules and append them to the string buffer
|
||||
for (Rule rule : getRules()) {
|
||||
buf.append(rule.toXML());
|
||||
}
|
||||
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class AttentionExtension implements ExtensionElement {
|
|||
*/
|
||||
public String toXML() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<").append(getElementName()).append(" xmlns=\"").append(
|
||||
sb.append('<').append(getElementName()).append(" xmlns=\"").append(
|
||||
getNamespace()).append("\"/>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -631,13 +631,13 @@ public final class EntityCapsManager extends Manager {
|
|||
// followed by the '<' character.
|
||||
for (DiscoverInfo.Identity identity : sortedIdentities) {
|
||||
sb.append(identity.getCategory());
|
||||
sb.append("/");
|
||||
sb.append('/');
|
||||
sb.append(identity.getType());
|
||||
sb.append("/");
|
||||
sb.append('/');
|
||||
sb.append(identity.getLanguage() == null ? "" : identity.getLanguage());
|
||||
sb.append("/");
|
||||
sb.append('/');
|
||||
sb.append(identity.getName() == null ? "" : identity.getName());
|
||||
sb.append("<");
|
||||
sb.append('<');
|
||||
}
|
||||
|
||||
// 4. Sort the supported service discovery features.
|
||||
|
@ -649,7 +649,7 @@ public final class EntityCapsManager extends Manager {
|
|||
// character
|
||||
for (String f : features) {
|
||||
sb.append(f);
|
||||
sb.append("<");
|
||||
sb.append('<');
|
||||
}
|
||||
|
||||
// only use the data form for calculation is it has a hidden FORM_TYPE
|
||||
|
@ -690,7 +690,7 @@ public final class EntityCapsManager extends Manager {
|
|||
// followed by the '<' character.
|
||||
for (FormField f : fs) {
|
||||
sb.append(f.getVariable());
|
||||
sb.append("<");
|
||||
sb.append('<');
|
||||
formFieldValuesToCaps(f.getValues(), sb);
|
||||
}
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ public final class EntityCapsManager extends Manager {
|
|||
}
|
||||
for (String fv : fvs) {
|
||||
sb.append(fv);
|
||||
sb.append("<");
|
||||
sb.append('<');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public class AdHocCommandData extends IQ {
|
|||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName());
|
||||
buf.append('<').append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\"/>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
|
@ -81,14 +81,14 @@ public class DefaultPrivateData implements PrivateData {
|
|||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||
buf.append('<').append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||
for (String name : getNames()) {
|
||||
String value = getValue(name);
|
||||
buf.append("<").append(name).append(">");
|
||||
buf.append('<').append(name).append('>');
|
||||
buf.append(value);
|
||||
buf.append("</").append(name).append(">");
|
||||
buf.append("</").append(name).append('>');
|
||||
}
|
||||
buf.append("</").append(elementName).append(">");
|
||||
buf.append("</").append(elementName).append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class Nick implements ExtensionElement {
|
|||
public String toXML() {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(
|
||||
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append(
|
||||
NAMESPACE).append("\">");
|
||||
buf.append(getName());
|
||||
buf.append("</").append(ELEMENT_NAME).append('>');
|
||||
|
|
|
@ -80,11 +80,11 @@ public class OfflineMessageInfo 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(
|
||||
"\">");
|
||||
if (getNode() != null)
|
||||
buf.append("<item node=\"").append(getNode()).append("\"/>");
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -182,13 +182,13 @@ public class OfflineMessageRequest extends IQ {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item");
|
||||
if (getAction() != null) {
|
||||
buf.append(" action=\"").append(getAction()).append("\"");
|
||||
buf.append(" action=\"").append(getAction()).append('"');
|
||||
}
|
||||
if (getJid() != null) {
|
||||
buf.append(" jid=\"").append(getJid()).append("\"");
|
||||
buf.append(" jid=\"").append(getJid()).append('"');
|
||||
}
|
||||
if (getNode() != null) {
|
||||
buf.append(" node=\"").append(getNode()).append("\"");
|
||||
buf.append(" node=\"").append(getNode()).append('"');
|
||||
}
|
||||
buf.append("/>");
|
||||
return buf.toString();
|
||||
|
|
|
@ -93,9 +93,9 @@ public class PEPEvent 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("\">");
|
||||
buf.append(item.toXML());
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ public abstract class PEPItem implements ExtensionElement {
|
|||
*/
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" id=\"").append(id).append("\">");
|
||||
buf.append('<').append(getElementName()).append(" id=\"").append(id).append("\">");
|
||||
buf.append(getItemDetailsXML());
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -296,17 +296,17 @@ public class PrivacyItem {
|
|||
} else {
|
||||
buf.append(" action=\"deny\"");
|
||||
}
|
||||
buf.append(" order=\"").append(getOrder()).append("\"");
|
||||
buf.append(" order=\"").append(getOrder()).append('"');
|
||||
if (getType() != null) {
|
||||
buf.append(" type=\"").append(getType()).append("\"");
|
||||
buf.append(" type=\"").append(getType()).append('"');
|
||||
}
|
||||
if (getValue() != null) {
|
||||
buf.append(" value=\"").append(getValue()).append("\"");
|
||||
buf.append(" value=\"").append(getValue()).append('"');
|
||||
}
|
||||
if (isFilterEverything()) {
|
||||
buf.append("/>");
|
||||
} else {
|
||||
buf.append(">");
|
||||
buf.append('>');
|
||||
if (this.isFilterIQ()) {
|
||||
buf.append("<iq/>");
|
||||
}
|
||||
|
|
|
@ -122,13 +122,13 @@ public class Item extends NodeExtension
|
|||
{
|
||||
builder.append(" id='");
|
||||
builder.append(id);
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
|
||||
if (getNode() != null) {
|
||||
builder.append(" node='");
|
||||
builder.append(getNode());
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
builder.append("/>");
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
|
||||
builder.append("</");
|
||||
builder.append(getElementName());
|
||||
builder.append(">");
|
||||
builder.append('>');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,15 +118,15 @@ public class PayloadItem<E extends ExtensionElement> extends Item
|
|||
{
|
||||
builder.append(" id='");
|
||||
builder.append(getId());
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
|
||||
if (getNode() != null) {
|
||||
builder.append(" node='");
|
||||
builder.append(getNode());
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
builder.append(">");
|
||||
builder.append('>');
|
||||
builder.append(payload.toXML());
|
||||
builder.append("</item>");
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class SubscribeExtension extends NodeExtension
|
|||
{
|
||||
builder.append(" node='");
|
||||
builder.append(getNode());
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
builder.append(" jid='");
|
||||
builder.append(getJid());
|
||||
|
|
|
@ -153,11 +153,11 @@ public class Subscription extends NodeExtension
|
|||
|
||||
private static void appendAttribute(StringBuilder builder, String att, String value)
|
||||
{
|
||||
builder.append(" ");
|
||||
builder.append(' ');
|
||||
builder.append(att);
|
||||
builder.append("='");
|
||||
builder.append(value);
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,9 +81,9 @@ public class SubscriptionsExtension extends NodeExtension
|
|||
{
|
||||
builder.append(" node='");
|
||||
builder.append(getNode());
|
||||
builder.append("'");
|
||||
builder.append('\'');
|
||||
}
|
||||
builder.append(">");
|
||||
builder.append('>');
|
||||
|
||||
for (Subscription item : items)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public class SubscriptionsExtension extends NodeExtension
|
|||
|
||||
builder.append("</");
|
||||
builder.append(getElementName());
|
||||
builder.append(">");
|
||||
builder.append('>');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class SimpleUserSearch extends IQ {
|
|||
String name = field.getVariable();
|
||||
String value = getSingleValue(field);
|
||||
if (value.trim().length() > 0) {
|
||||
buf.append("<").append(name).append(">").append(value).append("</").append(name).append(">");
|
||||
buf.append('<').append(name).append('>').append(value).append("</").append(name).append('>');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ public class StreamInitiation extends IQ {
|
|||
public String toXML() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append("<").append(getElementName()).append(" xmlns=\"")
|
||||
buffer.append('<').append(getElementName()).append(" xmlns=\"")
|
||||
.append(getNamespace()).append("\" ");
|
||||
|
||||
if (getName() != null) {
|
||||
|
@ -348,14 +348,14 @@ public class StreamInitiation extends IQ {
|
|||
}
|
||||
|
||||
if ((desc != null && desc.length() > 0) || isRanged) {
|
||||
buffer.append(">");
|
||||
buffer.append('>');
|
||||
if (getDesc() != null && desc.length() > 0) {
|
||||
buffer.append("<desc>").append(StringUtils.escapeForXML(getDesc())).append("</desc>");
|
||||
}
|
||||
if (isRanged()) {
|
||||
buffer.append("<range/>");
|
||||
}
|
||||
buffer.append("</").append(getElementName()).append(">");
|
||||
buffer.append("</").append(getElementName()).append('>');
|
||||
}
|
||||
else {
|
||||
buffer.append("/>");
|
||||
|
|
|
@ -376,7 +376,7 @@ public class Form {
|
|||
sb.append(it.next());
|
||||
// If this is not the last instruction then append a newline
|
||||
if (it.hasNext()) {
|
||||
sb.append("\n");
|
||||
sb.append('\n');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue