From 69a5bdba32cdf0a48e51baa8c9fb28dca013f515 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Wed, 7 Dec 2016 18:56:43 +0700 Subject: message improvenments, checking for tag's duplicates --- .../java/com/juick/xmpp/extensions/JuickUser.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'juick-xmpp/src/main/java/com/juick') diff --git a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickUser.java b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickUser.java index 7473134c..08e38c41 100644 --- a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickUser.java +++ b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickUser.java @@ -17,18 +17,17 @@ */ package com.juick.xmpp.extensions; +import com.juick.xmpp.StanzaChild; import com.juick.xmpp.utils.XmlUtils; -import com.juick.xmpp.*; -import java.io.IOException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; + /** - * * @author Ugnich Anton */ public class JuickUser extends com.juick.User implements StanzaChild { - public final static String XMLNS = "http://juick.com/user"; public final static String TagName = "user"; @@ -57,15 +56,19 @@ public class JuickUser extends com.juick.User implements StanzaChild { } public static String toString(com.juick.User user) { - String str = "<" + TagName + " xmlns='" + XMLNS + "'"; - if (user.getUid() > 0) { - str += " uid='" + user.getUid() + "'"; - } - if (user.getName() != null && user.getName().length() > 0) { - str += " uname='" + XmlUtils.escape(user.getName()) + "'"; - } - str += "/>"; - return str; + StringBuilder builder = new StringBuilder(); + + builder.append("<").append(TagName).append(" xmlns='").append(XMLNS).append("'"); + + if (user.getUid() > 0) + builder.append(" uid='").append(user.getUid()).append("'"); + + if (user.getName() != null && user.getName().length() > 0) + builder.append(" uname='").append(XmlUtils.escape(user.getName())).append("'"); + + builder.append("/>"); + + return builder.toString(); } @Override -- cgit v1.2.3