package it.mice.voila.runtime.springmvc.editors;

import it.mice.voila.runtime.springmvc.bean.PageStatus;

import java.beans.PropertyEditorSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PageStatusEditor extends PropertyEditorSupport {
	Log log = LogFactory.getLog(PageStatusEditor.class);

	/**
	 * Create a page status editor.
	 */
	public PageStatusEditor() {
	}

	/**
	 * Parse the page status string value to the corresponding page status object.
	 */
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		setValue(PageStatus.forName(text));
	}

	/**
	 * Format the Date as String, using the specified DateFormat.
	 */
	@Override
	public String getAsText() {
		PageStatus value = (PageStatus) getValue();
		return (value != null ? value.toString() : "");
	}
}
