C# Class SimpleFramework.Xml.Core.Source

The Source object acts as a contextual object that is used to store all information regarding an instance of serialization or deserialization. This maintains the Strategy as well as the Filter used to replace template variables. When serialization and deserialization are performed the source is required as it acts as a factory for objects used in the process.

For serialization the source object is required as a factory for Schema objects, which are used to visit each field in the class that can be serialized. Also this can be used to get any data entered into the session Map object.

When deserializing the source object provides the contextual data used to replace template variables extracted from the XML source. This is performed using the Filter object. Also, as in serialization it acts as a factory for the Schema objects used to examine the serializable fields of an object.

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

Public Methods

Method Description
GetAttribute ( Object key ) : Object

This is used to acquire the attribute mapped to the specified key. In order for this to return a value it must have been previously placed into the context as it is empty by default.

GetCaller ( Class type ) : Caller

This is used to acquire the Caller object. This is used to call the callback methods within the object. If the object contains no callback methods then this will return an object that does not invoke any methods that are invoked.

GetDecorator ( Class type ) : Decorator

This will acquire the Decorator for the type. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.

GetInstance ( Class type ) : Instance

This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.

GetInstance ( Value value ) : Instance

This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.

GetName ( Class type ) : String

This is used to acquire the name of the specified type using the Root annotation for the class. This will use either the name explicitly provided by the annotation or it will use the name of the class that the annotation was placed on if there is no explicit name for the root.

GetOverride ( Type type, InputNode node ) : Value

This is used to resolve and load a class for the given element. The class should be of the same type or a subclass of the class specified. It can be resolved using the details within the provided XML element, if the details used do not represent any serializable values they should be removed so as not to disrupt the deserialization process. For example the default strategy removes all "class" attributes from the given elements.

GetProperty ( String text ) : String

Replaces any template variables within the provided string. This is used in the deserialization process to replace variables with system properties, environment variables, or used specified mappings. If a template variable does not have a mapping from the Filter is is left unchanged.

GetScanner ( Class type ) : Scanner

This creates a Scanner object that can be used to examine the fields within the XML class schema. The scanner maintains information when a field from within the scanner is visited, this allows the serialization and deserialization process to determine if all required XML annotations are used.

GetSchema ( Class type ) : Schema

This creates a Schema object that can be used to examine the fields within the XML class schema. The schema maintains information when a field from within the schema is visited, this allows the serialization and deserialization process to determine if all required XML annotations are used.

GetVersion ( Class type ) : Version

This returns the version for the type specified. The version is used to determine how the deserialization process is performed. If the version of the type is different from the version for the XML document, then deserialization is done in a best effort.

IsFloat ( Class type ) : bool
IsFloat ( Type type ) : bool

This is used to determine if the type specified is a floating point type. Types that are floating point are the double and float primitives as well as the java types for this primitives.

IsPrimitive ( Class type ) : bool

This is used to determine whether the scanned class represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.

IsPrimitive ( Type type ) : bool

This is used to determine whether the scanned type represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.

IsStrict ( ) : bool

This is used to determine if the deserialization mode is strict or not. If this is not strict then deserialization will be done in such a way that additional elements and attributes can be ignored. This allows external XML formats to be used without having to match the object structure to the XML fully.

SetOverride ( Type type, Object value, OutputNode node ) : bool

This is used to attach elements or attributes to the given element during the serialization process. This method allows the strategy to augment the XML document so that it can be deserialized using a similar strategy. For example the default strategy adds a "class" attribute to the element.

Source ( Strategy strategy, Support support, Style style ) : SimpleFramework.Xml.Filter

Constructor for the Source object. This is used to maintain a context during the serialization process. It holds the Strategy and Context used in the serialization process. The same source instance is used for each XML element evaluated in a the serialization process.

Source ( Strategy strategy, Support support, Style style, bool strict ) : SimpleFramework.Xml.Filter

Constructor for the Source object. This is used to maintain a context during the serialization process. It holds the Strategy and Context used in the serialization process. The same source instance is used for each XML element evaluated in a the serialization process.

Method Details

GetAttribute() public method

This is used to acquire the attribute mapped to the specified key. In order for this to return a value it must have been previously placed into the context as it is empty by default.
public GetAttribute ( Object key ) : Object
key Object /// this is the name of the attribute to retrieve ///
return Object

GetCaller() public method

This is used to acquire the Caller object. This is used to call the callback methods within the object. If the object contains no callback methods then this will return an object that does not invoke any methods that are invoked.
public GetCaller ( Class type ) : Caller
type Class /// this is the type to acquire the caller for ///
return Caller

GetDecorator() public method

This will acquire the Decorator for the type. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.
public GetDecorator ( Class type ) : Decorator
type Class /// this is the type to acquire the decorator for ///
return Decorator

GetInstance() public method

This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
public GetInstance ( Class type ) : Instance
type Class /// this is the type that is to be instantiated ///
return Instance

GetInstance() public method

This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
public GetInstance ( Value value ) : Instance
value Value /// this contains information on the object instance ///
return Instance

GetName() public method

This is used to acquire the name of the specified type using the Root annotation for the class. This will use either the name explicitly provided by the annotation or it will use the name of the class that the annotation was placed on if there is no explicit name for the root.
public GetName ( Class type ) : String
type Class /// this is the type to acquire the root name for ///
return String

GetOverride() public method

This is used to resolve and load a class for the given element. The class should be of the same type or a subclass of the class specified. It can be resolved using the details within the provided XML element, if the details used do not represent any serializable values they should be removed so as not to disrupt the deserialization process. For example the default strategy removes all "class" attributes from the given elements.
public GetOverride ( Type type, InputNode node ) : Value
type System.Type /// this is the type of the root element expected ///
node InputNode /// this is the element used to resolve an override ///
return Value

GetProperty() public method

Replaces any template variables within the provided string. This is used in the deserialization process to replace variables with system properties, environment variables, or used specified mappings. If a template variable does not have a mapping from the Filter is is left unchanged.
public GetProperty ( String text ) : String
text String /// this is processed by the template engine object ///
return String

GetScanner() public method

This creates a Scanner object that can be used to examine the fields within the XML class schema. The scanner maintains information when a field from within the scanner is visited, this allows the serialization and deserialization process to determine if all required XML annotations are used.
public GetScanner ( Class type ) : Scanner
type Class /// the schema class the scanner is created for ///
return Scanner

GetSchema() public method

This creates a Schema object that can be used to examine the fields within the XML class schema. The schema maintains information when a field from within the schema is visited, this allows the serialization and deserialization process to determine if all required XML annotations are used.
public GetSchema ( Class type ) : Schema
type Class /// the schema class the schema is created for ///
return Schema

GetVersion() public method

This returns the version for the type specified. The version is used to determine how the deserialization process is performed. If the version of the type is different from the version for the XML document, then deserialization is done in a best effort.
public GetVersion ( Class type ) : Version
type Class /// this is the type to acquire the version for ///
return Version

IsFloat() public method

public IsFloat ( Class type ) : bool
type Class /// this is the type to determine if it is a float ///
return bool

IsFloat() public method

This is used to determine if the type specified is a floating point type. Types that are floating point are the double and float primitives as well as the java types for this primitives.
public IsFloat ( Type type ) : bool
type System.Type /// this is the type to determine if it is a float ///
return bool

IsPrimitive() public method

This is used to determine whether the scanned class represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.
public IsPrimitive ( Class type ) : bool
type Class /// this is the type to determine if it is primitive ///
return bool

IsPrimitive() public method

This is used to determine whether the scanned type represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.
public IsPrimitive ( Type type ) : bool
type System.Type /// this is the type to determine if it is primitive ///
return bool

IsStrict() public method

This is used to determine if the deserialization mode is strict or not. If this is not strict then deserialization will be done in such a way that additional elements and attributes can be ignored. This allows external XML formats to be used without having to match the object structure to the XML fully.
public IsStrict ( ) : bool
return bool

SetOverride() public method

This is used to attach elements or attributes to the given element during the serialization process. This method allows the strategy to augment the XML document so that it can be deserialized using a similar strategy. For example the default strategy adds a "class" attribute to the element.
public SetOverride ( Type type, Object value, OutputNode node ) : bool
type System.Type /// this is the field type for the associated value ///
value Object /// this is the instance variable being serialized ///
node OutputNode /// this is the element used to represent the value ///
return bool

Source() public method

Constructor for the Source object. This is used to maintain a context during the serialization process. It holds the Strategy and Context used in the serialization process. The same source instance is used for each XML element evaluated in a the serialization process.
public Source ( Strategy strategy, Support support, Style style ) : SimpleFramework.Xml.Filter
strategy Strategy /// this is used to resolve the classes used ///
support Support /// this is the context used to process strings ///
style SimpleFramework.Xml.Stream.Style /// this is the style used for the serialization ///
return SimpleFramework.Xml.Filter

Source() public method

Constructor for the Source object. This is used to maintain a context during the serialization process. It holds the Strategy and Context used in the serialization process. The same source instance is used for each XML element evaluated in a the serialization process.
public Source ( Strategy strategy, Support support, Style style, bool strict ) : SimpleFramework.Xml.Filter
strategy Strategy /// this is used to resolve the classes used ///
support Support /// this is the context used to process strings ///
style SimpleFramework.Xml.Stream.Style /// this is the style used for the serialization ///
strict bool /// this determines whether to read in strict mode ///
return SimpleFramework.Xml.Filter