Package org.simpleframework.xml.convert
Annotation Type Convert
-
@Retention(RUNTIME) public @interface Convert
TheConvert
annotation is used to specify a converter class to use for serialization. This annotation is used when an object needs to be serialized but can not be annotated or when the object can not conform to an existing XML structure. In order to specify aConverter
object a field or method can be annotated like the field below.@Element @Convert(ExampleConverter.class) private Example example;
Note that for the above field theElement
annotation is required. If this is used with any other XML annotation such as theElementList
orText
annotation then an exception will be thrown. As well as field and methods this can be used to suggest a converter for a class. Take the class below which is annotated.@Root @Convert(DemoConverter.class) public class Demo { ... }
For the above class the specified converter will be used. This is useful when the class is used within ajava.util.List
or another similar collection. Finally, in order for this to work it must be used with theAnnotationStrategy
which is used to scan for annotations in order to delegate to converters.- Author:
- Niall Gallagher
- See Also:
AnnotationStrategy
-
-
Element Detail
-
value
java.lang.Class<? extends Converter> value
Specifies theConverter
implementation to be used to convert the annotated object. The converter specified will be used to convert the object to XML by intercepting the serialization and deserialization process as it happens. A converter should typically be used to handle an object of a specific type.- Returns:
- this returns the converter that has been specified
-
-