/*
 *	EasyScout Boy Scouts of America tracking software.
 *	http://www.easyscout.org/
 *
 *	Copyright (C) 2000 Conan C. Albrecht
 *	conan@warp.cx
 *
 *	This program is released under the GNU license so tech-savvy
 *	Boy Scouts and others can enhance the program for the use
 *	of all.  Please e-mail changes to my address above so I can
 *	reintegrate into the main program at http://www.easyscout.org/.
 *	This way, all users mutually benefit one another in the spirit of
 *	scouting.
 *
 *	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.
 *
 * 	Any and all changes to the program code must be documented with
 *  date, author name and e-mail, and a short description.
 *
 *	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 cx.warp.scout.file;

import cx.warp.scout.*;
import java.util.*;
import java.io.*;

/** A merit badge */
public class FileMeritBadge implements MeritBadge, Serializable {

	public static final long serialVersionUID = 2513964752332054331L;

	protected FileScout scout = null;
	protected String id = Utils.getGUID();
	protected String name = null;
	protected Date earned = null;
	protected String counselor = "";
	protected boolean required = false;
	
	/** Constructor */
	public FileMeritBadge(FileScout scout) {
		this.scout = scout;
	}//constructor
	
	/** Returns the unique id of this badge */
	public String getID() throws DataException {
		return id;
	}//getID

	/** Sets the name of merit badge */
	public void setName(String name) throws DataException {
		this.name = name;
	}//setName
	
	/** Returns the name of this merit badge */
	public String getName() throws DataException {
		return name; 
	}//getName
	
	/** Sets the date the merit badge was earned */
	public void setEarnedDate(Date earned) throws DataException {
		this.earned = earned;
	}//setEarnedDate
	
	/** Returns the date the merit badge was earned */
	public Date getEarnedDate() throws DataException { 
	  return earned; 
	}//getEarnedDate
	
	/** Sets the counselor of this merit badge */
	public void setCounselor(String counselor) throws DataException {
		this.counselor = counselor;
	}//setCounselor
	
	/** Returns the counselor of the merit badge */
	public String getCounselor() throws DataException { 
	  return counselor; 
	}//getCounselor
	
	/** Sets whether this badge is required or not */
	public void setRequired(boolean required) throws DataException {
		this.required = required;
	}//setRequired
	
	/** Returns whether this badge is required or not */
	public boolean isRequired() throws DataException {
		return required; 
	}//isRequired
	
	/** Writes my information to an XML buffer */
	public void writeXML(PrintWriter out) throws DataException {
		out.println("    <MeritBadge id=\"" + id + "\">");
		out.println("      <Name>" + Utils.xml(name) + "</Name>");
		out.println("      <Earned>" + Utils.xml(earned) + "</Earned>");
		out.println("      <Counselor>" + Utils.xml(counselor) + "</Counselor>");
		out.println("      <Required>" + (required ? "Yes" : "No") + "</Required>");
		out.println("    </MeritBadge>");
	}//writeXML
}//MeritBadge
