mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01: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
|
@ -19,6 +19,18 @@
|
|||
<property name="format" value="MXParser"/>
|
||||
<property name="message" value="Must not use MXParser, use XmlPullParserFactory instead"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<!--
|
||||
Matches StringBuilder.append(String) calls where the
|
||||
argument is a String of length one. Those should be replaced
|
||||
with append(char) for performance reasons.
|
||||
|
||||
TODO: This could be more advanced in order to match also
|
||||
- .append("\u1234")
|
||||
-->
|
||||
<property name="format" value="\.append\("(.|\\.)"\)"/>
|
||||
<property name="message" value="Don't use StringBuilder.append(String) when you can use StringBuilder.append(char). Solution: Replace double quotes of append's argument with single quotes."/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s+$"/>
|
||||
<property name="message" value="Line containing only whitespace character(s)"/>
|
||||
|
|
|
@ -160,7 +160,7 @@ public class MessageTest extends SmackTestCase {
|
|||
Message msg = new Message(getFullJID(1), Message.Type.chat);
|
||||
StringBuilder sb = new StringBuilder(5000);
|
||||
for (int i = 0; i <= 4000; i++) {
|
||||
sb.append("X");
|
||||
sb.append('X');
|
||||
}
|
||||
msg.setBody(sb.toString());
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ package org.jivesoftware.smack.filter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
public abstract class AbstractListFilter implements StanzaFilter {
|
||||
|
||||
|
@ -67,14 +67,8 @@ public abstract class AbstractListFilter implements StanzaFilter {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(": (");
|
||||
for (Iterator<StanzaFilter> it = filters.iterator(); it.hasNext();) {
|
||||
StanzaFilter filter = it.next();
|
||||
sb.append(filter.toString());
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
sb.append(StringUtils.toStringBuilder(filters, ", "));
|
||||
sb.append(')');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,21 +222,32 @@ public class StringUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform a collection of CharSequences to a whitespace delimited String.
|
||||
* Transform a collection of objects to a whitespace delimited String.
|
||||
*
|
||||
* @param collection the collection to transform.
|
||||
* @return a String with all the elements of the collection.
|
||||
*/
|
||||
public static String collectionToString(Collection<? extends CharSequence> collection) {
|
||||
public static String collectionToString(Collection<? extends Object> collection) {
|
||||
return toStringBuilder(collection, " ").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a collection of objects to a delimited String.
|
||||
*
|
||||
* @param collection the collection to transform.
|
||||
* @param delimiter the delimiter used to delimit the Strings.
|
||||
* @return a StringBuilder with all the elements of the collection.
|
||||
*/
|
||||
public static StringBuilder toStringBuilder(Collection<? extends Object> collection, String delimiter) {
|
||||
StringBuilder sb = new StringBuilder(collection.size() * 20);
|
||||
for (Iterator<? extends CharSequence> it = collection.iterator(); it.hasNext();) {
|
||||
CharSequence cs = it.next();
|
||||
for (Iterator<? extends Object> it = collection.iterator(); it.hasNext();) {
|
||||
Object cs = it.next();
|
||||
sb.append(cs);
|
||||
if (it.hasNext()) {
|
||||
sb.append(' ');
|
||||
sb.append(delimiter);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static String returnIfNotEmptyTrimmed(String string) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -207,7 +207,7 @@ public final class RosterEntry extends Manager {
|
|||
group = iter.next();
|
||||
buf.append(group.getName());
|
||||
}
|
||||
buf.append("]");
|
||||
buf.append(']');
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class XmppHostnameVerifier implements HostnameVerifier {
|
|||
StringBuilder sb = new StringBuilder("No subject alternative DNS name matching "
|
||||
+ name + " found. Tried: ");
|
||||
for (String nonMatchingDnsAltname : nonMatchingDnsAltnames) {
|
||||
sb.append(nonMatchingDnsAltname).append(",");
|
||||
sb.append(nonMatchingDnsAltname).append(',');
|
||||
}
|
||||
throw new CertificateException(sb.toString());
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class XmppHostnameVerifier implements HostnameVerifier {
|
|||
StringBuilder sb = new StringBuilder("No subject alternative names matching IP address "
|
||||
+ expectedIP + " found. Tried: ");
|
||||
for (String s : nonMatchingIpAltnames) {
|
||||
sb.append(s).append(",");
|
||||
sb.append(s).append(',');
|
||||
}
|
||||
throw new CertificateException(sb.toString());
|
||||
}
|
||||
|
|
|
@ -208,17 +208,17 @@ public class PayloadType {
|
|||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(getElementName()).append(" ");
|
||||
buf.append('<').append(getElementName()).append(' ');
|
||||
|
||||
// We covert here the payload type to XML
|
||||
if (this.getId() != PayloadType.INVALID_PT) {
|
||||
buf.append(" id=\"").append(this.getId()).append("\"");
|
||||
buf.append(" id=\"").append(this.getId()).append('"');
|
||||
}
|
||||
if (this.getName() != null) {
|
||||
buf.append(" name=\"").append(this.getName()).append("\"");
|
||||
buf.append(" name=\"").append(this.getName()).append('"');
|
||||
}
|
||||
if (this.getChannels() != 0) {
|
||||
buf.append(" channels=\"").append(this.getChannels()).append("\"");
|
||||
buf.append(" channels=\"").append(this.getChannels()).append('"');
|
||||
}
|
||||
if (getChildAttributes() != null) {
|
||||
buf.append(getChildAttributes());
|
||||
|
|
|
@ -134,22 +134,22 @@ public class RTPBridge extends IQ {
|
|||
StringBuilder str = new StringBuilder();
|
||||
|
||||
if (getSid() != null)
|
||||
str.append(" sid='").append(getSid()).append("'");
|
||||
str.append(" sid='").append(getSid()).append('\'');
|
||||
|
||||
if (getPass() != null)
|
||||
str.append(" pass='").append(getPass()).append("'");
|
||||
str.append(" pass='").append(getPass()).append('\'');
|
||||
|
||||
if (getPortA() != -1)
|
||||
str.append(" porta='").append(getPortA()).append("'");
|
||||
str.append(" porta='").append(getPortA()).append('\'');
|
||||
|
||||
if (getPortB() != -1)
|
||||
str.append(" portb='").append(getPortB()).append("'");
|
||||
str.append(" portb='").append(getPortB()).append('\'');
|
||||
|
||||
if (getHostA() != null)
|
||||
str.append(" hosta='").append(getHostA()).append("'");
|
||||
str.append(" hosta='").append(getHostA()).append('\'');
|
||||
|
||||
if (getHostB() != null)
|
||||
str.append(" hostb='").append(getHostB()).append("'");
|
||||
str.append(" hostb='").append(getHostB()).append('\'');
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
|
|
@ -345,18 +345,18 @@ public class Jingle extends IQ {
|
|||
*/
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
|
||||
if (getInitiator() != null) {
|
||||
buf.append(" initiator=\"").append(getInitiator()).append("\"");
|
||||
buf.append(" initiator=\"").append(getInitiator()).append('"');
|
||||
}
|
||||
if (getResponder() != null) {
|
||||
buf.append(" responder=\"").append(getResponder()).append("\"");
|
||||
buf.append(" responder=\"").append(getResponder()).append('"');
|
||||
}
|
||||
if (getAction() != null) {
|
||||
buf.append(" action=\"").append(getAction().name()).append("\"");
|
||||
buf.append(" action=\"").append(getAction().name()).append('"');
|
||||
}
|
||||
if (getSid() != null) {
|
||||
buf.append(" sid=\"").append(getSid()).append("\"");
|
||||
buf.append(" sid=\"").append(getSid()).append('"');
|
||||
}
|
||||
buf.append(">");
|
||||
buf.append('>');
|
||||
|
||||
synchronized (contents) {
|
||||
for (JingleContent content : contents) {
|
||||
|
|
|
@ -162,7 +162,7 @@ public class JingleContent implements ExtensionElement {
|
|||
|
||||
synchronized (transports) {
|
||||
|
||||
buf.append("<").append(getElementName());
|
||||
buf.append('<').append(getElementName());
|
||||
|
||||
buf.append(" creator='" + creator + "' name='" + name + "'>");
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class JingleContent implements ExtensionElement {
|
|||
for (JingleTransport transport : transports) {
|
||||
buf.append(transport.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
|||
|
||||
synchronized (payloads) {
|
||||
if (payloads.size() > 0) {
|
||||
buf.append("<").append(getElementName());
|
||||
buf.append('<').append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\" >");
|
||||
|
||||
Iterator<JinglePayloadType> pt = payloads.listIterator();
|
||||
|
@ -157,7 +157,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
|||
JinglePayloadType pte = pt.next();
|
||||
buf.append(pte.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,17 +251,17 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
if (payload != null) {
|
||||
buf.append("<").append(getElementName()).append(" ");
|
||||
buf.append('<').append(getElementName()).append(' ');
|
||||
|
||||
// We covert here the payload type to XML
|
||||
if (payload.getId() != PayloadType.INVALID_PT) {
|
||||
buf.append(" id=\"").append(payload.getId()).append("\"");
|
||||
buf.append(" id=\"").append(payload.getId()).append('"');
|
||||
}
|
||||
if (payload.getName() != null) {
|
||||
buf.append(" name=\"").append(payload.getName()).append("\"");
|
||||
buf.append(" name=\"").append(payload.getName()).append('"');
|
||||
}
|
||||
if (payload.getChannels() != 0) {
|
||||
buf.append(" channels=\"").append(payload.getChannels()).append("\"");
|
||||
buf.append(" channels=\"").append(payload.getChannels()).append('"');
|
||||
}
|
||||
if (getChildAttributes() != null) {
|
||||
buf.append(getChildAttributes());
|
||||
|
|
|
@ -82,7 +82,7 @@ public class JingleContentInfo implements ExtensionElement {
|
|||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"");
|
||||
buf.append('<').append(getElementName()).append(" xmlns=\"");
|
||||
buf.append(getNamespace()).append("\" ");
|
||||
buf.append("/>");
|
||||
return buf.toString();
|
||||
|
|
|
@ -156,7 +156,7 @@ public abstract class JingleDescription implements ExtensionElement {
|
|||
|
||||
synchronized (payloads) {
|
||||
if (payloads.size() > 0) {
|
||||
buf.append("<").append(getElementName());
|
||||
buf.append('<').append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\" >");
|
||||
|
||||
for (PayloadType payloadType : payloads) {
|
||||
|
@ -164,7 +164,7 @@ public abstract class JingleDescription implements ExtensionElement {
|
|||
buf.append(payloadType.toXML());
|
||||
}
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class JingleError implements ExtensionElement {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
if (message != null) {
|
||||
buf.append("<error type=\"cancel\">");
|
||||
buf.append("<").append(message).append(" xmlns=\"").append(NAMESPACE).append(
|
||||
buf.append('<').append(message).append(" xmlns=\"").append(NAMESPACE).append(
|
||||
"\"/>");
|
||||
buf.append("</error>");
|
||||
}
|
||||
|
|
|
@ -151,19 +151,19 @@ public class JingleTransport implements ExtensionElement {
|
|||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"");
|
||||
buf.append('<').append(getElementName()).append(" xmlns=\"");
|
||||
buf.append(getNamespace()).append("\" ");
|
||||
|
||||
synchronized (candidates) {
|
||||
if (getCandidatesCount() > 0) {
|
||||
buf.append(">");
|
||||
buf.append('>');
|
||||
Iterator<JingleTransportCandidate> iter = getCandidates();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
JingleTransportCandidate candidate = iter.next();
|
||||
buf.append(candidate.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
buf.append("</").append(getElementName()).append('>');
|
||||
} else {
|
||||
buf.append("/>");
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ public class JingleTransport implements ExtensionElement {
|
|||
String childElements = getChildElements();
|
||||
|
||||
if (transportCandidate != null && childElements != null) {
|
||||
buf.append("<").append(getElementName()).append(" ");
|
||||
buf.append('<').append(getElementName()).append(' ');
|
||||
buf.append(childElements);
|
||||
buf.append("/>");
|
||||
}
|
||||
|
@ -323,18 +323,18 @@ public class JingleTransport implements ExtensionElement {
|
|||
ICECandidate tci = (ICECandidate) transportCandidate;
|
||||
|
||||
// We convert the transportElement candidate to XML here...
|
||||
buf.append(" generation=\"").append(tci.getGeneration()).append("\"");
|
||||
buf.append(" ip=\"").append(tci.getIp()).append("\"");
|
||||
buf.append(" port=\"").append(tci.getPort()).append("\"");
|
||||
buf.append(" network=\"").append(tci.getNetwork()).append("\"");
|
||||
buf.append(" username=\"").append(tci.getUsername()).append("\"");
|
||||
buf.append(" password=\"").append(tci.getPassword()).append("\"");
|
||||
buf.append(" preference=\"").append(tci.getPreference()).append("\"");
|
||||
buf.append(" type=\"").append(tci.getType()).append("\"");
|
||||
buf.append(" generation=\"").append(tci.getGeneration()).append('"');
|
||||
buf.append(" ip=\"").append(tci.getIp()).append('"');
|
||||
buf.append(" port=\"").append(tci.getPort()).append('"');
|
||||
buf.append(" network=\"").append(tci.getNetwork()).append('"');
|
||||
buf.append(" username=\"").append(tci.getUsername()).append('"');
|
||||
buf.append(" password=\"").append(tci.getPassword()).append('"');
|
||||
buf.append(" preference=\"").append(tci.getPreference()).append('"');
|
||||
buf.append(" type=\"").append(tci.getType()).append('"');
|
||||
|
||||
// Optional elements
|
||||
if (transportCandidate.getName() != null) {
|
||||
buf.append(" name=\"").append(tci.getName()).append("\"");
|
||||
buf.append(" name=\"").append(tci.getName()).append('"');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,14 +408,14 @@ public class JingleTransport implements ExtensionElement {
|
|||
if (transportCandidate != null && transportCandidate instanceof TransportCandidate.Fixed) {
|
||||
TransportCandidate.Fixed tcf = (TransportCandidate.Fixed) transportCandidate;
|
||||
|
||||
buf.append(" generation=\"").append(tcf.getGeneration()).append("\"");
|
||||
buf.append(" ip=\"").append(tcf.getIp()).append("\"");
|
||||
buf.append(" port=\"").append(tcf.getPort()).append("\"");
|
||||
buf.append(" generation=\"").append(tcf.getGeneration()).append('"');
|
||||
buf.append(" ip=\"").append(tcf.getIp()).append('"');
|
||||
buf.append(" port=\"").append(tcf.getPort()).append('"');
|
||||
|
||||
// Optional parameters
|
||||
String name = tcf.getName();
|
||||
if (name != null) {
|
||||
buf.append(" name=\"").append(name).append("\"");
|
||||
buf.append(" name=\"").append(name).append('"');
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
|
|
|
@ -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("/>");
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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("\"/>");
|
||||
|
||||
|
|
|
@ -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("\"/>");
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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>");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue