The converter class will be used to file values of a bean class property as text in an XML structure. A new converter class must implement the interface Converter, wich prescribes the methods
Object toObject (Object parent, String[] string)
and
String[] toStringArray(Object arg0)
Example of a converter class:
public class LabelConverter implements Converter { public Object toObject(Object arg0, String[] arg1) throws InvocationTargetException { return arg1[0]; } public String[] toStringArray(Object arg0) throws InvocationTargetException { return new String[]{arg0}; } }
The
Object toObject(Object arg0, String[] arg1)
creates a object Object from the previous saved property text. In the example, the property LabelText will be returned.
The method
String[] toStringArray(Object arg0)
creates a StringArray from an Object, that will be used to save the property value in the XML struktur.
Now the LabelConverter class can be registered in the Bean-Schema.