package com.nms.server.thread.netty;

import java.io.File;

public class Message {
	
	private int messageType;//消息类型
	private BusinessType businessType;//业务类型
	private int length;//消息长度
	private File file;//消息保存的文件
	private String fileName;
	private byte[] data;
	
	public Message(int length,int messageType ,BusinessType type) {
		this.length = length;
		this.businessType = type;
		this.messageType = messageType;
	}
	public BusinessType getBusinessType() {
		return businessType;
	}

	public void setBusinessType(BusinessType type) {
		this.businessType = type;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
		this.length = (int)file.length();
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
		this.length = data.length;
	}

	public int getMessageType() {
		return messageType;
	}
	public void setMessageType(int messageType) {
		this.messageType = messageType;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("messageType : ");
		sb.append(messageType);
		sb.append(",BusinessType : ");
		sb.append(businessType);
		sb.append(",length : ");
		sb.append(length);
		if(file != null){
			sb.append(",tempFile:");
			sb.append(file.getAbsolutePath());
		}else{
			sb.append(",content : ");
			sb.append(new String(data));
		}
		return sb.toString();
	}

}
