package cnp.ew.converter;

/**
 * Subclasses of this class can convert objects into strings, using a formatting
 * string as a guide.

 * @version        $Version$
 * @author         $Author: Ken $
 */
public abstract class CpFormattedToStringConverter implements CpToStringConverter
{

    protected String formatString="";

    public CpFormattedToStringConverter()
    {
        super();
    }

    public CpFormattedToStringConverter(String newFormat)
    {
        setFormatString(newFormat);
    }


    /**
     * Set the formatting string for this converter.
     */
    public void setFormatString(String newFormatString)
    {
        formatString = newFormatString;
        parseFormatString();
    }

    /**
     * Answer the formatting string for this converter.
     */
    public String getFormatString()
    {
        return formatString;
    }

    /**
     * Convert o into a string, using the current formatting string.
     */
    abstract public String convert(Object o);

    /**
     * Parse the current formatting string into more rapidly readible information.
     */
    abstract void parseFormatString();
}

