📄 friendmessageexporter.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;
import edu.tsinghua.lumaqq.models.IQQNode;
import edu.tsinghua.swt.models.INode;
/**
* <pre>
* 好友聊天记录的导出类
* </pre>
*
* @author 马若劼
*/
public class FriendMessageExporter implements IRecordExporter {
private DateFormat longDateFormat;
private Date date;
private FriendModel myModel, fModel;
private int friendQQ;
/**
* 创建一个空的,不可用的好友聊天记录导出器
*/
public FriendMessageExporter() {
longDateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
date = new Date();
}
/**
* 构造函数
* @param myModel 我自己的model
* @param fModel 要导出记录好友的model
*/
public FriendMessageExporter(FriendModel myModel, FriendModel fModel) {
this();
this.myModel = myModel;
this.fModel = fModel;
this.friendQQ = fModel.getQQ();
}
/**
* 设置自己的model
*
* @param me
* 自己的FriendModel对象
*/
public void setMyModel(FriendModel me) {
this.myModel = me;
}
/**
* 设置好友的model
*
* @param f
* 好友的FriendModel
*/
public void setFriendModel(FriendModel f) {
this.fModel = f;
friendQQ = f.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(INode.NAME) : myModel.getProperty(INode.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.getString("text.export.header", new Object[] { String.valueOf(friendQQ), myModel.getProperty(INode.NAME), ((Integer)fModel.getProperty(IQQNode.QQ_NUMBER)).toString(), fModel.getProperty(INode.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 + -