Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pt.uc.dei.proj3.common;
- import java.io.Serializable;
- import java.util.GregorianCalendar;
- import javax.xml.bind.annotation.XmlRootElement;
- /**
- * POJO mensagem, que contem um rementente data de envio e conteudo.
- * Nota: As mensagens sรณ "existem" associadas a um chat
- */
- @XmlRootElement
- public class Mensagem implements Serializable{
- /**
- *
- */
- private static final long serialVersionUID = -3570514059296199504L;
- private static int idGerado;
- private int id;
- private Utilizador remetente;
- private GregorianCalendar dataEnvio;
- private String texto;
- /****CONSTRUTORES****/
- public Mensagem() {}
- public Mensagem(Utilizador remetente, String texto) {
- idGerado++;
- this.id=idGerado;
- this.remetente=remetente;
- this.dataEnvio=new GregorianCalendar();
- this.texto=texto;
- }
- public Mensagem(int id, Utilizador remetente, GregorianCalendar dataEnvio, String texto) {
- this.id=id;
- this.remetente=remetente;
- this.dataEnvio=dataEnvio;
- this.texto=texto;
- if (idGerado < id) {
- idGerado=id;
- }
- }
- /****METODOS PUBLICOS****/
- /**
- * Devolve a hora de envio da mensagem com o formato hh:mm
- * @return String com a hora da mensagem
- */
- public String horaMensagem() {
- return String.format("%tR", dataEnvio);
- }
- /**
- * Devolve o dia de envio da mensagem com o formato yyyy-mm-dd
- * @return String com o dia da mensagem
- */
- public String diaMensagem() {
- return String.format("%tF", dataEnvio);
- }
- /****GETTERS E SETTERS****/
- /**
- * @return the idGerado
- */
- public static int getIdGerado() {
- return idGerado;
- }
- /**
- * @param idGerado the idGerado to set
- */
- public static void setIdGerado(int idGerado) {
- Mensagem.idGerado = idGerado;
- }
- /**
- * @return the id
- */
- public int getId() {
- return id;
- }
- /**
- * @param id the id to set
- */
- public void setId(int id) {
- this.id = id;
- }
- /**
- * @return the remetente
- */
- public Utilizador getRemetente() {
- return remetente;
- }
- /**
- * @param remetente the remetente to set
- */
- public void setRemetente(Utilizador remetente) {
- this.remetente = remetente;
- }
- /**
- * @return the dataEnvio
- */
- public GregorianCalendar getDataEnvio() {
- return dataEnvio;
- }
- /**
- * @param dataEnvio the dataEnvio to set
- */
- public void setDataEnvio(GregorianCalendar dataEnvio) {
- this.dataEnvio = dataEnvio;
- }
- /**
- * @return the texto
- */
- public String getTexto() {
- return texto;
- }
- /**
- * @param texto the texto to set
- */
- public void setTexto(String texto) {
- this.texto = texto;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement