Package org.simpleframework.xml.core
Class ArrayFactory
java.lang.Object
org.simpleframework.xml.core.Factory
org.simpleframework.xml.core.ArrayFactory
The
ArrayFactory
is used to create object array
types that are compatible with the field type. This simply
requires the type of the array in order to instantiate that
array. However, this also performs a check on the field type
to ensure that the array component types are compatible.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionArrayFactory
(Context context, Type type) Constructor for theArrayFactory
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate Class
This is used to extract the component type for the array class this factory represents.This is used to create a default instance of the field type.private Instance
getInstance
(Value value, Class entry) Creates the array type to use.getInstance
(InputNode node) Creates the array type to use.Methods inherited from class org.simpleframework.xml.core.Factory
getConversion, getOverride, getType, isCompatible, isInstantiable, setOverride
-
Constructor Details
-
ArrayFactory
Constructor for theArrayFactory
object. This is given the array component type as taken from the field type of the source object. Each request for an array will return an array which uses a compatible component type.- Parameters:
context
- this is the context object for serializationtype
- the array component type for the field object
-
-
Method Details
-
getInstance
This is used to create a default instance of the field type. It is up to the subclass to determine how to best instantiate an object of the field type that best suits. This is used when the empty value is required or to create the default type instance.- Overrides:
getInstance
in classFactory
- Returns:
- a type which is used to instantiate the collection
- Throws:
Exception
-
getInstance
Creates the array type to use. This will use the provided XML element to determine the array type and provide a means for creating an array with theValue
object. If the array size cannot be determined an exception is thrown.- Parameters:
node
- this is the input node for the array element- Returns:
- the object array type used for the instantiation
- Throws:
Exception
-
getInstance
Creates the array type to use. This will use the provided XML element to determine the array type and provide a means for creating an array with theValue
object. If the array types are not compatible an exception is thrown.- Parameters:
value
- this is the type object with the array detailsentry
- this is the entry type for the array instance- Returns:
- this object array type used for the instantiation
- Throws:
Exception
-
getComponentType
This is used to extract the component type for the array class this factory represents. This is used when an array is to be instantiated. If the class provided to the factory is not an array then this will throw an exception.- Returns:
- this returns the component type for the array
- Throws:
Exception
-