If you think the Android project sms-smap-gateway listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.android.smap.models;
/*fromwww.java2s.com*/import java.util.Date;
/**
* Possible model for text messages. Nothing set in stone. Borrowed from another
* Implementation.
*
*
*/publicclass TextMessage {
/** the message is incoming */publicstaticfinalchar INCOMING = 'I';
/** the message is outgoing */publicstaticfinalchar OUTGOING = 'O';
/** indicates the message is received, but needs to be handled */publicstaticfinalchar RECEIVED = 'R';
/** the message has been handled, that is delivered to the server */publicstaticfinalchar HANDLED = 'H';
/** we ignored this message */publicstaticfinalchar IGNORED = 'I';
/**
* we've told android to send it, but haven't got a confirmation that it has
* happened yet
*/publicstaticfinalchar QUEUED = 'Q';
/**
* we tried to send it (either to the server or to android) but got an error
*/publicstaticfinalchar ERRORED = 'E';
/** android told us it's on its way */publicstaticfinalchar SENT = 'S';
/**
* the handling for this message is complete, the server was notified it was
* sent
*/publicstaticfinalchar DONE = 'D';
public TextMessage() {}
public TextMessage(String number, String text, long serverId) {
this.number = number;
this.text = text;
this.created = new Date();
this.direction = OUTGOING;
this.status = QUEUED;
this.serverId = serverId;
}
public TextMessage respond(String number, String text) {
TextMessage msg = new TextMessage();
msg.number = number;
msg.text = text;
msg.created = new Date();
msg.direction = OUTGOING;
msg.status = QUEUED;
return msg;
}
public String getStatusText() {
switch (status) {
case RECEIVED:
return"Received";
case HANDLED:
return"Complete";
case IGNORED:
return"Ignored";
case QUEUED:
return"Queued";
case ERRORED:
if (direction == OUTGOING) {
return"Send Error";
} else {
return"Server Error";
}
case SENT:
return"Sent";
case DONE:
return"Complete";
default:
return"--";
}
}
publicboolean equals(Object other) {
if (other instanceof TextMessage) {
return ((TextMessage) other).id == this.id;
} else {
return false;
}
}
publiclong id;
public String number;
public String text;
public String error;
public Date created;
publicchar direction;
publicchar status;
publiclong serverId;
}