Package org.simpleframework.xml.core
Class ConversionInstance
java.lang.Object
org.simpleframework.xml.core.ConversionInstance
- All Implemented Interfaces:
Instance
The
ConversionInstance
object is used to promote the
type to some more specialized type. For example if a field or
method that represents a List
is annotated then this
might create a specialized type such as a Vector
. It
typically used to promote a type either because it is abstract
or because another type is required.
This is used by the CollectionFactory
to convert the
type of a collection field from an abstract type to a instantiable
type. This is used to simplify strategy implementations.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConversionInstance
(Context context, Value value, Class convert) This is used to specify the creation of a conversion type that can be used for creating an instance with a class other than the default class specified by theValue
object. -
Method Summary
Modifier and TypeMethodDescriptionThis method is used to acquire an instance of the type that is defined by this object.getInstance
(Class type) This method is used to acquire an instance of the type that is defined by this object.getType()
This is the type of the object instance that will be created by thegetInstance
method.boolean
This will return true if theValue
object provided is a reference type.setInstance
(Object object) This method is used acquire the value from the type and if possible replace the value for the type.
-
Field Details
-
context
This is the context that is used to create the instance. -
convert
This is the new class that is used for the type conversion. -
value
This is the value object that will be wrapped by this.
-
-
Constructor Details
-
ConversionInstance
This is used to specify the creation of a conversion type that can be used for creating an instance with a class other than the default class specified by theValue
object.- Parameters:
context
- this is the context used for instantiationvalue
- this is the type used to create the instanceconvert
- this is the class the type is converted to- Throws:
Exception
-
-
Method Details
-
getInstance
This method is used to acquire an instance of the type that is defined by this object. If for some reason the type can not be instantiated an exception is thrown from this.- Specified by:
getInstance
in interfaceInstance
- Returns:
- an instance of the type this object represents
- Throws:
Exception
-
getInstance
This method is used to acquire an instance of the type that is defined by this object. If for some reason the type can not be instantiated an exception is thrown from this.- Parameters:
type
- this is the type of the instance to create- Returns:
- an instance of the type this object represents
- Throws:
Exception
-
setInstance
This method is used acquire the value from the type and if possible replace the value for the type. If the value can not be replaced then an exception should be thrown. This is used to allow primitives to be inserted into a graph.- Specified by:
setInstance
in interfaceInstance
- Parameters:
object
- this is the object to insert as the value- Returns:
- an instance of the type this object represents
- Throws:
Exception
-
getType
This is the type of the object instance that will be created by thegetInstance
method. This allows the deserialization process to perform checks against the field. -
isReference
public boolean isReference()This will return true if theValue
object provided is a reference type. Typically a reference type refers to a type that is substituted during the deserialization process and so constitutes an object that does not need initialization.- Specified by:
isReference
in interfaceInstance
- Returns:
- this returns true if the type is a reference type
-