1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| package com.daedric.dmess.message;
import java.io.Serializable;
import javax.swing.ImageIcon;
import com.daedric.swing.text.TextStylizer;
public class Message implements Requestable, Serializable {
private static final long serialVersionUID = -1061459363120194710L;
private TextStylizer doc = null;
private ImageIcon[] img = null;
private String dest = null;
private String emetteur = null;
private MessageType type = null;
private MessengerAction mac = null;
private Object arg = null;
public <T extends Serializable> Message(MessageType t, MessengerAction ac,
T arg, String emetteur) {
this(t, ac, arg, null, emetteur, null, new ImageIcon[0]);
}
public <T extends Serializable, K extends TextStylizer> Message(
MessageType t, String dest, String emetteur, K doc,
ImageIcon... img) {
this(t, null, null, dest, emetteur, doc, img);
}
public <T extends Serializable, K extends TextStylizer> Message(
MessageType t, MessengerAction ac, T arg, String dest,
String emetteur, K doc, ImageIcon... img) {
this.dest = dest;
this.arg = arg;
this.emetteur = emetteur;
this.doc = doc;
this.img = img;
this.type = t;
this.mac = ac;
if (this.type == null || this.emetteur == null)
throw new NullPointerException("arguments null : type ="
+ this.type + "\nemetteur =" + this.emetteur);
}
public TextStylizer getDoc() {
return doc;
}
public ImageIcon[] getImg() {
return img;
}
public String getDest() {
return dest;
}
public String getEmetteur() {
return emetteur;
}
public MessageType getMessageType() {
return type;
}
public <T extends Serializable> T getArg() {
return (T) arg;
}
public MessengerAction getMessageAction() {
return mac;
}
public String toString() {
return "emetteur = " + this.getEmetteur() + "\ndestinataire = "
+ this.getDest() + "\nMessageType = " + this.getMessageType()
+ "\nMessageAction = " + this.getMessageAction() + "\narg = "
+ this.getArg();
}
} |
Partager