diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index 08aa082c1..b071a5c33 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -40,10 +40,10 @@ import java.lang.reflect.Method; import java.net.Socket; import java.net.UnknownHostException; import java.util.Collection; -import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; /** * Creates a connection to a XMPP server. A simple use of this API might @@ -89,8 +89,8 @@ public class XMPPConnection { */ public static boolean DEBUG_ENABLED = false; - private final static List connectionEstablishedListeners = - new CopyOnWriteArrayList(); + private final static Set connectionEstablishedListeners = + new CopyOnWriteArraySet(); static { // Use try block since we may not have permission to get a system @@ -167,7 +167,7 @@ public class XMPPConnection { * Holds the initial configuration used while creating the connection. */ private ConnectionConfiguration configuration; - + /** * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * performed to try to determine the IP address and port corresponding to the @@ -396,7 +396,6 @@ public class XMPPConnection { } // Do partial version of nameprep on the username. username = username.toLowerCase().trim(); - username = StringUtils.escapeNode(username); String response; if (configuration.isSASLAuthenticationEnabled() && @@ -437,14 +436,14 @@ public class XMPPConnection { if (sendPresence) { packetWriter.sendPacket(new Presence(Presence.Type.available)); } - + // Indicate that we're now authenticated. authenticated = true; anonymous = false; // Stores the autentication for future reconnection this.getConfiguration().setUsernameAndPassword(username, password); - + // If debugging is enabled, change the the debug window title to include the // name we are now logged-in as. // If DEBUG_ENABLED was set to true AFTER the connection was created the debugger @@ -654,30 +653,30 @@ public class XMPPConnection { catch (Exception e) { // Ignore. } - + this.setWasAuthenticated(authenticated); authenticated = false; connected = false; - + saslAuthentication.init(); } - + /** * Closes the connection by setting presence to unavailable then closing the stream to * the XMPP server. The XMPPConnection can still be used for connecting to the server * again. - * + * * The difference between disconnect and shutdown is that disconnect makes a complete reset * of the connection state whereas shutdown only cleans the connection and keeps alive * packet reader listeners, previous login and roster presences. */ public void disconnect() { this.shutdown(); - + this.roster = null; - + this.wasAuthenticated = false; - + packetWriter = null; packetReader = null; } @@ -819,9 +818,7 @@ public class XMPPConnection { * @param connectionEstablishedListener a listener interested on connection established events. */ public static void addConnectionEstablishedListener(ConnectionEstablishedListener connectionEstablishedListener) { - if (!connectionEstablishedListeners.contains(connectionEstablishedListener)) { - connectionEstablishedListeners.add(connectionEstablishedListener); - } + connectionEstablishedListeners.add(connectionEstablishedListener); } /** @@ -878,7 +875,7 @@ public class XMPPConnection { // Do nothing } } - + /** * Initializes the connection by creating a packet reader and writer and opening a * XMPP stream to the server. @@ -1317,14 +1314,14 @@ public class XMPPConnection { this.notify(); } } - /** + /** * Establishes a connection to the XMPP server and performs an automatic login * only if the previous connection state was logged (authenticated). It basically * creates and maintains a socket connection to the server.

- * + * * Listeners will be preserved from a previous connection if the reconnection * occurs after an abrupt termination. - * + * * @throws XMPPException if an error occurs while trying to establish the connection. * Two possible errors can occur which will be wrapped by an XMPPException -- * UnknownHostException (XMPP error code 504), and IOException (XMPP error code @@ -1350,10 +1347,10 @@ public class XMPPConnection { } } } - - /** + + /** * Sets whether the connection has already logged in the server. - * + * * @param wasAuthenticated true if the connection has already been authenticated. */ private void setWasAuthenticated(boolean wasAuthenticated) { diff --git a/source/org/jivesoftware/smack/packet/Packet.java b/source/org/jivesoftware/smack/packet/Packet.java index 2ad24125e..292332e77 100644 --- a/source/org/jivesoftware/smack/packet/Packet.java +++ b/source/org/jivesoftware/smack/packet/Packet.java @@ -43,7 +43,7 @@ public abstract class Packet { /** * Constant used as packetID to indicate that a packet has no id. To indicate that a packet - * has no id set this constant as the packet's id. When the packet is asked for its id the + * has no id set this constant as the packet's id. When the packet is asked for its id the * answer will be null. */ public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE"; @@ -86,7 +86,7 @@ public abstract class Packet { if (ID_NOT_AVAILABLE.equals(packetID)) { return null; } - + if (packetID == null) { packetID = nextID(); } @@ -94,7 +94,7 @@ public abstract class Packet { } /** - * Sets the unique ID of the packet. To indicate that a packet has no id + * Sets the unique ID of the packet. To indicate that a packet has no id * pass the constant ID_NOT_AVAILABLE as the packet's id value. * * @param packetID the unique ID for the packet. @@ -122,8 +122,7 @@ public abstract class Packet { * @param to who the packet is being sent to. */ public void setTo(String to) { - // Use escaped version of the JID in case the user included invalid characters. - this.to = StringUtils.escapeJID(to); + this.to = to; } /** @@ -146,8 +145,7 @@ public abstract class Packet { * @param from who the packet is being sent to. */ public void setFrom(String from) { - // Use escaped version of the JID in case the user included invalid characters. - this.from = StringUtils.escapeJID(from); + this.from = from; } /** diff --git a/source/org/jivesoftware/smack/packet/RosterPacket.java b/source/org/jivesoftware/smack/packet/RosterPacket.java index 32fd72ff1..fff1c9946 100644 --- a/source/org/jivesoftware/smack/packet/RosterPacket.java +++ b/source/org/jivesoftware/smack/packet/RosterPacket.java @@ -198,7 +198,7 @@ public class RosterPacket extends IQ { public String toXML() { StringBuilder buf = new StringBuilder(); - buf.append(" XMPPAddress.length()) { return ""; @@ -127,8 +127,6 @@ public class StringUtils { } } - - /** * Escapes the node portion of a JID according to "JID Escaping" (JEP-0106). * Escaping replaces characters prohibited by node-prep with escape sequences, @@ -168,9 +166,15 @@ public class StringUtils { for (int i=0, n=node.length(); i': buf.append("\\3e"); break; case '@': buf.append("\\40"); break; - + case '\\': buf.append("\\5c"); break; default: { if (Character.isWhitespace(c)) { buf.append("\\20"); @@ -184,43 +188,6 @@ public class StringUtils { return buf.toString(); } - /** - * Escapes a complete JID by examing the Node itself and escaping - * when neccessary. - * @param jid the users JID - * @return the escaped JID. - */ - public static String escapeJID(String jid){ - if(jid == null){ - return null; - } - - final StringBuilder builder = new StringBuilder(); - String node = parseName(jid); - String restOfJID = jid.substring(node.length()); - builder.append(escapeNode(node)); - builder.append(restOfJID); - return builder.toString(); - } - - /** - * Unescapes a complete JID by examing the node itself and unescaping when necessary. - * @param jid the users jid. - * @return the unescaped JID. - */ - public static String unescapeJID(String jid){ - if(jid == null){ - return null; - } - - final StringBuilder builder = new StringBuilder(); - String node = parseName(jid); - String restOfJID = jid.substring(node.length()); - builder.append(unescapeNode(node)); - builder.append(restOfJID); - return builder.toString(); - } - /** * Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).

* Escaping replaces characters prohibited by node-prep with escape sequences, diff --git a/source/org/jivesoftware/smackx/FormField.java b/source/org/jivesoftware/smackx/FormField.java index 2a58c278c..84432914a 100644 --- a/source/org/jivesoftware/smackx/FormField.java +++ b/source/org/jivesoftware/smackx/FormField.java @@ -20,8 +20,6 @@ package org.jivesoftware.smackx; -import org.jivesoftware.smack.util.StringUtils; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -31,7 +29,7 @@ import java.util.List; * Represents a field of a form. The field could be used to represent a question to complete, * a completed question or a data returned from a search. The exact interpretation of the field * depends on the context where the field is used. - * + * * @author Gaston Dombiak */ public class FormField { @@ -55,31 +53,31 @@ public class FormField { private final List values = new ArrayList(); /** - * Creates a new FormField with the variable name that uniquely identifies the field - * in the context of the form. - * + * Creates a new FormField with the variable name that uniquely identifies the field + * in the context of the form. + * * @param variable the variable name of the question. */ public FormField(String variable) { this.variable = variable; } - + /** - * Creates a new FormField of type FIXED. The fields of type FIXED do not define a variable - * name. - * + * Creates a new FormField of type FIXED. The fields of type FIXED do not define a variable + * name. + * */ public FormField() { - this.type = FormField.TYPE_FIXED; + this.type = FormField.TYPE_FIXED; } - + /** * Returns a description that provides extra clarification about the question. This information - * could be presented to the user either in tool-tip, help button, or as a section of text - * before the question.

- * + * could be presented to the user either in tool-tip, help button, or as a section of text + * before the question.

+ * * If the question is of type FIXED then the description should remain empty. - * + * * @return description that provides extra clarification about the question. */ public String getDescription() { @@ -87,9 +85,9 @@ public class FormField { } /** - * Returns the label of the question which should give enough information to the user to + * Returns the label of the question which should give enough information to the user to * fill out the form. - * + * * @return label of the question. */ public String getLabel() { @@ -98,9 +96,9 @@ public class FormField { /** * Returns an Iterator for the available options that the user has in order to answer - * the question. - * - * @return Iterator for the available options. + * the question. + * + * @return Iterator for the available options. */ public Iterator

    *
  • text-single -> single line or word of text - *
  • text-private -> instead of showing the user what they typed, you show ***** to + *
  • text-private -> instead of showing the user what they typed, you show ***** to * protect it *
  • text-multi -> multiple lines of text entry *
  • list-single -> given a list of choices, pick one *
  • list-multi -> given a list of choices, pick one or more *
  • boolean -> 0 or 1, true or false, yes or no. Default value is 0 - *
  • fixed -> fixed for putting in text to show sections, or just advertise your web + *
  • fixed -> fixed for putting in text to show sections, or just advertise your web * site in the middle of the form *
  • hidden -> is not given to the user at all, but returned with the questionnaire - *
  • jid-single -> Jabber ID - choosing a JID from your roster, and entering one based + *
  • jid-single -> Jabber ID - choosing a JID from your roster, and entering one based * on the rules for a JID. *
  • jid-multi -> multiple entries for JIDs *
- * + * * @return format for the data to answer. */ public String getType() { @@ -144,10 +142,10 @@ public class FormField { /** * Returns an Iterator for the default values of the question if the question is part - * of a form to fill out. Otherwise, returns an Iterator for the answered values of - * the question. - * - * @return an Iterator for the default values or answered values of the question. + * of a form to fill out. Otherwise, returns an Iterator for the answered values of + * the question. + * + * @return an Iterator for the default values or answered values of the question. */ public Iterator getValues() { synchronized (values) { @@ -157,7 +155,7 @@ public class FormField { /** * Returns the variable name that the question is filling out. - * + * * @return the variable name of the question. */ public String getVariable() { @@ -166,11 +164,11 @@ public class FormField { /** * Sets a description that provides extra clarification about the question. This information - * could be presented to the user either in tool-tip, help button, or as a section of text - * before the question.

- * + * could be presented to the user either in tool-tip, help button, or as a section of text + * before the question.

+ * * If the question is of type FIXED then the description should remain empty. - * + * * @param description provides extra clarification about the question. */ public void setDescription(String description) { @@ -178,9 +176,9 @@ public class FormField { } /** - * Sets the label of the question which should give enough information to the user to + * Sets the label of the question which should give enough information to the user to * fill out the form. - * + * * @param label the label of the question. */ public void setLabel(String label) { @@ -189,7 +187,7 @@ public class FormField { /** * Sets if the question must be answered in order to complete the questionnaire. - * + * * @param required if the question must be answered in order to complete the questionnaire. */ public void setRequired(boolean required) { @@ -198,23 +196,23 @@ public class FormField { /** * Sets an indicative of the format for the data to answer. Valid formats are: - * + * *

    *
  • text-single -> single line or word of text - *
  • text-private -> instead of showing the user what they typed, you show ***** to + *
  • text-private -> instead of showing the user what they typed, you show ***** to * protect it *
  • text-multi -> multiple lines of text entry *
  • list-single -> given a list of choices, pick one *
  • list-multi -> given a list of choices, pick one or more *
  • boolean -> 0 or 1, true or false, yes or no. Default value is 0 - *
  • fixed -> fixed for putting in text to show sections, or just advertise your web + *
  • fixed -> fixed for putting in text to show sections, or just advertise your web * site in the middle of the form *
  • hidden -> is not given to the user at all, but returned with the questionnaire - *
  • jid-single -> Jabber ID - choosing a JID from your roster, and entering one based + *
  • jid-single -> Jabber ID - choosing a JID from your roster, and entering one based * on the rules for a JID. *
  • jid-multi -> multiple entries for JIDs *
- * + * * @param type an indicative of the format for the data to answer. */ public void setType(String type) { @@ -222,9 +220,9 @@ public class FormField { } /** - * Adds a default value to the question if the question is part of a form to fill out. + * Adds a default value to the question if the question is part of a form to fill out. * Otherwise, adds an answered value to the question. - * + * * @param value a default value or an answered value of the question. */ public void addValue(String value) { @@ -234,9 +232,9 @@ public class FormField { } /** - * Adds a default values to the question if the question is part of a form to fill out. + * Adds a default values to the question if the question is part of a form to fill out. * Otherwise, adds an answered values to the question. - * + * * @param newValues default values or an answered values of the question. */ public void addValues(List newValues) { @@ -254,11 +252,11 @@ public class FormField { values.removeAll(new ArrayList(values)); } } - + /** - * Adss an available options to the question that the user has in order to answer + * Adss an available options to the question that the user has in order to answer * the question. - * + * * @param option a new available option for the question. */ public void addOption(Option option) { @@ -290,7 +288,7 @@ public class FormField { } // Loop through all the values and append them to the string buffer for (Iterator i = getValues(); i.hasNext();) { - buf.append("").append(StringUtils.escapeForXML(i.next())).append(""); + buf.append("").append(i.next()).append(""); } // Loop through all the values and append them to the string buffer for (Iterator i = getOptions(); i.hasNext();) { diff --git a/source/org/jivesoftware/smackx/RemoteRosterEntry.java b/source/org/jivesoftware/smackx/RemoteRosterEntry.java index 8039b4d19..f3c6196f0 100644 --- a/source/org/jivesoftware/smackx/RemoteRosterEntry.java +++ b/source/org/jivesoftware/smackx/RemoteRosterEntry.java @@ -20,15 +20,13 @@ package org.jivesoftware.smackx; -import org.jivesoftware.smack.util.StringUtils; - import java.util.*; /** * Represents a roster item, which consists of a JID and , their name and * the groups the roster item belongs to. This roster item does not belong - * to the local roster. Therefore, it does not persist in the server.

- * + * to the local roster. Therefore, it does not persist in the server.

+ * * The idea of a RemoteRosterEntry is to be used as part of a roster exchange. * * @author Gaston Dombiak @@ -37,7 +35,7 @@ public class RemoteRosterEntry { private String user; private String name; - private List groupNames = new ArrayList(); + private final List groupNames = new ArrayList(); /** * Creates a new remote roster entry. @@ -51,7 +49,7 @@ public class RemoteRosterEntry { this.user = user; this.name = name; if (groups != null) { - groupNames = new ArrayList(Arrays.asList(groups)); + groupNames.addAll(Arrays.asList(groups)); } } @@ -93,23 +91,19 @@ public class RemoteRosterEntry { */ public String[] getGroupArrayNames() { synchronized (groupNames) { - return (String[]) - (Collections - .unmodifiableList(groupNames) - .toArray(new String[groupNames.size()])); + return Collections.unmodifiableList(groupNames).toArray(new String[groupNames.size()]); } } public String toXML() { StringBuilder buf = new StringBuilder(); - buf.append(""); synchronized (groupNames) { - for (int i = 0; i < groupNames.size(); i++) { - String groupName = (String) groupNames.get(i); + for (String groupName : groupNames) { buf.append("").append(groupName).append(""); } } diff --git a/source/org/jivesoftware/smackx/packet/MUCUser.java b/source/org/jivesoftware/smackx/packet/MUCUser.java index 4b89581bc..19a773fc6 100644 --- a/source/org/jivesoftware/smackx/packet/MUCUser.java +++ b/source/org/jivesoftware/smackx/packet/MUCUser.java @@ -21,12 +21,11 @@ package org.jivesoftware.smackx.packet; import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.util.StringUtils; /** - * Represents extended presence information about roles, affiliations, full JIDs, + * Represents extended presence information about roles, affiliations, full JIDs, * or status codes scoped by the 'http://jabber.org/protocol/muc#user' namespace. - * + * * @author Gaston Dombiak */ public class MUCUser implements PacketExtension { @@ -76,7 +75,7 @@ public class MUCUser implements PacketExtension { * Returns the invitation for another user to a room. The sender of the invitation * must be an occupant of the room. The invitation will be sent to the room which in turn * will forward the invitation to the invitee. - * + * * @return an invitation for another user to a room. */ public Invite getInvite() { @@ -84,9 +83,9 @@ public class MUCUser implements PacketExtension { } /** - * Returns the rejection to an invitation from another user to a room. The rejection will be + * Returns the rejection to an invitation from another user to a room. The rejection will be * sent to the room which in turn will forward the refusal to the inviter. - * + * * @return a rejection to an invitation from another user to a room. */ public Decline getDecline() { @@ -95,7 +94,7 @@ public class MUCUser implements PacketExtension { /** * Returns the item child that holds information about roles, affiliation, jids and nicks. - * + * * @return an item child that holds information about roles, affiliation, jids and nicks. */ public Item getItem() { @@ -103,9 +102,9 @@ public class MUCUser implements PacketExtension { } /** - * Returns the password to use to enter Password-Protected Room. A Password-Protected Room is + * Returns the password to use to enter Password-Protected Room. A Password-Protected Room is * a room that a user cannot enter without first providing the correct password. - * + * * @return the password to use to enter Password-Protected Room. */ public String getPassword() { @@ -114,7 +113,7 @@ public class MUCUser implements PacketExtension { /** * Returns the status which holds a code that assists in presenting notification messages. - * + * * @return the status which holds a code that assists in presenting notification messages. */ public Status getStatus() { @@ -123,9 +122,9 @@ public class MUCUser implements PacketExtension { /** * Returns the notification that the room has been destroyed. After a room has been destroyed, - * the room occupants will receive a Presence packet of type 'unavailable' with the reason for + * the room occupants will receive a Presence packet of type 'unavailable' with the reason for * the room destruction if provided by the room owner. - * + * * @return a notification that the room has been destroyed. */ public Destroy getDestroy() { @@ -136,7 +135,7 @@ public class MUCUser implements PacketExtension { * Sets the invitation for another user to a room. The sender of the invitation * must be an occupant of the room. The invitation will be sent to the room which in turn * will forward the invitation to the invitee. - * + * * @param invite the invitation for another user to a room. */ public void setInvite(Invite invite) { @@ -144,9 +143,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the rejection to an invitation from another user to a room. The rejection will be + * Sets the rejection to an invitation from another user to a room. The rejection will be * sent to the room which in turn will forward the refusal to the inviter. - * + * * @param decline the rejection to an invitation from another user to a room. */ public void setDecline(Decline decline) { @@ -155,7 +154,7 @@ public class MUCUser implements PacketExtension { /** * Sets the item child that holds information about roles, affiliation, jids and nicks. - * + * * @param item the item child that holds information about roles, affiliation, jids and nicks. */ public void setItem(Item item) { @@ -163,9 +162,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the password to use to enter Password-Protected Room. A Password-Protected Room is + * Sets the password to use to enter Password-Protected Room. A Password-Protected Room is * a room that a user cannot enter without first providing the correct password. - * + * * @param string the password to use to enter Password-Protected Room. */ public void setPassword(String string) { @@ -174,8 +173,8 @@ public class MUCUser implements PacketExtension { /** * Sets the status which holds a code that assists in presenting notification messages. - * - * @param status the status which holds a code that assists in presenting notification + * + * @param status the status which holds a code that assists in presenting notification * messages. */ public void setStatus(Status status) { @@ -184,9 +183,9 @@ public class MUCUser implements PacketExtension { /** * Sets the notification that the room has been destroyed. After a room has been destroyed, - * the room occupants will receive a Presence packet of type 'unavailable' with the reason for + * the room occupants will receive a Presence packet of type 'unavailable' with the reason for * the room destruction if provided by the room owner. - * + * * @param destroy the notification that the room has been destroyed. */ public void setDestroy(Destroy destroy) { @@ -196,7 +195,7 @@ public class MUCUser implements PacketExtension { /** * Represents an invitation for another user to a room. The sender of the invitation * must be an occupant of the room. The invitation will be sent to the room which in turn - * will forward the invitation to the invitee. + * will forward the invitation to the invitee. * * @author Gaston Dombiak */ @@ -206,9 +205,9 @@ public class MUCUser implements PacketExtension { private String to; /** - * Returns the bare JID of the inviter or, optionally, the room JID. (e.g. - * 'crone1@shakespeare.lit/desktop'). - * + * Returns the bare JID of the inviter or, optionally, the room JID. (e.g. + * 'crone1@shakespeare.lit/desktop'). + * * @return the room's occupant that sent the invitation. */ public String getFrom() { @@ -217,7 +216,7 @@ public class MUCUser implements PacketExtension { /** * Returns the message explaining the invitation. - * + * * @return the message explaining the invitation. */ public String getReason() { @@ -226,7 +225,7 @@ public class MUCUser implements PacketExtension { /** * Returns the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit') - * + * * @return the bare JID of the invitee. */ public String getTo() { @@ -234,9 +233,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the bare JID of the inviter or, optionally, the room JID. (e.g. + * Sets the bare JID of the inviter or, optionally, the room JID. (e.g. * 'crone1@shakespeare.lit/desktop') - * + * * @param from the bare JID of the inviter or, optionally, the room JID. */ public void setFrom(String from) { @@ -245,7 +244,7 @@ public class MUCUser implements PacketExtension { /** * Sets the message explaining the invitation. - * + * * @param reason the message explaining the invitation. */ public void setReason(String reason) { @@ -254,7 +253,7 @@ public class MUCUser implements PacketExtension { /** * Sets the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit') - * + * * @param to the bare JID of the invitee. */ public void setTo(String to) { @@ -277,11 +276,11 @@ public class MUCUser implements PacketExtension { buf.append(""); return buf.toString(); } - }; + } /** - * Represents a rejection to an invitation from another user to a room. The rejection will be - * sent to the room which in turn will forward the refusal to the inviter. + * Represents a rejection to an invitation from another user to a room. The rejection will be + * sent to the room which in turn will forward the refusal to the inviter. * * @author Gaston Dombiak */ @@ -291,9 +290,9 @@ public class MUCUser implements PacketExtension { private String to; /** - * Returns the bare JID of the invitee that rejected the invitation. (e.g. - * 'crone1@shakespeare.lit/desktop'). - * + * Returns the bare JID of the invitee that rejected the invitation. (e.g. + * 'crone1@shakespeare.lit/desktop'). + * * @return the bare JID of the invitee that rejected the invitation. */ public String getFrom() { @@ -302,7 +301,7 @@ public class MUCUser implements PacketExtension { /** * Returns the message explaining why the invitation was rejected. - * + * * @return the message explaining the reason for the rejection. */ public String getReason() { @@ -311,7 +310,7 @@ public class MUCUser implements PacketExtension { /** * Returns the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit') - * + * * @return the bare JID of the inviter. */ public String getTo() { @@ -319,9 +318,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the bare JID of the invitee that rejected the invitation. (e.g. - * 'crone1@shakespeare.lit/desktop'). - * + * Sets the bare JID of the invitee that rejected the invitation. (e.g. + * 'crone1@shakespeare.lit/desktop'). + * * @param from the bare JID of the invitee that rejected the invitation. */ public void setFrom(String from) { @@ -330,7 +329,7 @@ public class MUCUser implements PacketExtension { /** * Sets the message explaining why the invitation was rejected. - * + * * @param reason the message explaining the reason for the rejection. */ public void setReason(String reason) { @@ -339,7 +338,7 @@ public class MUCUser implements PacketExtension { /** * Sets the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit') - * + * * @param to the bare JID of the inviter. */ public void setTo(String to) { @@ -362,7 +361,7 @@ public class MUCUser implements PacketExtension { buf.append(""); return buf.toString(); } - }; + } /** * Item child that holds information about roles, affiliation, jids and nicks. @@ -378,8 +377,8 @@ public class MUCUser implements PacketExtension { private String role; /** - * Creates a new item child. - * + * Creates a new item child. + * * @param affiliation the actor's affiliation to the room * @param role the privilege level of an occupant within a room. */ @@ -390,7 +389,7 @@ public class MUCUser implements PacketExtension { /** * Returns the actor (JID of an occupant in the room) that was kicked or banned. - * + * * @return the JID of an occupant in the room that was kicked or banned. */ public String getActor() { @@ -400,7 +399,7 @@ public class MUCUser implements PacketExtension { /** * Returns the reason for the item child. The reason is optional and could be used to * explain the reason why a user (occupant) was kicked or banned. - * + * * @return the reason for the item child. */ public String getReason() { @@ -408,11 +407,11 @@ public class MUCUser implements PacketExtension { } /** - * Returns the occupant's affiliation to the room. The affiliation is a semi-permanent - * association or connection with a room. The possible affiliations are "owner", "admin", - * "member", and "outcast" (naturally it is also possible to have no affiliation). An + * Returns the occupant's affiliation to the room. The affiliation is a semi-permanent + * association or connection with a room. The possible affiliations are "owner", "admin", + * "member", and "outcast" (naturally it is also possible to have no affiliation). An * affiliation lasts across a user's visits to a room. - * + * * @return the actor's affiliation to the room */ public String getAffiliation() { @@ -420,9 +419,9 @@ public class MUCUser implements PacketExtension { } /** - * Returns the by which an occupant is identified within the context - * of a room. If the room is non-anonymous, the JID will be included in the item. - * + * Returns the by which an occupant is identified within the context + * of a room. If the room is non-anonymous, the JID will be included in the item. + * * @return the room JID by which an occupant is identified within the room. */ public String getJid() { @@ -430,9 +429,9 @@ public class MUCUser implements PacketExtension { } /** - * Returns the new nickname of an occupant that is changing his/her nickname. The new - * nickname is sent as part of the unavailable presence. - * + * Returns the new nickname of an occupant that is changing his/her nickname. The new + * nickname is sent as part of the unavailable presence. + * * @return the new nickname of an occupant that is changing his/her nickname. */ public String getNick() { @@ -440,11 +439,11 @@ public class MUCUser implements PacketExtension { } /** - * Returns the temporary position or privilege level of an occupant within a room. The - * possible roles are "moderator", "participant", and "visitor" (it is also possible to - * have no defined role). A role lasts only for the duration of an occupant's visit to - * a room. - * + * Returns the temporary position or privilege level of an occupant within a room. The + * possible roles are "moderator", "participant", and "visitor" (it is also possible to + * have no defined role). A role lasts only for the duration of an occupant's visit to + * a room. + * * @return the privilege level of an occupant within a room. */ public String getRole() { @@ -453,7 +452,7 @@ public class MUCUser implements PacketExtension { /** * Sets the actor (JID of an occupant in the room) that was kicked or banned. - * + * * @param actor the actor (JID of an occupant in the room) that was kicked or banned. */ public void setActor(String actor) { @@ -463,7 +462,7 @@ public class MUCUser implements PacketExtension { /** * Sets the reason for the item child. The reason is optional and could be used to * explain the reason why a user (occupant) was kicked or banned. - * + * * @param reason the reason why a user (occupant) was kicked or banned. */ public void setReason(String reason) { @@ -471,9 +470,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the by which an occupant is identified within the context + * Sets the by which an occupant is identified within the context * of a room. If the room is non-anonymous, the JID will be included in the item. - * + * * @param jid the JID by which an occupant is identified within a room. */ public void setJid(String jid) { @@ -481,9 +480,9 @@ public class MUCUser implements PacketExtension { } /** - * Sets the new nickname of an occupant that is changing his/her nickname. The new + * Sets the new nickname of an occupant that is changing his/her nickname. The new * nickname is sent as part of the unavailable presence. - * + * * @param nick the new nickname of an occupant that is changing his/her nickname. */ public void setNick(String nick) { @@ -497,7 +496,7 @@ public class MUCUser implements PacketExtension { buf.append(" affiliation=\"").append(getAffiliation()).append("\""); } if (getJid() != null) { - buf.append(" jid=\"").append(StringUtils.escapeJID(getJid())).append("\""); + buf.append(" jid=\"").append(getJid()).append("\""); } if (getNick() != null) { buf.append(" nick=\"").append(getNick()).append("\""); @@ -514,16 +513,16 @@ public class MUCUser implements PacketExtension { buf.append("").append(getReason()).append(""); } if (getActor() != null) { - buf.append(""); + buf.append(""); } buf.append(""); } return buf.toString(); } - }; + } /** - * Status code assists in presenting notification messages. The following link provides the + * Status code assists in presenting notification messages. The following link provides the * list of existing error codes (@link http://www.jabber.org/jeps/jep-0045.html#errorstatus). * * @author Gaston Dombiak @@ -532,8 +531,8 @@ public class MUCUser implements PacketExtension { private String code; /** - * Creates a new instance of Status with the specified code. - * + * Creates a new instance of Status with the specified code. + * * @param code the code that uniquely identifies the reason of the error. */ public Status(String code) { @@ -541,9 +540,9 @@ public class MUCUser implements PacketExtension { } /** - * Returns the code that uniquely identifies the reason of the error. The code - * assists in presenting notification messages. - * + * Returns the code that uniquely identifies the reason of the error. The code + * assists in presenting notification messages. + * * @return the code that uniquely identifies the reason of the error. */ public String getCode() { @@ -555,13 +554,13 @@ public class MUCUser implements PacketExtension { buf.append(""); return buf.toString(); } - }; + } /** * Represents a notification that the room has been destroyed. After a room has been destroyed, - * the room occupants will receive a Presence packet of type 'unavailable' with the reason for - * the room destruction if provided by the room owner. - * + * the room occupants will receive a Presence packet of type 'unavailable' with the reason for + * the room destruction if provided by the room owner. + * * @author Gaston Dombiak */ public static class Destroy { @@ -571,7 +570,7 @@ public class MUCUser implements PacketExtension { /** * Returns the JID of an alternate location since the current room is being destroyed. - * + * * @return the JID of an alternate location. */ public String getJid() { @@ -580,7 +579,7 @@ public class MUCUser implements PacketExtension { /** * Returns the reason for the room destruction. - * + * * @return the reason for the room destruction. */ public String getReason() { @@ -589,7 +588,7 @@ public class MUCUser implements PacketExtension { /** * Sets the JID of an alternate location since the current room is being destroyed. - * + * * @param jid the JID of an alternate location. */ public void setJid(String jid) { @@ -598,7 +597,7 @@ public class MUCUser implements PacketExtension { /** * Sets the reason for the room destruction. - * + * * @param reason the reason for the room destruction. */ public void setReason(String reason) { @@ -609,7 +608,7 @@ public class MUCUser implements PacketExtension { StringBuilder buf = new StringBuilder(); buf.append(""); diff --git a/source/org/jivesoftware/smackx/search/UserSearchManager.java b/source/org/jivesoftware/smackx/search/UserSearchManager.java index 9358d1fe5..db034c8e9 100644 --- a/source/org/jivesoftware/smackx/search/UserSearchManager.java +++ b/source/org/jivesoftware/smackx/search/UserSearchManager.java @@ -91,11 +91,11 @@ public class UserSearchManager { final List searchServices = new ArrayList(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); DiscoverItems items = discoManager.discoverItems(con.getServiceName()); - Iterator iter = items.getItems(); + Iterator iter = items.getItems(); while (iter.hasNext()) { - DiscoverItems.Item item = (DiscoverItems.Item) iter.next(); + DiscoverItems.Item item = iter.next(); try { - DiscoverInfo info = null; + DiscoverInfo info; try { info = discoManager.discoverInfo(item.getEntityID()); }