C# Class SimpleFramework.Xml.Core.Primitive

The Primitive object is used to provide serialization for primitive objects. This can serialize and deserialize any primitive object and enumerations. Primitive values are converted to text using the String.valueOf method. Enumerated types are converted using the Enum.valueOf method.

Text within attributes and elements can contain template variables similar to those found in Apache Ant. This allows values such as system properties, environment variables, and user specified mappings to be inserted into the text in place of the template reference variables. <example attribute="${value}> <text>Text with a ${variable}</text> </example> In the above XML element the template variable references will be checked against the Filter object used by the context serialization object. If they corrospond to a filtered value then they are replaced, if not the text remains unchanged.

Inheritance: Converter
显示文件 Open project: ngallagher/simplexml Class Usage Examples

Public Methods

Method Description
Primitive ( Context context, Type type ) : SimpleFramework.Xml.Strategy

Constructor for the Primitive object. This is used to convert an XML node to a primitive object and vice versa. To perform deserialization the primitive object requires the context object used for the instance of serialization to performed.

Primitive ( Context context, Type type, String empty ) : SimpleFramework.Xml.Strategy

Constructor for the Primitive object. This is used to convert an XML node to a primitive object and vice versa. To perform deserialization the primitive object requires the context object used for the instance of serialization to performed.

Read ( InputNode node ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

Read ( InputNode node, Class type ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

Read ( InputNode node, Object value ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

ReadElement ( InputNode node ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

ReadElement ( InputNode node, Instance value ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

ReadTemplate ( String value, Class type ) : Object

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.

Validate ( InputNode node ) : bool

This validate method will validate the primitive by checking the node text. If the value is a reference then this will not extract any value from the node. Transformation of the extracted value is not done as it can not account for template variables. Thus any text extracted is valid.

ValidateElement ( InputNode node ) : bool

This validateElement method validates a primitive by checking the node text. If the value is a reference then this will not extract any value from the node. Transformation of the extracted value is not done as it can not account for template variables. Thus any text extracted is valid.

Write ( OutputNode node, Object source ) : void

This write method will serialize the contents of the provided object to the given XML element. This will use the String.valueOf method to convert the object to a string if the object represents a primitive, if however the object represents an enumerated type then the text value is created using Enum.name.

Method Details

Primitive() public method

Constructor for the Primitive object. This is used to convert an XML node to a primitive object and vice versa. To perform deserialization the primitive object requires the context object used for the instance of serialization to performed.
public Primitive ( Context context, Type type ) : SimpleFramework.Xml.Strategy
context Context /// the context object used for the serialization ///
type System.Type /// this is the type of primitive this represents ///
return SimpleFramework.Xml.Strategy

Primitive() public method

Constructor for the Primitive object. This is used to convert an XML node to a primitive object and vice versa. To perform deserialization the primitive object requires the context object used for the instance of serialization to performed.
public Primitive ( Context context, Type type, String empty ) : SimpleFramework.Xml.Strategy
context Context /// the context object used for the serialization ///
type System.Type /// this is the type of primitive this represents ///
empty String /// this is the value used to represent a null value ///
return SimpleFramework.Xml.Strategy

Read() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public Read ( InputNode node ) : Object
node InputNode /// this is the node to be converted to a primitive ///
return Object

Read() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public Read ( InputNode node, Class type ) : Object
node InputNode /// this is the node to be converted to a primitive ///
type Class /// this is the type to read the primitive with ///
return Object

Read() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public Read ( InputNode node, Object value ) : Object
node InputNode /// this is the node to be converted to a primitive ///
value Object /// this is the original primitive value used ///
return Object

ReadElement() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public ReadElement ( InputNode node ) : Object
node InputNode /// this is the node to be converted to a primitive ///
return Object

ReadElement() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public ReadElement ( InputNode node, Instance value ) : Object
node InputNode /// this is the node to be converted to a primitive ///
value Instance /// this is the instance to set the result to ///
return Object

ReadTemplate() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public ReadTemplate ( String value, Class type ) : Object
value String /// this is the value to be processed as a template ///
type Class /// this is the type that that the primitive is ///
return Object

Validate() public method

This validate method will validate the primitive by checking the node text. If the value is a reference then this will not extract any value from the node. Transformation of the extracted value is not done as it can not account for template variables. Thus any text extracted is valid.
public Validate ( InputNode node ) : bool
node InputNode /// this is the node to be validated as a primitive ///
return bool

ValidateElement() public method

This validateElement method validates a primitive by checking the node text. If the value is a reference then this will not extract any value from the node. Transformation of the extracted value is not done as it can not account for template variables. Thus any text extracted is valid.
public ValidateElement ( InputNode node ) : bool
node InputNode /// this is the node to be validated as a primitive ///
return bool

Write() public method

This write method will serialize the contents of the provided object to the given XML element. This will use the String.valueOf method to convert the object to a string if the object represents a primitive, if however the object represents an enumerated type then the text value is created using Enum.name.
public Write ( OutputNode node, Object source ) : void
node OutputNode /// this is the XML element to have its text set ///
source Object /// this is the object to be serialized ///
return void