package zall.bean;

import java.sql.Timestamp;
import java.util.Date;

import zutil.db.bean.DBBean;
import zutil.db.bean.DBBean.*;
import zutil.parser.BBCodeParser;

@DBTable("Comments")
public class Comment extends DBBean{
	private static BBCodeParser parser = null;

	protected User user;
	protected Date date;
	protected String message;
	
	public Comment(){
		if( parser == null ){
			parser = new BBCodeParser();
		}
		setCurrentDate();
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String msg) {
		if( msg != null ){
			msg = msg.replaceAll("<", "&lt;");
			msg = msg.replaceAll(">", "&gt;");
			this.message = parser.read( msg );
		}
	}
	public void setCurrentDate() {
		this.date = new Timestamp( System.currentTimeMillis() );
	}
}
