@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface TypeConverter
The following code show how to implements a converter between String and boolean.
@TypeConverterpublic class StringBooleanConverter { protected String trueExp; protected String falseExp; public void init(Mapprops) { this.trueExp = props.get("cobol_bool_true"); this.falseExp = props.get("cobol_bool_false"); } public synchronized boolean convertToTarget(String source) { return trueExp.equals(source); } public synchronized String convertToSource(boolean target) { return target ? trueExp : falseExp; } }
© Copyright IBM Corp. 1987, 2017