package com.example.db01;

import android.content.ContentValues;

public class AlarmMsg 
{
	
	public static final String TABLE_NAME = "alarmmsg";
	public static final String COL_ID = "_id";
	public static final String COL_ALARMID = "alarm_id";
	public static final String COL_DATETIME = "datetime";
	public static final String COL_STATUS = "status";
	
	public static final String ACTIVE = "A";
	public static final String EXPIRED = "E";
	public static final String CANCELLED = "C";
	public static final String DEFERRED = "D";
	
	
	static String getSql() {
		return Utils.concat("CREATE TABLE ", TABLE_NAME, " (",
				COL_ID, " INTEGER PRIMARY KEY AUTOINCREMENT, ",
				COL_ALARMID, " INTEGER, ",
				COL_DATETIME, " INTEGER, ",
				COL_STATUS, " TEXT",
				");");
	}
	
	void save() 
	{
		ContentValues cv = new ContentValues();
		cv.put(COL_ALARMID, alarmId);
		cv.put(COL_DATETIME, datetime);
		cv.put(COL_STATUS, status==null ? ACTIVE : status);
		
		//return db.insert(TABLE_NAME, null, cv);
	}
	
	
	
	//--------------------------------------------------------------------------
	private long id;
	private long alarmId;
	private long datetime;
	private String status;
	
	public void reset() 
	{
		alarmId = 0;
		datetime = 0;
		status = null;
	}

	public long getAlarmId() {
		return alarmId;
	}
	public void setAlarmId(long alarmId) {
		this.alarmId = alarmId;
	}
	public long getDateTime() {
		return datetime;
	}
	public void setDateTime(long datetime) {
		this.datetime = datetime;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	public AlarmMsg() {}
	
	public AlarmMsg(long id) {
		this.id = id;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if ((obj == null) || (obj.getClass() != this.getClass()))
			return false;
		
		return id == ((AlarmMsg)obj).id;
	}
 
	@Override
	public int hashCode() {
		return 1;
	}	
	
}
