Package org.simpleframework.xml.core
Class ObjectFactory
java.lang.Object
org.simpleframework.xml.core.Factory
org.simpleframework.xml.core.PrimitiveFactory
org.simpleframework.xml.core.ObjectFactory
The
ObjectFactory
is the most basic factory. This will
basically check to see if there is an override type within the XML
node provided, if there is then that is instantiated, otherwise the
field type is instantiated. Any type created must have a default
no argument constructor. If the override type is an abstract class
or an interface then this factory throws an exception.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionObjectFactory
(Context context, Type type, Class override) Constructor for theObjectFactory
class. -
Method Summary
Modifier and TypeMethodDescriptiongetInstance
(InputNode node) This method will instantiate an object of the field type, or if theStrategy
object can resolve a class from the XML element then this is used instead.Methods inherited from class org.simpleframework.xml.core.PrimitiveFactory
getInstance, getText
Methods inherited from class org.simpleframework.xml.core.Factory
getConversion, getInstance, getOverride, getType, isCompatible, isInstantiable, setOverride
-
Constructor Details
-
ObjectFactory
Constructor for theObjectFactory
class. This is given the field class that this should create object instances of. If the field type is abstract then the XML node must have sufficient information for theStrategy
object to resolve the implementation class to be instantiated.- Parameters:
context
- the contextual object used by the persistertype
- this is the object type to use for this factory
-
-
Method Details
-
getInstance
This method will instantiate an object of the field type, or if theStrategy
object can resolve a class from the XML element then this is used instead. If the resulting type is abstract or an interface then this method throws an exception.- Overrides:
getInstance
in classPrimitiveFactory
- Parameters:
node
- this is the node to check for the override- Returns:
- this returns an instance of the resulting type
- Throws:
Exception
-