package com.safemobile.libpad; import java.io.Serializable; import java.util.ArrayList; import com.safemobile.lib.SM; public class PadTextMessage implements Serializable { private static final long serialVersionUID = 1L; public long dbID = 0; public int userID = 0; public long radioID = 0; public String message = ""; public boolean isOutgoing = false; public long timeGMT = 0; public int status = 0; public String seqID = ""; public Integer tmSeqID = 0; public PadTextMessage() { } public PadTextMessage(long dbID, int usedID, long radioId, boolean isOutgoing, String msg, long timeGMT, int status, String seqID) { this.dbID = dbID; this.userID = usedID; this.radioID = radioId; this.isOutgoing = isOutgoing; this.message = msg; this.timeGMT = timeGMT; this.status = status; this.seqID = seqID; } public String toString() { return dbID + "." + radioID + "[" + message + "]"; } public static ArrayList parseTCPMsg(String msg) { ArrayList messages = new ArrayList(); try { msg = msg.replace("#", ""); // split payload to get contacts // split contact by / String[] contArr = msg.split("/"); PadTextMessage message = new PadTextMessage(); message.dbID = Integer.parseInt(contArr[0]); message.userID = Integer.parseInt(contArr[1]); message.radioID = Long.parseLong(contArr[2]); message.message = contArr[3]; message.timeGMT = Long.parseLong(contArr[4]); message.isOutgoing = (Integer.parseInt(contArr[5]) == 1 ? true: false); message.status = Integer.parseInt(contArr[6]); messages.add(message); } catch(Exception ex) { SM.Exception("Exception parse Message", ex.toString()); } return messages; } }