import java.util.*; // For Date

public class UBMessage {
	public static final int MESSAGE_UNREAD = 1;
	public static final int MESSAGE_READ = 2;
	public static final int MESSAGE_DELETED = 4;

	private UBUser author;
	private UBUser recipient;
	private String text;
	private Date time;
	private int status; // could also be a boolean[], depending on if you want multi-state status.
	
	// Constructor for creating a new message (sending)
	public UBMessage(UBUser author, UBUser recipient, String text) {
		this.author = author;
		this.recipient = recipient;
		this.text = text;
		this.time = new Date();
		this.status = MESSAGE_UNREAD;
	}

	// Constructor for loading stored messages
	public UBMessage(UBUser author, UBUser recipient, String text, Date time, int status) {
		this.author = author;
		this.recipient = recipient;
		this.text = text;
		this.time = time;
		this.status = status;
	}
	
	public UBUser getAuthor() {
		return author;
	}
	
	public UBUser getRecipient() {
		return recipient;
	}
	
	public String getText() {
		return text;
	}
	
	public Date getDate() {
		return time;
	}
	
	public boolean isRead() {
		return (status == MESSAGE_READ);
	}

	public int getStatus() {
		return status;
	}
	
	public void setStatus(int status) {
		this.status = status;
	}
	
	public void deleteMessage() {
		status = MESSAGE_DELETED;
	}
}