Package org.simpleframework.xml.convert
Class ConverterScanner
java.lang.Object
org.simpleframework.xml.convert.ConverterScanner
The
ConverterScanner
is used to create a converter
given a method or field representation. Creation of the converter
is done using the Convert
annotation, which may
be used to annotate a field, method or class. This describes the
implementation to use for object serialization. To account for
polymorphism the type scanned for annotations can be overridden
from type provided in the Type
object. This ensures
that if a collection of objects are serialized the correct
implementation will be used for each type or subtype.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ScannerBuilder
This is used to build a scanner to scan for annotations.private final ConverterFactory
This is used to instantiate converters given the type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate <T extends Annotation>
TgetAnnotation
(Class<?> type, Class<T> label) This is used to acquire theConvert
annotation from the class provided.private Convert
getConvert
(Class real) This method is used to scan the providedType
for an annotation.private Convert
getConvert
(Type type) This method is used to scan the providedType
for an annotation.private Convert
getConvert
(Type type, Class real) This method is used to scan the providedType
for an annotation.getConverter
(Type type, Object value) This method will lookup and instantiate a converter found from scanning the field or method type provided.getConverter
(Type type, Value value) This method will lookup and instantiate a converter found from scanning the field or method type provided.private Class
This is used to acquire the class that should be scanned.private Class
This is used to acquire the class that should be scanned.
-
Field Details
-
factory
This is used to instantiate converters given the type. -
builder
This is used to build a scanner to scan for annotations.
-
-
Constructor Details
-
ConverterScanner
public ConverterScanner()Constructor for theConverterScanner
object. This uses an internal factory to instantiate and cache all of the converters created. This will ensure that there is reduced overhead for a serialization process using converters.
-
-
Method Details
-
getConverter
This method will lookup and instantiate a converter found from scanning the field or method type provided. If the type has been overridden then theValue
object will provide the type to scan. If no annotation is found on the class, field or method then this will return null.- Parameters:
type
- this is the type to search for the annotationvalue
- this contains the type if it was overridden- Returns:
- a converter scanned from the provided field or method
- Throws:
Exception
-
getConverter
This method will lookup and instantiate a converter found from scanning the field or method type provided. If the type has been overridden then the object instance will provide the type to scan. If no annotation is found on the class, field or method then this will return null.- Parameters:
type
- this is the type to search for the annotationvalue
- this contains the type if it was overridden- Returns:
- a converter scanned from the provided field or method
- Throws:
Exception
-
getConvert
This method is used to scan the providedType
for an annotation. If theType
represents a field or method then the annotation can be taken directly from that field or method. If however the type represents a class then the class itself must contain the annotation.- Parameters:
type
- the field or method containing the annotationreal
- the type that represents the field or method- Returns:
- this returns the annotation on the field or method
- Throws:
Exception
-
getConvert
This method is used to scan the providedType
for an annotation. If theType
represents a field or method then the annotation can be taken directly from that field or method. If however the type represents a class then the class itself must contain the annotation.- Parameters:
type
- the field or method containing the annotation- Returns:
- this returns the annotation on the field or method
- Throws:
Exception
-
getConvert
This method is used to scan the providedType
for an annotation. If theType
represents a field or method then the annotation can be taken directly from that field or method. If however the type represents a class then the class itself must contain the annotation.- Parameters:
real
- the type that represents the field or method- Returns:
- this returns the annotation on the field or method
- Throws:
Exception
-
getAnnotation
This is used to acquire theConvert
annotation from the class provided. If the type does not contain the annotation then this scans all supertypes until either an annotation is found or there are no further supertypes.- Parameters:
type
- this is the type to scan for annotationslabel
- this is the annotation type that is to be found- Returns:
- this returns the annotation if found otherwise null
-
getType
This is used to acquire the class that should be scanned. The type is found either on the method or field, or should there be a subtype then the class is taken from the provided value.- Parameters:
type
- this is the type representing the field or methodvalue
- this contains the type if it was overridden- Returns:
- this returns the class that has been scanned
-
getType
This is used to acquire the class that should be scanned. The type is found either on the method or field, or should there be a subtype then the class is taken from the provided value.- Parameters:
type
- this is the type representing the field or methodvalue
- this contains the type if it was overridden- Returns:
- this returns the class that has been scanned
-