📄 systemmessageformatter.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;
/**
* <pre>
* 系统消息的格式化器
* </pre>
*
* @author 马若劼
*/
public class SystemMessageFormatter implements IRecordFormatter {
private Date date;
private DateFormat shortDateFormat;
/**
* 构造函数
*/
public SystemMessageFormatter() {
date = new Date();
shortDateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.IRecordFormatter#format(edu.tsinghua.lumaqq.MessageEntry)
*/
public String[] format(MessageEntry me) {
String[] ret = new String[3];
String msg = me.getMessage();
int delimit = msg.indexOf('|');
if(delimit == -1) {
// 如果等于-1,则是普通的系统广播消息
ret[0] = "10000";
date.setTime((long)me.getTime() * 1000L);
ret[1] = shortDateFormat.format(date);
ret[2] = msg;
} else {
// 设置发送者QQ号
ret[0] = String.valueOf(me.getSender());
// 设置时间
date.setTime((long)me.getTime() * 1000L);
ret[1] = shortDateFormat.format(date);
// 设置消息内容
ret[2] = msg.substring(delimit + 1);
}
return ret;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.IRecordFormatter#copy(edu.tsinghua.lumaqq.MessageEntry)
*/
public String copy(MessageEntry me) {
return me.getMessage().substring(me.getMessage().lastIndexOf('|') + 1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -