Package org.simpleframework.xml.convert
Class ConverterFactory
java.lang.Object
org.simpleframework.xml.convert.ConverterFactory
The
ConverterFactory
is used to instantiate objects
based on a provided type or annotation. This provides a single
point of creation for all converters within the framework. For
performance all the instantiated converters are cached against
the class for that converter. This ensures the converters can
be acquired without the overhead of instantiation.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Constructor
getConstructor
(Class type) This is used to acquire the default no argument constructor for the the provided type.private Converter
getConverter
(Class type) This is used to instantiate the converter based on the type provided.private Converter
getConverter
(Class type, Constructor factory) This is used to instantiate the converter based on the type provided.getInstance
(Class type) This is used to instantiate the converter based on the type provided.getInstance
(Convert convert) This is used to instantiate the converter based on the type of theConvert
annotation provided.
-
Field Details
-
cache
This is the cache that is used to cache converter instances.
-
-
Constructor Details
-
ConverterFactory
public ConverterFactory()Constructor for theConverterFactory
object. This will create an internal cache which is used to cache all instantiations made by the factory. Caching the converters ensures there is no overhead with instantiations.
-
-
Method Details
-
getInstance
This is used to instantiate the converter based on the type provided. If the type provided can not be instantiated for some reason then an exception is thrown from this method.- Parameters:
type
- this is the converter type to be instantiated- Returns:
- this returns an instance of the provided type
- Throws:
Exception
-
getInstance
This is used to instantiate the converter based on the type of theConvert
annotation provided. If the type can not be instantiated for some reason then an exception is thrown from this method.- Parameters:
convert
- this is the annotation containing the type- Returns:
- this returns an instance of the provided type
- Throws:
Exception
-
getConverter
This is used to instantiate the converter based on the type provided. If the type provided can not be instantiated for some reason then an exception is thrown from this method.- Parameters:
type
- this is the converter type to be instantiated- Returns:
- this returns an instance of the provided type
- Throws:
Exception
-
getConverter
This is used to instantiate the converter based on the type provided. If the type provided can not be instantiated for some reason then an exception is thrown from this method.- Parameters:
type
- this is the converter type to be instantiatedfactory
- this is the constructor used to instantiate- Returns:
- this returns an instance of the provided type
- Throws:
Exception
-
getConstructor
This is used to acquire the default no argument constructor for the the provided type. If the constructor is not accessible then it will be made accessible so that it can be instantiated.- Parameters:
type
- this is the type to acquire the constructor for- Returns:
- this returns the constructor for the type provided
- Throws:
Exception
-