/*
 * Created on Aug 25, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.va.med.esr.ui.util;

import gov.va.med.esr.common.model.lookup.Indicator;

/**
 * @author DNS   CHENB
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ConvertUtils {
    public static final String YES_VALUE = "y";
    public static final String NO_VALUE = "n";
    public static final String UNKNOWN_VALUE = "uk";
    public static final String NULL_VALUE = "nd";
    
    public static final String YES_STRING = "Yes";
    public static final String NO_STRING = "No";
    public static final String UNKNOWN_STRING = "Unknown";
    public static final String NULL_STRING = "No Data";

	/**
	 * 
	 */
	private ConvertUtils() {
	}
    public static Boolean convertBoolean(String value)
    {
    	if (value != null && (value.equalsIgnoreCase(YES_VALUE) || value.equalsIgnoreCase(YES_STRING)))
    		return Boolean.TRUE;
    	else if (value != null && (value.equalsIgnoreCase(NO_VALUE) || value.equalsIgnoreCase(NO_STRING)))
    		return Boolean.FALSE;
    	else
    		return null;
    }
    
    public static String convertIndicator(String value)
    {
        if (value != null && (value.equalsIgnoreCase(YES_VALUE) || value.equalsIgnoreCase(YES_STRING)))
            return Indicator.YES.getCode();
        else if (value != null && (value.equalsIgnoreCase(NO_VALUE) || value.equalsIgnoreCase(NO_STRING)))
            return Indicator.NO.getCode();
        else
            return Indicator.UNKNOWN.getCode();
    }
    
    public static boolean isYes(String value)
    {
    	if (value != null && value.equalsIgnoreCase(YES_VALUE))
    		return true;
    	else
    		return false;
    }
    public static String convertYesNo(Object value)
    {
    	if (value == null)
    		return NO_VALUE;
    	else if (value instanceof Boolean)
    	{
    		if (((Boolean)value).booleanValue() == true)
    			return YES_VALUE;
    		else
    			return NO_VALUE;
    	}
    	else
    		return YES_VALUE;
    }
    public static String convertYesNoNoData(Object value)
    {
    	if (value == null)
    		return NULL_VALUE;
    	else if (value instanceof Boolean)
    	{
    		if (((Boolean)value).booleanValue() == true)
    			return YES_VALUE;
    		else
    			return NO_VALUE;
    	}
    	else
    		return YES_VALUE;
    }
    public static String convertYesNoUnknown(Object value)
    {
    	if (value == null)
    		return UNKNOWN_VALUE;
    	else if (value instanceof Boolean)
    	{
    		if (((Boolean)value).booleanValue() == true)
    			return YES_VALUE;
    		else
    			return NO_VALUE;
    	}
    	else
    		return YES_VALUE;
    }

    public static String convertYesNoNoDataString(Object value)
    {
    	if (value == null)
    		return NULL_STRING;
    	else if (value instanceof Boolean)
    	{
    		if (((Boolean)value).booleanValue() == true)
    			return YES_STRING;
    		else
    			return NO_STRING;
    	}
    	else
    		return YES_STRING;
    }

}
