From 4d7e4b2ab1243111ee286d9707fd7c8905bbc0c8 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 24 Jul 2016 21:21:21 +0200 Subject: [PATCH] Add Message(String, String) constructor to make simply Smack examples work, e.g. Message message = new Message("user@example.org", "Hi, how are you?"); --- .../java/org/jivesoftware/smack/packet/Message.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java index 17d1d3f23..2a6321e1e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java @@ -27,6 +27,8 @@ import java.util.Set; import org.jivesoftware.smack.util.TypedCloneable; import org.jivesoftware.smack.util.XmlStringBuilder; import org.jxmpp.jid.Jid; +import org.jxmpp.jid.impl.JidCreate; +import org.jxmpp.stringprep.XmppStringprepException; /** * Represents XMPP message packets. A message can be one of several types: @@ -101,6 +103,17 @@ public final class Message extends Stanza implements TypedCloneable { setBody(body); } + /** + * Creates a new message to the specified recipient and with the specified body. + * + * @param to the user to send the message to. + * @param body the body of the message. + * @throws XmppStringprepException if 'to' is not a valid XMPP address. + */ + public Message(String to, String body) throws XmppStringprepException { + this(JidCreate.from(to), body); + } + /** * Copy constructor. *