mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Removed extra fields.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1784 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
b6ca505170
commit
6696541c43
1 changed files with 15 additions and 56 deletions
|
@ -86,8 +86,6 @@ public class Message extends Packet {
|
||||||
public static final Type HEADLINE = new Type("headline");
|
public static final Type HEADLINE = new Type("headline");
|
||||||
public static final Type ERROR = new Type("error");
|
public static final Type ERROR = new Type("error");
|
||||||
|
|
||||||
private String sender = null;
|
|
||||||
private String recipient = null;
|
|
||||||
private Type type = NORMAL;
|
private Type type = NORMAL;
|
||||||
private String subject = null;
|
private String subject = null;
|
||||||
private String body = null;
|
private String body = null;
|
||||||
|
@ -103,65 +101,26 @@ public class Message extends Packet {
|
||||||
/**
|
/**
|
||||||
* Creates a new "normal" message to the specified recipient.
|
* Creates a new "normal" message to the specified recipient.
|
||||||
*
|
*
|
||||||
* @param recipient the recipient of the message.
|
* @param to the recipient of the message.
|
||||||
*/
|
*/
|
||||||
public Message(String recipient) {
|
public Message(String to) {
|
||||||
this.recipient = recipient;
|
setTo(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new message of the specified type to a recipient.
|
* Creates a new message of the specified type to a recipient.
|
||||||
*
|
*
|
||||||
* @param recipient the user to send the message to.
|
* @param to the user to send the message to.
|
||||||
* @param type the message type.
|
* @param type the message type.
|
||||||
*/
|
*/
|
||||||
public Message(String recipient, Type type) {
|
public Message(String to, Type type) {
|
||||||
if (recipient == null || type == null) {
|
if (to == null || type == null) {
|
||||||
throw new IllegalArgumentException("Parameters cannot be null.");
|
throw new IllegalArgumentException("Parameters cannot be null.");
|
||||||
}
|
}
|
||||||
this.recipient = recipient;
|
setTo(to);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the sender of the message, or null if the sender has not been set.
|
|
||||||
*
|
|
||||||
* @return the sender of the message.
|
|
||||||
*/
|
|
||||||
public String getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the sender of the message.
|
|
||||||
*
|
|
||||||
* @param sender the sender of the message.
|
|
||||||
*/
|
|
||||||
public void setSender(String sender) {
|
|
||||||
this.sender = sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the recipient of the message, or null if the recipient has not been set.
|
|
||||||
*
|
|
||||||
* @return the recipient of the message.
|
|
||||||
*/
|
|
||||||
public String getRecipient() {
|
|
||||||
return recipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the recipient of the message.
|
|
||||||
*
|
|
||||||
* @param recipient the recipient of the message.
|
|
||||||
*/
|
|
||||||
public void setRecipient(String recipient) {
|
|
||||||
if (recipient == null) {
|
|
||||||
throw new IllegalArgumentException("Recipient cannot be null.");
|
|
||||||
}
|
|
||||||
this.recipient = recipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the message.
|
* Returns the type of the message.
|
||||||
*
|
*
|
||||||
|
@ -250,11 +209,11 @@ public class Message extends Packet {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
buf.append("<message");
|
buf.append("<message");
|
||||||
buf.append(" id=\"").append(getPacketID()).append("\"");
|
buf.append(" id=\"").append(getPacketID()).append("\"");
|
||||||
if (recipient != null) {
|
if (getTo() != null) {
|
||||||
buf.append(" to=\"").append(recipient).append("\"");
|
buf.append(" to=\"").append(getTo()).append("\"");
|
||||||
}
|
}
|
||||||
if (sender != null) {
|
if (getFrom() != null) {
|
||||||
buf.append(" from=\"").append(sender).append("\"");
|
buf.append(" from=\"").append(getFrom()).append("\"");
|
||||||
}
|
}
|
||||||
if (type != NORMAL) {
|
if (type != NORMAL) {
|
||||||
buf.append(" type=\"").append(type).append("\"");
|
buf.append(" type=\"").append(type).append("\"");
|
||||||
|
@ -290,16 +249,16 @@ public class Message extends Packet {
|
||||||
public static class Type {
|
public static class Type {
|
||||||
|
|
||||||
public static Type fromString(String type) {
|
public static Type fromString(String type) {
|
||||||
if (type.equals(CHAT.toString())) {
|
if (CHAT.toString().equals(type)) {
|
||||||
return CHAT;
|
return CHAT;
|
||||||
}
|
}
|
||||||
else if (type.equals(GROUP_CHAT.toString())) {
|
else if (GROUP_CHAT.toString().equals(type)) {
|
||||||
return GROUP_CHAT;
|
return GROUP_CHAT;
|
||||||
}
|
}
|
||||||
else if (type.equals(HEADLINE.toString())) {
|
else if (HEADLINE.toString().equals(type)) {
|
||||||
return HEADLINE;
|
return HEADLINE;
|
||||||
}
|
}
|
||||||
else if (type.equals(ERROR.toString())) {
|
else if (ERROR.toString().equals(type)) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue