package cn.hmsoft.weixin.entity.reply;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import cn.hmsoft.weixin.entity.reply.item.News;

@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class NewsReply  extends WeiXinReply{
	@XmlJavaTypeAdapter(value = CDATAdapter.class)
	private String ToUserName; // 接收者微信号
	@XmlJavaTypeAdapter(value = CDATAdapter.class)
	private String FromUserName; // 发送者微信号
	private Long CreateTime; // 消息创建时间
	@XmlJavaTypeAdapter(value = CDATAdapter.class)
	private String MsgType = "news"; // 消息类型

	private Integer ArticleCount;
	
	@XmlElementWrapper(name="Articles")
	@XmlElement(name = "item")
	private List<News> Articles;

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUserName) {
		ToUserName = toUserName;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}

	public Long getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Long createTime) {
		CreateTime = createTime;
	}

	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		MsgType = msgType;
	}

	public Integer getArticleCount() {
		return ArticleCount;
	}

	public void setArticleCount(Integer articleCount) {
		ArticleCount = articleCount;
	}

	public List<News> getArticles() {
		return Articles;
	}

	public void setArticles(List<News> articles) {
		Articles = articles;
		this.ArticleCount = this.Articles == null ? 0 : this.Articles.size();
	}

	public void AddNews(News news) {
		if (this.Articles == null)
			this.Articles = new ArrayList<News>();
		this.Articles.add(news);
		this.ArticleCount = this.Articles.size();
	}

}
