package com.tandbergtv.watchpoint.pmm.title.conf;

import java.util.ResourceBundle;

/**
 * Class that represent the &lt;variable&gt; tag in the Specification.
 * 
 * @author Raj Prakash
 */
public abstract class Variable {
	private TitleConf title;
	private String name;
	private String displayName;
	private String xpath;
	private int min = 1;
	private int max = 1;

	/**
	 * @param title
	 */
	public Variable(TitleConf title) {
		super();
		this.title = title;
	}

	/**
	 * @return the title
	 */
	public TitleConf getTitleConf() {
		return title;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the displayName
	 */
	public String getDisplayName() {
		ResourceBundle bundle = this.title.getSpecification().getBundle();

		if (bundle != null && bundle.containsKey(this.displayName))
			return bundle.getString(this.displayName);

		return displayName;
	}

	/**
	 * @param displayName the displayName to set
	 */
	void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

    /**
     * @return the xpath
     */
    public String getXPath() {
	    return xpath;
    }

    /**
     * @param xpath the xpath to set
     */
    void setXPath(String xpath) {
	    this.xpath = xpath;
    }

    /**
	 * @return the max
	 */
	public int getMax() {
		return max;
	}

	/**
     * @param max the max to set
     */
    void setMax(int max) {
	    this.max = max;
    }

	/**
	 * @return the min
	 */
	public int getMin() {
		return min;
	}

	/**
     * @param min the min to set
     */
    void setMin(int min) {
	    this.min = min;
    }

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		String delimiter = " | ";
		return "Variable: " + delimiter + "Name: " + name + delimiter + "Display Name: "
		        + getDisplayName();
	}
}
