Package au.net.causal.projo.prefs.transform

Source Code of au.net.causal.projo.prefs.transform.IntToStringTransformer

package au.net.causal.projo.prefs.transform;

import au.net.causal.projo.prefs.PreferencesException;

/**
* Converts from {@link Integer} and primitive int data type to string data type.
*
* @author prunge
*/
public class IntToStringTransformer extends GenericToStringTransformer<Integer>
{
  public IntToStringTransformer()
  {
    super(Integer.class);
  }
 
  @Override
  protected Integer stringToValue(String s) throws PreferencesException
  {
    try
    {
      return(Integer.valueOf(s));
    }
    catch (NumberFormatException e)
    {
      throw new PreferencesException("Failed to convert value '" + s + "' to an integer.", e);
    }
  }
 
  @Override
  protected String valueToString(Integer value) throws PreferencesException
  {
    return(value.toString());
  }
}
TOP

Related Classes of au.net.causal.projo.prefs.transform.IntToStringTransformer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.