From 89fccaa90b823ea924eb6d2b54fcaf40a0e3bc34 Mon Sep 17 00:00:00 2001 From: Anatoliy Sablin Date: Wed, 18 Oct 2017 23:51:25 +0300 Subject: Replaced string concatenation with the StringBuilder. --- .../com/juick/xmpp/extensions/JuickMessage.java | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'juick-xmpp/src/main/java/com/juick/xmpp/extensions') diff --git a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java index 2e10606a..86b4d02e 100644 --- a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java +++ b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java @@ -92,44 +92,41 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { } @Override public String toString() { - String ret = ""; - ret = "<" + TagName + " xmlns=\"" + XMLNS + "\""; + StringBuilder ret = new StringBuilder("<").append(TagName).append(" xmlns=\"").append(XMLNS).append("\""); if (getMid() > 0) { - ret += " mid=\"" + getMid() + "\""; + ret.append(" mid=\"").append(getMid()).append("\""); } if (getRid() > 0) { - ret += " rid=\"" + getRid() + "\""; + ret.append(" rid=\"").append(getRid()).append("\""); } if (getReplyto() > 0) { - ret += " replyto=\"" + getReplyto() + "\""; + ret.append(" replyto=\"").append(getReplyto()).append("\""); } - ret += " privacy=\"" + getPrivacy() + "\""; + ret.append(" privacy=\"").append(getPrivacy()).append("\""); if (FriendsOnly) { - ret += " friendsonly=\"1\""; + ret.append(" friendsonly=\"1\""); } if (ReadOnly) { - ret += " readonly=\"1\""; + ret.append(" readonly=\"1\""); } if (getTimestamp() != null) { - ret += " ts=\"" + df.format(Date.from(getTimestamp())) + "\""; + ret.append(" ts=\"").append(df.format(Date.from(getTimestamp()))).append("\""); } if (getAttachmentType() != null) { - ret += " attach=\"" + getAttachmentType() + "\""; + ret.append(" attach=\"").append(getAttachmentType()).append("\""); } - ret += ">"; + ret.append(">"); if (getUser() != null) { - ret += JuickUser.toString(getUser()); + ret.append(JuickUser.toString(getUser())); } if (getText() != null) { - ret += "" + StringEscapeUtils.escapeXml10(getText()) + ""; + ret.append("").append(StringEscapeUtils.escapeXml10(getText())).append(""); } - if (!getTags().isEmpty()) { - for (Tag Tag : getTags()) { - ret += "" + StringEscapeUtils.escapeXml10(Tag.getName()) + ""; - } + for (Tag Tag : getTags()) { + ret.append("").append(StringEscapeUtils.escapeXml10(Tag.getName())).append(""); } - ret += ""; - return ret; + ret.append(""); + return ret.toString(); } @Override public boolean equals(Object obj) { -- cgit v1.2.3