C# Class SimpleFramework.Xml.Core.PrimitiveFactory

The PrimitiveFactory object is used to create objects that are primitive types. This creates primitives and enumerated types when given a string value. The string value is parsed using a matched Transform implementation. The transform is then used to convert the object instance to an from a suitable XML representation. Only enumerated types are not transformed using a transform, instead they use Enum.name.
Inheritance: Factory
Afficher le fichier Open project: ngallagher/simplexml Class Usage Examples

Méthodes publiques

Méthode Description
GetInstance ( InputNode node ) : Instance

This method will instantiate an object of the field type, or if the Strategy 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.

GetInstance ( String text ) : Object

This will instantiate an object of the field type using the provided string. Typically this string is transformed in to the type using a Transform object. However, if the values is an enumeration then its value is created using the Enum.valueOf method. Also string values typically do not require conversion of any form and are just returned.

GetInstance ( String text, Class type ) : Object

This will instantiate an object of the field type using the provided string. Typically this string is transformed in to the type using a Transform object. However, if the values is an enumeration then its value is created using the Enum.valueOf method. Also string values typically do not require conversion of any form and are just returned.

GetText ( Object source ) : String

This is used to acquire a text value for the specified object. This will convert the object to a string using the transformer so that it can be deserialized from the generate XML document. However if the type is an Enum type then the text value is taken from Enum.name so it can later be deserialized easily using the enumeration class and name.

PrimitiveFactory ( Context context, Type type ) : SimpleFramework.Xml.Strategy

Constructor for the PrimitiveFactory object. This is provided the field type that is to be instantiated. This must be a type that contains a Transform object, typically this is a java.lang primitive object or one of the primitive types such as int. Also this can be given a class for an enumerated type.

Method Details

GetInstance() public méthode

This method will instantiate an object of the field type, or if the Strategy 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.
public GetInstance ( InputNode node ) : Instance
node InputNode /// this is the node to check for the override ///
Résultat Instance

GetInstance() public méthode

This will instantiate an object of the field type using the provided string. Typically this string is transformed in to the type using a Transform object. However, if the values is an enumeration then its value is created using the Enum.valueOf method. Also string values typically do not require conversion of any form and are just returned.
public GetInstance ( String text ) : Object
text String /// this is the value to be transformed to an object ///
Résultat Object

GetInstance() public méthode

This will instantiate an object of the field type using the provided string. Typically this string is transformed in to the type using a Transform object. However, if the values is an enumeration then its value is created using the Enum.valueOf method. Also string values typically do not require conversion of any form and are just returned.
public GetInstance ( String text, Class type ) : Object
text String /// this is the value to be transformed to an object ///
type Class /// this is the type of the primitive to instantiate ///
Résultat Object

GetText() public méthode

This is used to acquire a text value for the specified object. This will convert the object to a string using the transformer so that it can be deserialized from the generate XML document. However if the type is an Enum type then the text value is taken from Enum.name so it can later be deserialized easily using the enumeration class and name.
public GetText ( Object source ) : String
source Object /// this is the object instance to get the value of ///
Résultat String

PrimitiveFactory() public méthode

Constructor for the PrimitiveFactory object. This is provided the field type that is to be instantiated. This must be a type that contains a Transform object, typically this is a java.lang primitive object or one of the primitive types such as int. Also this can be given a class for an enumerated type.
public PrimitiveFactory ( Context context, Type type ) : SimpleFramework.Xml.Strategy
context Context /// this is the context used by this factory ///
type System.Type /// this is the field type to be instantiated ///
Résultat SimpleFramework.Xml.Strategy