Package org.simpleframework.xml.core
Class InstanceFactory
- java.lang.Object
-
- org.simpleframework.xml.core.InstanceFactory
-
class InstanceFactory extends java.lang.ObjectTheInstantiatoris 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:
Instance
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classInstanceFactory.ClassInstanceTheClassInstanceobject is used to create an object by using aClassto determine the type.private classInstanceFactory.ValueInstanceTheValueInstanceobject is used to create an object by using aValueinstance to determine the type.
-
Constructor Summary
Constructors Constructor Description InstanceFactory()Constructor for theInstantiatorobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstancegetInstance(java.lang.Class type)This will create anInstancethat can be used to instantiate objects of the specified class.InstancegetInstance(Value value)This will create anInstancethat can be used to instantiate objects of the specified class.protected java.lang.ObjectgetObject(java.lang.Class type)This method will instantiate an object of the provided type.
-
-
-
Field Detail
-
cache
private final Cache<java.lang.reflect.Constructor> cache
This is used to cache the constructors for the given types.
-
-
Method Detail
-
getInstance
public Instance getInstance(Value value)
This will create anInstancethat 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(java.lang.Class type)
This will create anInstancethat 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 java.lang.Object getObject(java.lang.Class type) throws java.lang.ExceptionThis 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:
java.lang.Exception
-
-