Package org.simpleframework.xml.core
Class InstanceFactory
- java.lang.Object
-
- org.simpleframework.xml.core.InstanceFactory
-
class InstanceFactory extends java.lang.Object
TheInstantiator
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:
Instance
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
InstanceFactory.ClassInstance
TheClassInstance
object is used to create an object by using aClass
to determine the type.private class
InstanceFactory.ValueInstance
TheValueInstance
object is used to create an object by using aValue
instance to determine the type.
-
Constructor Summary
Constructors Constructor Description InstanceFactory()
Constructor for theInstantiator
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Instance
getInstance(java.lang.Class type)
This will create anInstance
that can be used to instantiate objects of the specified class.Instance
getInstance(Value value)
This will create anInstance
that can be used to instantiate objects of the specified class.protected java.lang.Object
getObject(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 anInstance
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(java.lang.Class type)
This will create anInstance
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 java.lang.Object getObject(java.lang.Class type) throws java.lang.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:
java.lang.Exception
-
-