📄 friendmessageformatter.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.MessageEntry;
import edu.tsinghua.lumaqq.models.FriendModel;
/**
* <pre>
* 好友消息的格式化器
* </pre>
*
* @author 马若劼
*/
public class FriendMessageFormatter implements IRecordFormatter {
private DateFormat shortDateFormat;
private Date date;
private FriendModel myModel, fModel;
private int friendQQ;
/**
* 构造函数
* @param myModel 我自己的model
* @param fModel 要导出记录好友的model
*/
public FriendMessageFormatter(FriendModel myModel, FriendModel fModel) {
shortDateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
date = new Date();
this.myModel = myModel;
this.fModel = fModel;
this.friendQQ = fModel.getQQ();
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.IRecordFormatter#format(edu.tsinghua.lumaqq.MessageEntry)
*/
public String[] format(MessageEntry me) {
String[] ret = new String[3];
// 设置来源
if(me.getSender() == friendQQ) ret[0] = (String)fModel.getProperty("name");
else ret[0] = (String)myModel.getProperty("name");
// 设置收到时间
date.setTime((long)me.getTime() * 1000L);
ret[1] = shortDateFormat.format(date);
// 设置消息
ret[2] = me.getMessage();
return ret;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.IRecordFormatter#copy(edu.tsinghua.lumaqq.MessageEntry)
*/
public String copy(MessageEntry me) {
return me.getMessage();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -