Package org.simpleframework.xml.convert
Class ConverterScanner
- java.lang.Object
-
- org.simpleframework.xml.convert.ConverterScanner
-
class ConverterScanner extends java.lang.ObjectTheConverterScanneris used to create a converter given a method or field representation. Creation of the converter is done using theConvertannotation, 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 theTypeobject. This ensures that if a collection of objects are serialized the correct implementation will be used for each type or subtype.
-
-
Field Summary
Fields Modifier and Type Field Description private ScannerBuilderbuilderThis is used to build a scanner to scan for annotations.private ConverterFactoryfactoryThis is used to instantiate converters given the type.
-
Constructor Summary
Constructors Constructor Description ConverterScanner()Constructor for theConverterScannerobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private <T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<?> type, java.lang.Class<T> label)This is used to acquire theConvertannotation from the class provided.private ConvertgetConvert(java.lang.Class real)This method is used to scan the providedTypefor an annotation.private ConvertgetConvert(Type type)This method is used to scan the providedTypefor an annotation.private ConvertgetConvert(Type type, java.lang.Class real)This method is used to scan the providedTypefor an annotation.ConvertergetConverter(Type type, java.lang.Object value)This method will lookup and instantiate a converter found from scanning the field or method type provided.ConvertergetConverter(Type type, Value value)This method will lookup and instantiate a converter found from scanning the field or method type provided.private java.lang.ClassgetType(Type type, java.lang.Object value)This is used to acquire the class that should be scanned.private java.lang.ClassgetType(Type type, Value value)This is used to acquire the class that should be scanned.
-
-
-
Field Detail
-
factory
private final ConverterFactory factory
This is used to instantiate converters given the type.
-
builder
private final ScannerBuilder builder
This is used to build a scanner to scan for annotations.
-
-
Method Detail
-
getConverter
public Converter getConverter(Type type, Value value) throws java.lang.Exception
This method will lookup and instantiate a converter found from scanning the field or method type provided. If the type has been overridden then theValueobject 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:
java.lang.Exception
-
getConverter
public Converter getConverter(Type type, java.lang.Object value) throws java.lang.Exception
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:
java.lang.Exception
-
getConvert
private Convert getConvert(Type type, java.lang.Class real) throws java.lang.Exception
This method is used to scan the providedTypefor an annotation. If theTyperepresents 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:
java.lang.Exception
-
getConvert
private Convert getConvert(Type type) throws java.lang.Exception
This method is used to scan the providedTypefor an annotation. If theTyperepresents 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:
java.lang.Exception
-
getConvert
private Convert getConvert(java.lang.Class real) throws java.lang.Exception
This method is used to scan the providedTypefor an annotation. If theTyperepresents 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:
java.lang.Exception
-
getAnnotation
private <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<?> type, java.lang.Class<T> label)This is used to acquire theConvertannotation 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
private java.lang.Class getType(Type type, Value value)
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
private java.lang.Class getType(Type type, java.lang.Object value)
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
-
-