Package org.simpleframework.xml.core
Class ArrayInstance
- java.lang.Object
-
- org.simpleframework.xml.core.ArrayInstance
-
- All Implemented Interfaces:
Instance
class ArrayInstance extends java.lang.Object implements Instance
TheArrayInstanceobject is used for creating arrays from a specifiedValueobject. This allows primitive and composite arrays to be acquired either by reference or by value from the given value object. This must be given the length of the array so that it can be allocated correctly.- See Also:
Instance
-
-
Constructor Summary
Constructors Constructor Description ArrayInstance(Value value)Constructor for theArrayInstanceobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetInstance()This method is used to acquire an instance of the type that is defined by this object.java.lang.ClassgetType()This is the type of the object instance that will be created by thegetInstancemethod.booleanisReference()This is used to determine if the type is a reference type.java.lang.ObjectsetInstance(java.lang.Object array)This method is used acquire the value from the type and if possible replace the value for the type.
-
-
-
Field Detail
-
value
private final Value value
This is the value object that contains the criteria.
-
type
private final java.lang.Class type
This is the array component type for the created array.
-
length
private final int length
This is the length of the array to be instantiated.
-
-
Constructor Detail
-
ArrayInstance
public ArrayInstance(Value value)
Constructor for theArrayInstanceobject. This is used to create an object that can create an array of the given length and specified component type.- Parameters:
value- this is the value object describing the instance
-
-
Method Detail
-
getInstance
public java.lang.Object getInstance() throws java.lang.ExceptionThis 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:
getInstancein interfaceInstance- Returns:
- an instance of the type this object represents
- Throws:
java.lang.Exception
-
setInstance
public java.lang.Object setInstance(java.lang.Object array)
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:
setInstancein interfaceInstance- Parameters:
array- this is the array to insert as the value- Returns:
- an instance of the type this object represents
-
getType
public java.lang.Class getType()
This is the type of the object instance that will be created by thegetInstancemethod. This allows the deserialization process to perform checks against the field.
-
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 of existing ones.- Specified by:
isReferencein interfaceInstance- Returns:
- this returns true if the object is a reference
-
-