Class InstanceFactory

java.lang.Object
org.simpleframework.xml.core.InstanceFactory

class InstanceFactory extends Object
The Instantiator is used to instantiate types that will leverage a constructor cache to quickly create the objects. This is used by the various object factories to return type instances that can be used by converters to create the objects that will later be deserialized.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    The ClassInstance object is used to create an object by using a Class to determine the type.
    private class 
    The ValueInstance object is used to create an object by using a Value instance to determine the type.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Cache<Constructor>
    This is used to cache the constructors for the given types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Instantiator object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This will create an Instance that can be used to instantiate objects of the specified class.
    This will create an Instance that can be used to instantiate objects of the specified class.
    protected Object
    This method will instantiate an object of the provided type.

    Methods inherited from class java.lang.Object

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

    • cache

      private final Cache<Constructor> cache
      This is used to cache the constructors for the given types.
  • Constructor Details

    • InstanceFactory

      public InstanceFactory()
      Constructor for the Instantiator object. This will create a constructor cache that can be used to cache all of the constructors instantiated for the required types.
  • Method Details

    • getInstance

      public Instance getInstance(Value value)
      This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
      Parameters:
      value - this contains information on the object instance
      Returns:
      this will return an object for instantiating objects
    • getInstance

      public Instance getInstance(Class type)
      This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
      Parameters:
      type - this is the type that is to be instantiated
      Returns:
      this will return an object for instantiating objects
    • getObject

      protected Object getObject(Class type) throws Exception
      This method will instantiate an object of the provided type. If the object or constructor does not have public access then this will ensure the constructor is accessible and can be used.
      Parameters:
      type - this is used to ensure the object is accessible
      Returns:
      this returns an instance of the specific class type
      Throws:
      Exception