mirror of
https://gitee.com/farsunset/cim.git
synced 2025-07-13 03:49:06 +08:00
Update Message.java
This commit is contained in:
parent
0d33050eda
commit
eb174b1d9f
@ -1,204 +1,204 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-server-sdk
|
* probject:cim-server-sdk
|
||||||
* @version 2.0.0
|
* @version 2.0.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
package com.farsunset.cim.sdk.server.model;
|
package com.farsunset.cim.sdk.server.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
/**
|
/**
|
||||||
* 消息对象
|
* 消息对象
|
||||||
*/
|
*/
|
||||||
public class Message implements Serializable {
|
public class Message implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息类型,用户自定义消息类别
|
* 消息类型,用户自定义消息类别
|
||||||
*/
|
*/
|
||||||
private String mid;
|
private String mid;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息类型,用户自定义消息类别
|
* 消息类型,用户自定义消息类别
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String type;
|
||||||
/**
|
/**
|
||||||
* 消息标题
|
* 消息标题
|
||||||
*/
|
*/
|
||||||
private String title;
|
private String title;
|
||||||
/**
|
/**
|
||||||
* 消息类容,于type 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式
|
* 消息类容,于type 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式
|
||||||
*/
|
*/
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息发送者账号
|
* 消息发送者账号
|
||||||
*/
|
*/
|
||||||
private String sender;
|
private String sender;
|
||||||
/**
|
/**
|
||||||
* 消息发送者接收者
|
* 消息发送者接收者
|
||||||
*/
|
*/
|
||||||
private String receiver;
|
private String receiver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件 url
|
* 文件 url
|
||||||
*/
|
*/
|
||||||
private String file;
|
private String file;
|
||||||
/**
|
/**
|
||||||
* 文件类型
|
* 文件类型
|
||||||
*/
|
*/
|
||||||
private String fileType;
|
private String fileType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* content 内容格式
|
* content 内容格式
|
||||||
*/
|
*/
|
||||||
private String format = "txt";
|
private String format = "txt";
|
||||||
|
|
||||||
|
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
||||||
|
|
||||||
public Message()
|
public Message()
|
||||||
{
|
{
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimestamp(long timestamp) {
|
public void setTimestamp(long timestamp) {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContent() {
|
public String getContent() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContent(String content) {
|
public void setContent(String content) {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSender() {
|
public String getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSender(String sender) {
|
public void setSender(String sender) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReceiver() {
|
public String getReceiver() {
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReceiver(String receiver) {
|
public void setReceiver(String receiver) {
|
||||||
this.receiver = receiver;
|
this.receiver = receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile() {
|
public String getFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFile(String file) {
|
public void setFile(String file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileType() {
|
public String getFileType() {
|
||||||
return fileType;
|
return fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileType(String fileType) {
|
public void setFileType(String fileType) {
|
||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormat() {
|
public String getFormat() {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFormat(String format) {
|
public void setFormat(String format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
buffer.append("<message>");
|
buffer.append("<message>");
|
||||||
buffer.append("<mid>").append(mid).append("</mid>");
|
buffer.append("<mid>").append(mid).append("</mid>");
|
||||||
|
|
||||||
if (isNotEmpty(type)) {
|
if (isNotEmpty(type)) {
|
||||||
buffer.append("<type>").append(type).append("</type>");
|
buffer.append("<type>").append(type).append("</type>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(title)) {
|
if (isNotEmpty(title)) {
|
||||||
buffer.append("<title>").append(title).append("</title>");
|
buffer.append("<title>").append(title).append("</title>");
|
||||||
}
|
}
|
||||||
if (isNotEmpty(content)) {
|
if (isNotEmpty(content)) {
|
||||||
buffer.append("<content><![CDATA[").append(content).append("]]></content>");
|
buffer.append("<content><![CDATA[").append(content).append("]]></content>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(file)) {
|
if (isNotEmpty(file)) {
|
||||||
buffer.append("<file>").append(file).append("</file>");
|
buffer.append("<file>").append(file).append("</file>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(fileType)) {
|
if (isNotEmpty(fileType)) {
|
||||||
buffer.append("<fileType>").append(fileType).append("</fileType>");
|
buffer.append("<fileType>").append(fileType).append("</fileType>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(sender)) {
|
if (isNotEmpty(sender)) {
|
||||||
buffer.append("<sender>").append(sender).append("</sender>");
|
buffer.append("<sender>").append(sender).append("</sender>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(receiver)) {
|
if (isNotEmpty(receiver)) {
|
||||||
buffer.append("<receiver>").append(receiver).append("</receiver>");
|
buffer.append("<receiver>").append(receiver).append("</receiver>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(format)) {
|
if (isNotEmpty(format)) {
|
||||||
buffer.append("<format>").append(format).append("</format>");
|
buffer.append("<format>").append(format).append("</format>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timestamp > 0) {
|
if (timestamp > 0) {
|
||||||
buffer.append("<timestamp>").append(timestamp).append("</timestamp>");
|
buffer.append("<timestamp>").append(timestamp).append("</timestamp>");
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.append("</message>");
|
buffer.append("</message>");
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXmlString() {
|
public String toXmlString() {
|
||||||
|
|
||||||
return toString();
|
return toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMid() {
|
public String getMid() {
|
||||||
return mid;
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMid(String mid) {
|
public void setMid(String mid) {
|
||||||
this.mid = mid;
|
this.mid = mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotEmpty(String txt) {
|
public boolean isNotEmpty(String txt) {
|
||||||
return txt != null && !txt.isEmpty();
|
return txt != null && txt.trim().length()>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user