Package org.simpleframework.xml.core
Class ArrayFactory
- java.lang.Object
-
- org.simpleframework.xml.core.Factory
-
- org.simpleframework.xml.core.ArrayFactory
-
class ArrayFactory extends Factory
TheArrayFactory
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.
-
-
Constructor Summary
Constructors Constructor Description ArrayFactory(Context context, Type type)
Constructor for theArrayFactory
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Class
getComponentType()
This is used to extract the component type for the array class this factory represents.java.lang.Object
getInstance()
This is used to create a default instance of the field type.private Instance
getInstance(Value value, java.lang.Class entry)
Creates the array type to use.Instance
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 Detail
-
ArrayFactory
public ArrayFactory(Context context, Type type)
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 Detail
-
getInstance
public java.lang.Object getInstance() throws java.lang.Exception
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:
java.lang.Exception
-
getInstance
public Instance getInstance(InputNode node) throws java.lang.Exception
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:
java.lang.Exception
-
getInstance
private Instance getInstance(Value value, java.lang.Class entry) throws java.lang.Exception
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:
java.lang.Exception
-
getComponentType
private java.lang.Class getComponentType() throws java.lang.Exception
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:
java.lang.Exception
-
-