⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 friendmessageexporter.java

📁 用java实现的
💻 JAVA
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.widgets;

import java.text.DateFormat;
import java.util.Date;

import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.MessageEntry;
import edu.tsinghua.lumaqq.models.FriendModel;

/**
 * <pre>
 * 好友聊天记录的导出类
 * </pre>
 * 
 * @author 马若劼
 */
public class FriendMessageExporter implements IRecordExporter {
	private DateFormat longDateFormat;
	private Date date;
	private FriendModel myModel, fModel;
	private int friendQQ;
	
	/**
	 * 构造函数
	 * @param myModel 我自己的model
	 * @param fModel 要导出记录好友的model
	 */
	public FriendMessageExporter(FriendModel myModel, FriendModel fModel) {
		longDateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
		date = new Date();
		this.myModel = myModel;
		this.fModel = fModel;
		this.friendQQ = fModel.getQQ();
	}
	
	/* (non-Javadoc)
	 * @see edu.tsinghua.lumaqq.IRecordExporter#exportString(edu.tsinghua.lumaqq.MessageEntry)
	 */
	public String exportString(MessageEntry me) {
		StringBuffer sb = new StringBuffer();
		sb.append(System.getProperty("line.separator"));
		sb.append(System.getProperty("line.separator"));
		date.setTime((long)me.getTime() * 1000L);
		sb.append(longDateFormat.format(date));
		sb.append(' ');
		sb.append((me.getSender() == friendQQ) ? fModel.getProperty("name") : myModel.getProperty("name"));
		sb.append(System.getProperty("line.separator"));
		sb.append(me.getMessage());
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see edu.tsinghua.lumaqq.IRecordExporter#exportHeader()
	 */
	public String exportHeader() {
		StringBuffer sb = new StringBuffer();
		sb.append(LumaQQ.getResourceString("text.export.header", new Object[] { String.valueOf(friendQQ), myModel.getProperty("name"), ((Integer)fModel.getProperty("qq")).toString(), fModel.getProperty("name") }));
		sb.append(System.getProperty("line.separator"));
		sb.append(System.getProperty("line.separator"));
		sb.append("==============================================================");
		return sb.toString();
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -