//
// CopyRight (C) 2002, IPA All rights reserved.
//
//	Objective
//
//	変更履歴
//		2002.12.25  新規作成
//

package jp.co.ntt.lms.lo.scorm.kernel;

import java.math.BigDecimal;

import jp.co.ntt.lms.lo.scorm.kernel.exception.SystemException;

/**
 * Objective class
 * Objective情報を表すクラス<BR>
 */
public abstract class Objective {
	/** 0.0000のBigDecimal */
	protected static final BigDecimal zero = new BigDecimal("0.0").setScale(4, BigDecimal.ROUND_HALF_UP);

	/** objective identifier */
	protected String objectiveID;

	/** objective progress status */
	protected boolean objectiveProgressStatus;

	/** objective satisfied status */
	protected boolean objectiveSatisfiedStatus;

	/** objective measure status */
	protected boolean objectiveMeasureStatus;

	/** objective normalized measure */
	protected BigDecimal objectiveNormalizedMeasure;

	// 20040801 ADD NTTR
	/* primaryObjectがIDをもつかどうか */
	protected boolean hasPrimaryID = false;
	
	/**
	 * デフォルトコンストラクタ
	 */
	public Objective() {
		initializeObjective();
	}

	/**
	 * Objectiveの初期化<BR>
	 */
	public void initializeObjective() {
		this.initializeObjectiveProgress();
		this.initializeObjectiveMeasure();
	}

	/**
	 * objectiveの情報の初期化<BR>
	 */
	private void initializeObjectiveProgress() {
		objectiveProgressStatus = false;
		objectiveSatisfiedStatus = false;
	}

	/**
	 * objectiveの情報の初期化<BR>
	 */
	private void initializeObjectiveMeasure() {
		objectiveMeasureStatus = false;
		objectiveNormalizedMeasure = zero;
	}

	/**
	 * 終期化<BR>
	 */
	public void terminate() throws SystemException {}

	/**
	 * objectiveIDの取得
	 *
	 * @return ObjectiveID
	 */
	public String getObjectiveID() {
		return objectiveID;
	}

	/**
	 * objectiveIDの設定<BR>
	 *
	 * @param id 設定するID<BR>
	 */
	public void setObjectiveID(String id) {
		objectiveID = id;
	}

	/**
	 * Objective Progress Status のセット
	 *
	 * @param result true/false
	 */
	public void setObjectiveProgressStatus(boolean result) throws SystemException {
		objectiveProgressStatus = result;
	}

	/**
	 * Objective satisfied status のセット
	 *
	 * @param result true/false
	 */
	public void setObjectiveSatisfiedStatus(boolean result) throws SystemException {
		objectiveSatisfiedStatus = result;
	}

	/**
	 * Objective Measure status のセット
	 *
	 * @param result true/false
	 */
	public void setObjectiveMeasureStatus(boolean result) throws SystemException {
		objectiveMeasureStatus = result;
	}

	/**
	 * objective normalized measureのセット
	 *
	 * @param measure
	 */
	public void setObjectiveNormalizedMeasure(BigDecimal measure) throws SystemException {
		objectiveNormalizedMeasure = measure;
	}

	/**
	 * Objective progress Statusの取得
	 *
	 * @return boolean true/false
	 */
	public boolean getObjectiveProgressStatus() throws SystemException {
		return objectiveProgressStatus;
	}

	/**
	 * objective satisfied status の取得
	 *
	 * @return boolean true/false
	 */
	public boolean getObjectiveSatisfiedStatus() throws SystemException {
		return objectiveSatisfiedStatus;
	}

	/**
	 * objective measure statusの取得
	 *
	 * @return boolean true/false
	 */
	public boolean getObjectiveMeasureStatus() throws SystemException {
		return objectiveMeasureStatus;
	}

	/**
	 * objective normalized meadsureの取得
	 *
	 * @return BigDecimal normalized measureの取得
	 */
	public BigDecimal getObjectiveNormalizedMeasure() throws SystemException {
		return objectiveNormalizedMeasure;
	}
	
	//	20040801 ADD NTTR
	/**
	 * primaryObjectiveのIDがあるかないかの取得
	 *
	 * @return IDを持つかどうかのフラグを返却
	 */
	public boolean getHasObjectiveID() throws SystemException {
		return hasPrimaryID;
	}
	
	/**
	 * primaryObjectiveのIDがないことをセット
	 *
	 * @return IDを持ってないことをセット
	 */
	public void setHasObjectiveID() throws SystemException {
		hasPrimaryID = true;	
	}
}
