/*
 * Created on Mar 26, 2009
 * 
 * (C) Copyright TANDBERG Television Ltd.
 */

package com.tandbergtv.watchpoint.pmm.title.conf;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents the definition of a metadata variable that is a name-value pair.
 * 
 * @author Vijay Silva
 */
public class SimpleVariable extends Variable {

	private String dataType;
	private boolean isRequired;
	private boolean isFilePath;
	private boolean isKey;
	private boolean isSearchField;
	private boolean isExternalSearchField;
	private String searchFieldDataProvider;
	private Map<String, String> searchFieldConstants;
	private boolean attribute;

	/**
	 * Constructor
	 */
	public SimpleVariable(TitleConf title) {
		super(title);
	}

	/**
	 * @return the dataType
	 */
	public String getDataType() {
		return dataType;
	}

	/**
	 * @param dataType the dataType to set
	 */
	void setDataType(String dataType) {
		this.dataType = dataType;
	}

	/**
	 * @return the isRequired
	 */
	public boolean isRequired() {
		return isRequired;
	}

	/**
	 * @param isRequired the isRequired to set
	 */
	void setRequired(boolean isRequired) {
		this.isRequired = isRequired;
	}

	/**
	 * @return the isFilePath
	 */
	public boolean isFilePath() {
		return isFilePath;
	}

	/**
	 * @param isFilePath the isFilePath to set
	 */
	void setFilePath(boolean isFilePath) {
		this.isFilePath = isFilePath;
	}

	/**
	 * @return the isKey
	 */
	public boolean isKey() {
		return isKey;
	}

	/**
	 * @param isKey the isKey to set
	 */
	void setKey(boolean isKey) {
		this.isKey = isKey;
	}

	/**
	 * @return the isSearchField
	 */
	public boolean isSearchField() {
		return isSearchField;
	}

	/**
	 * @param isSearchField the isSearchField to set
	 */
	void setSearchField(boolean isSearchField) {
		this.isSearchField = isSearchField;
	}

	/**
	 * @return the isExternalSearchField
	 */
	public boolean isExternalSearchField() {
		return isExternalSearchField;
	}

	/**
	 * @param isExternalSearchField the isExternalSearchField to set
	 */
	void setExternalSearchField(boolean isExternalSearchField) {
		this.isExternalSearchField = isExternalSearchField;
	}

	/**
	 * @return the searchFieldDataProvider
	 */
	public String getSearchFieldDataProvider() {
		return searchFieldDataProvider;
	}

	/**
	 * @param searchFieldDataProvider the searchFieldDataProvider to set
	 */
	void setSearchFieldDataProvider(String searchFieldDataProvider) {
		this.searchFieldDataProvider = searchFieldDataProvider;
	}

	/**
	 * @return the searchFieldConstants
	 */
	public Map<String, String> getSearchFieldValues() {
		return searchFieldConstants;
	}

	/**
	 * @param searchFieldConstants the searchFieldConstants to set
	 */
	void setSearchFieldValues(Map<String, String> searchFieldConstants) {
		this.searchFieldConstants = searchFieldConstants;
	}

	/**
	 * Adds a search field constant.
	 * 
	 * @param name the name of the search field constant
	 * @param value the value of the search field constant
	 */
	void addSearchFieldValue(String name, String value) {
		if (searchFieldConstants == null)
			searchFieldConstants = new HashMap<String, String>();
		searchFieldConstants.put(name, value);
	}

	/**
	 * @return the attribute
	 */
	public boolean isAttribute() {
		return attribute;
	}

	/**
	 * @param attribute the attribute to set
	 */
	void setAttribute(boolean attribute) {
		this.attribute = attribute;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tandbergtv.watchpoint.pmm.title.conf.Variable#toString()
	 */
	@Override
	public String toString() {
		String desc = super.toString();
		String delimiter = " | ";
		desc += delimiter + "Data Type: " + dataType + delimiter + "Is Required: " + isRequired;
		return desc;
	}
}
