|
TopLink performs all type conversions through the use of a
ConversionManager class (
oracle.toplink.internal.helper). This class can be extended to perform any additional conversions or to customize existing conversions. The source code to the
ConversionManager is shipped with the product in the source.jar library.
For the purpose of this example a subclass of
ConversionManager is created called
MyConversionManager. This new class must support converting from a String into an Answer instance and from an Answer instance into a String.
The important methods to overwrite are:
public Object convertObject(Object source, Class javaClass)
public String convertObjectToString(Object source)
For this particular case an additional method was added for converting into an Answer:
public Answer convertObjectToAnswer(Object source)
The source for MyConversionManager.java.
|