package com.tandbergtv.watchpoint.pmm.web.formbeans.title;

/**
 * Represents a variable (metadata or property) of Title in UI.
 * 
 * @author Raj Prakash
 */
public class Variable {
	private String name, displayName, dataType, value;
	private boolean required = false;
	private boolean filePath = false;
	
	/**
	 * Default Constructor.
	 */
	public Variable() {}

	/**
	 * Constructor.
	 */
	public Variable(String name, String displayName, String datatType) {
		this.name = name;
		this.displayName = displayName;
		this.dataType = datatType;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the required
	 */
	public boolean isRequired() {
		return required;
	}

	/**
	 * @param required the required to set
	 */
	public void setRequired(boolean required) {
		this.required = required;
	}

	/**
	 * @return the filePath
	 */
	public boolean isFilePath() {
		return filePath;
	}

	/**
	 * @param filePath the filePath to set
	 */
	public void setFilePath(boolean filePath) {
		this.filePath = filePath;
	}

	/**
	 * @return the displayName
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * @param displayName the displayName to set
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	/**
	 * @return the datatType
	 */
	public String getDataType() {
		return dataType;
	}

	/**
	 * @param datatType the datatType to set
	 */
	public void setDataType(String datatType) {
		this.dataType = datatType;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = trim(value);
	}
	
	/**
	 * Safely trims the given string. Returns null for empty or blank string argument.
	 */
	private String trim(String s) {
		String result;
		
		if(s == null)
			return null;
		
		result = s.trim();
		
		if(result.length() == 0)
			result = null;
		
		return result;
	}
}
