Package org.simpleframework.xml.core
Interface Instance
-
- All Known Implementing Classes:
ArrayInstance
,ConversionInstance
,InstanceFactory.ClassInstance
,InstanceFactory.ValueInstance
,ObjectInstance
interface Instance
TheInstance
object creates a type that is represented by an XML element. Typically thegetInstance
method acts as a proxy to the classes new instance method, which takes no arguments. Simply delegating toClass.newInstance
will sometimes not be sufficient, is such cases reflectively acquiring the classes constructor may be required in order to pass arguments.- See Also:
Value
-
-
Method Summary
All Methods Instance Methods Abstract 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.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 value)
This method is used acquire the value from the type and if possible replace the value for the type.
-
-
-
Method Detail
-
getInstance
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.- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
setInstance
java.lang.Object setInstance(java.lang.Object value) throws java.lang.Exception
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.- Parameters:
value
- this is the value to insert as the type- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
isReference
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.- Returns:
- this returns true if the object is a reference
-
getType
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.- Returns:
- the type of the object that will be instantiated
-
-