Class ConversionInstance

java.lang.Object
org.simpleframework.xml.core.ConversionInstance
All Implemented Interfaces:
Instance

class ConversionInstance extends Object implements 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
    Modifier and Type
    Field
    Description
    private final Context
    This is the context that is used to create the instance.
    private final Class
    This is the new class that is used for the type conversion.
    private final Value
    This is the value object that will be wrapped by this.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConversionInstance(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 the Value object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This method is used to acquire an instance of the type that is defined by this object.
    This method is used to acquire an instance of the type that is defined by this object.
    This is the type of the object instance that will be created by the getInstance method.
    boolean
    This will return true if the Value object provided is a reference type.
    This method is used acquire the value from the type and if possible replace the value for the type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • context

      private final Context context
      This is the context that is used to create the instance.
    • convert

      private final 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 Details

    • ConversionInstance

      public ConversionInstance(Context context, Value value, Class convert) throws 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 the Value object.
      Parameters:
      context - this is the context used for instantiation
      value - this is the type used to create the instance
      convert - this is the class the type is converted to
      Throws:
      Exception
  • Method Details

    • getInstance

      public Object getInstance() throws Exception
      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 interface Instance
      Returns:
      an instance of the type this object represents
      Throws:
      Exception
    • getInstance

      public Object getInstance(Class type) throws Exception
      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

      public Object setInstance(Object object) throws Exception
      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 interface Instance
      Parameters:
      object - this is the object to insert as the value
      Returns:
      an instance of the type this object represents
      Throws:
      Exception
    • getType

      public Class getType()
      This is the type of the object instance that will be created by the getInstance method. This allows the deserialization process to perform checks against the field.
      Specified by:
      getType in interface Instance
      Returns:
      the type of the object that will be instantiated
    • isReference

      public boolean isReference()
      This will return true if the Value 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 interface Instance
      Returns:
      this returns true if the type is a reference type