net.sf.sfac.setting
Class TypeHelper<T>

java.lang.Object
  extended by net.sf.sfac.setting.TypeHelper<T>
Type Parameters:
T - the data type

public abstract class TypeHelper<T>
extends Object

Interface used to manage and identify a data type inside the Settings implementation.
This interface provides two method used to convert between string and the target data type. You will need to provide an instance of this helper for each new type supported by the settings implementation.

Author:
Olivier Berlanger

Constructor Summary
TypeHelper()
           
 
Method Summary
 String objectToString(T obj)
          Convert an object of the target data type to a string.
abstract  T stringToObject(String str)
          Convert a string to an object of the target data type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeHelper

public TypeHelper()
Method Detail

stringToObject

public abstract T stringToObject(String str)
                          throws Exception
Convert a string to an object of the target data type.

Parameters:
str - The string to convert.
Returns:
An object of the target data type.
Throws:
Exception - If the conversion cannot be performed.

objectToString

public String objectToString(T obj)
Convert an object of the target data type to a string.

Parameters:
obj - An object of the target data type to convert.
Returns:
The converted string.


Copyright © 2012. All Rights Reserved.