C# Class Transformer, simplexml

The Transformer object is used to convert strings to and from object instances. This is used during the serialization and deserialization process to transform types from the Java class libraries, as well as other types which do not contain XML schema annotations. Typically this will be used to transform primitive types to and from strings, such as int values. @Element private String[] value; For example taking the above value the array of strings needs to be converted in to a single string value that can be inserted in to the element in such a way that in can be read later. In this case the serialized value of the string array would be as follows. <value>one, two, three</value> Here each non-null string is inserted in to a comma separated list of values, which can later be deserialized. Just to note the above array could be annotated with ElementList just as easily, in which case each entry would have its own element. The choice of which annotation to use is up to the developer. A more obvious benefit to transformations like this can be seen for values annotated with the Attribute annotation.
Show file Open project: ngallagher/simplexml Class Usage Examples

Public Methods

Method Description
Lookup ( Class, type ) : Transform,

This method is used to acquire a Transform for the the specified type. If there is no transform for the type then this will return null. Once acquired once the transform is cached so that subsequent lookups will be performed faster.

Match ( Class, type ) : Transform,

This method is used to acquire a Transform for the the specified type. If there is no transform for the type then this will return null. Once acquired once the transform is cached so that subsequent lookups will be performed faster.

Read ( String value, Class, type ) : Object

This method is used to convert the string value given to an appropriate representation. This is used when an object is being deserialized from the XML document and the value for the string representation is required.

Transformer ( Matcher matcher ) : SimpleFramework.Xml.Util

Constructor for the Transformer object. This is used to create a transformer which will transform specified types using transforms loaded from the class path. Transforms are matched to types using the specified matcher object.

Valid ( Class, type ) : bool

This method is used to determine if the type specified can be transformed. This will use the Matcher to find a suitable transform, if one exists then this returns true, if not then this returns false. This is used during serialization to determine how to convert a field or method parameter.

Write ( Object value, Class, type ) : String

This method is used to convert the provided value into an XML usable format. This is used in the serialization process when there is a need to convert a field value in to a string so that that value can be written as a valid XML entity.

Method Details

Lookup() public method

This method is used to acquire a Transform for the the specified type. If there is no transform for the type then this will return null. Once acquired once the transform is cached so that subsequent lookups will be performed faster.
public Lookup ( Class, type ) : Transform,
type Class, /// the type to determine whether its transformable ///
return Transform,

Match() public method

This method is used to acquire a Transform for the the specified type. If there is no transform for the type then this will return null. Once acquired once the transform is cached so that subsequent lookups will be performed faster.
public Match ( Class, type ) : Transform,
type Class, /// the type to determine whether its transformable ///
return Transform,

Read() public method

This method is used to convert the string value given to an appropriate representation. This is used when an object is being deserialized from the XML document and the value for the string representation is required.
public Read ( String value, Class, type ) : Object
value String /// this is the string representation of the value ///
type Class, /// this is the type to convert the string value to ///
return Object

Transformer() public method

Constructor for the Transformer object. This is used to create a transformer which will transform specified types using transforms loaded from the class path. Transforms are matched to types using the specified matcher object.
public Transformer ( Matcher matcher ) : SimpleFramework.Xml.Util
matcher Matcher /// this is used to match types to transforms ///
return SimpleFramework.Xml.Util

Valid() public method

This method is used to determine if the type specified can be transformed. This will use the Matcher to find a suitable transform, if one exists then this returns true, if not then this returns false. This is used during serialization to determine how to convert a field or method parameter.
public Valid ( Class, type ) : bool
type Class, /// the type to determine whether its transformable ///
return bool

Write() public method

This method is used to convert the provided value into an XML usable format. This is used in the serialization process when there is a need to convert a field value in to a string so that that value can be written as a valid XML entity.
public Write ( Object value, Class, type ) : String
value Object /// this is the value to be converted to a string ///
type Class, /// this is the type to convert to a string value ///
return String