Package org.simpleframework.xml.core
Class InstanceFactory.ValueInstance
java.lang.Object
org.simpleframework.xml.core.InstanceFactory.ValueInstance
- All Implemented Interfaces:
Instance
- Enclosing class:
InstanceFactory
The
ValueInstance
object is used to create an object
by using a Value
instance to determine the type. If
the provided value instance represents a reference then this will
simply provide the value of the reference, otherwise it will
instantiate a new object and return that.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method is used to acquire an instance of the type that is defined by this object.getType()
This is the type of the object instance that will be created by thegetInstance
method.boolean
This is used to determine if the type is a reference type.setInstance
(Object object) This method is used acquire the value from the type and if possible replace the value for the type.
-
Field Details
-
value
This is the internal value that contains the criteria. -
type
This is the type that is to be instantiated by this.
-
-
Constructor Details
-
ValueInstance
Constructor for theValueInstance
object. This is used to represent an instance that delegates to the given value object in order to acquire the object.- Parameters:
value
- this is the value object that contains the data
-
-
Method Details
-
getInstance
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:
Exception
-
setInstance
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. Values that are references could be substitutes objects or existing ones.- Specified by:
isReference
in interfaceInstance
- Returns:
- this returns true if the object is a reference
-
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.
-