Package org.simpleframework.xml.core
Class ConversionInstance
- java.lang.Object
-
- org.simpleframework.xml.core.ConversionInstance
-
- All Implemented Interfaces:
Instance
class ConversionInstance extends java.lang.Object implements Instance
TheConversionInstanceobject is used to promote the type to some more specialized type. For example if a field or method that represents aListis annotated then this might create a specialized type such as aVector. It typically used to promote a type either because it is abstract or because another type is required.This is used by the
CollectionFactoryto convert the type of a collection field from an abstract type to a instantiable type. This is used to simplify strategy implementations.- See Also:
CollectionFactory
-
-
Field Summary
Fields Modifier and Type Field Description private ContextcontextThis is the context that is used to create the instance.private java.lang.ClassconvertThis is the new class that is used for the type conversion.private ValuevalueThis is the value object that will be wrapped by this.
-
Constructor Summary
Constructors Constructor Description ConversionInstance(Context context, Value value, java.lang.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 theValueobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetInstance()This method is used to acquire an instance of the type that is defined by this object.java.lang.ObjectgetInstance(java.lang.Class type)This method is used to acquire an instance of the type that is defined by this object.java.lang.ClassgetType()This is the type of the object instance that will be created by thegetInstancemethod.booleanisReference()This will return true if theValueobject provided is a reference type.java.lang.ObjectsetInstance(java.lang.Object object)This method is used acquire the value from the type and if possible replace the value for the type.
-
-
-
Field Detail
-
context
private final Context context
This is the context that is used to create the instance.
-
convert
private final java.lang.Class convert
This is the new class that is used for the type conversion.
-
value
private final Value value
This is the value object that will be wrapped by this.
-
-
Constructor Detail
-
ConversionInstance
public ConversionInstance(Context context, Value value, java.lang.Class convert) throws java.lang.Exception
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 theValueobject.- 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:
java.lang.Exception
-
-
Method Detail
-
getInstance
public java.lang.Object getInstance() throws java.lang.ExceptionThis 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:
getInstancein interfaceInstance- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
getInstance
public java.lang.Object getInstance(java.lang.Class type) throws java.lang.ExceptionThis 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:
java.lang.Exception
-
setInstance
public java.lang.Object setInstance(java.lang.Object object) throws java.lang.ExceptionThis 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:
setInstancein interfaceInstance- Parameters:
object- this is the object to insert as the value- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
getType
public java.lang.Class getType()
This is the type of the object instance that will be created by thegetInstancemethod. This allows the deserialization process to perform checks against the field.
-
isReference
public boolean isReference()
This will return true if theValueobject 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:
isReferencein interfaceInstance- Returns:
- this returns true if the type is a reference type
-
-