Package org.simpleframework.xml.core
Class ObjectInstance
- java.lang.Object
-
- org.simpleframework.xml.core.ObjectInstance
-
- All Implemented Interfaces:
Instance
class ObjectInstance extends java.lang.Object implements Instance
TheObjectInstance
is used to instantiate an object from the criteria provided in the givenValue
. If the value contains a reference then the reference is provided from this type. For performance theContext
object is used to instantiate the object as it contains a reflection cache of constructors.
-
-
Constructor Summary
Constructors Constructor Description ObjectInstance(Context context, Value value)
Constructor for theObjectInstance
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getInstance()
This method is used to acquire an instance of the type that is defined by this object.java.lang.Object
getInstance(java.lang.Class type)
This method is used to acquire an instance of the type that is defined by this object.java.lang.Class
getType()
This is the type of the object instance that will be created by thegetInstance
method.boolean
isReference()
This is used to determine if the type is a reference type.java.lang.Object
setInstance(java.lang.Object object)
This method is used acquire the value from the type and if possible replace the value for the type.
-
-
-
Constructor Detail
-
ObjectInstance
public ObjectInstance(Context context, Value value)
Constructor for theObjectInstance
object. This is used to create an instance of the type described by the value object. If the value object contains a reference then this will simply provide that reference.- Parameters:
context
- this is used to instantiate the objectvalue
- this is the value describing the instance
-
-
Method Detail
-
getInstance
public java.lang.Object getInstance() throws java.lang.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 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.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 that is to be instantiated- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
setInstance
public java.lang.Object setInstance(java.lang.Object object)
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 interfaceInstance
- Parameters:
object
- this is the object to insert as the value- Returns:
- an instance of the type this object represents
-
isReference
public boolean isReference()
This is used to determine if the type is a reference type. A reference type is a type that does not require any XML deserialization based on its annotations. Types that are references could be substitutes objects are existing ones.- Specified by:
isReference
in interfaceInstance
- Returns:
- this returns true if the object is a reference
-
getType
public java.lang.Class getType()
This is the type of the object instance that will be created by thegetInstance
method. This allows the deserialization process to perform checks against the field.
-
-