C# Class Spring.Objects.Factory.Xml.AbstractObjectDefinitionParser

Abstract IObjectDefinitionParser implementation providing a number of convenience methods and a AbstractObjectDefinitionParser.ParseInternal template method that subclasses must override to provide the actual parsing logic.
Use this IObjectDefinitionParser implementation when you want to parse some arbitrarily complex XML into one or more IObjectDefinition ObjectDefinitions. If you just want to parse some XML into a single IObjectDefinition, you may wish to consider the simpler convenience extensions of this class, namely AbstractSingleObjectDefinitionParser and AbstractSimpleObjectDefinitionParser
Inheritance: IObjectDefinitionParser
Exibir arquivo Open project: spring-projects/spring-net

Public Properties

Property Type Description
ID_ATTRIBUTE string

Public Methods

Method Description
ParseElement ( XmlElement element, ParserContext parserContext ) : IObjectDefinition

Parse the specified XmlElement and register the resulting ObjectDefinitions with the ParserContext.Registry IObjectDefinitionRegistry embedded in the supplied ParserContext

This method is never invoked if the parser is namespace aware and was called to process the root node.

Protected Methods

Method Description
GetAttributeValue ( XmlElement element, string attributeName ) : string

Returns the value of the element's attribute or null, if the attribute is not specified.

This is a helper for bypassing the behavior of XmlElement.GetAttribute(string) to return string.Empty if the attribute does not exist.

GetAttributeValue ( XmlElement element, string attributeName, string defaultValue ) : string

Returns the value of the element's attribute or defaultValue, if the attribute is not specified.

This is a helper for bypassing the behavior of XmlElement.GetAttribute(string) to return string.Empty if the attribute does not exist.

ParseInternal ( XmlElement element, ParserContext parserContext ) : AbstractObjectDefinition

Central template method to actually parse the supplied XmlElement into one or more IObjectDefinitions.

RegisterObjectDefinition ( Spring.Objects.Factory.Config.ObjectDefinitionHolder definition, IObjectDefinitionRegistry registry ) : void

Registers the supplied ObjectDefinitionHolder with the supplied IObjectDefinitionRegistry.

Subclasses can override this method to control whether or not the supplied ObjectDefinitionHolder is actually even registered, or to register even more objects.

The default implementation registers the supplied ObjectDefinitionHolder with the supplied ObjectDefinitionHolder only if the IsNested parameter is false, because one typically does not want inner objects to be registered as top level objects.

ResolveId ( XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext ) : string

Resolves the ID for the supplied IObjectDefinition.

When using ShouldGenerateId generation, a name is generated automatically. Otherwise, the ID is extracted from the "id" attribute, potentially with a ShouldGenerateIdAsFallback fallback to a generated id.

Method Details

GetAttributeValue() protected static method

Returns the value of the element's attribute or null, if the attribute is not specified.
This is a helper for bypassing the behavior of XmlElement.GetAttribute(string) to return string.Empty if the attribute does not exist.
protected static GetAttributeValue ( XmlElement element, string attributeName ) : string
element System.Xml.XmlElement
attributeName string
return string

GetAttributeValue() protected static method

Returns the value of the element's attribute or defaultValue, if the attribute is not specified.
This is a helper for bypassing the behavior of XmlElement.GetAttribute(string) to return string.Empty if the attribute does not exist.
protected static GetAttributeValue ( XmlElement element, string attributeName, string defaultValue ) : string
element System.Xml.XmlElement
attributeName string
defaultValue string
return string

ParseElement() public method

Parse the specified XmlElement and register the resulting ObjectDefinitions with the ParserContext.Registry IObjectDefinitionRegistry embedded in the supplied ParserContext

This method is never invoked if the parser is namespace aware and was called to process the root node.

public ParseElement ( XmlElement element, ParserContext parserContext ) : IObjectDefinition
element System.Xml.XmlElement The element to be parsed.
parserContext ParserContext The object encapsulating the current state of the parsing process. /// Provides access to a IObjectDefinitionRegistry
return IObjectDefinition

ParseInternal() protected abstract method

Central template method to actually parse the supplied XmlElement into one or more IObjectDefinitions.
protected abstract ParseInternal ( XmlElement element, ParserContext parserContext ) : AbstractObjectDefinition
element System.Xml.XmlElement The element that is to be parsed into one or more s
parserContext ParserContext The the object encapsulating the current state of the parsing process; /// provides access to a
return Spring.Objects.Factory.Support.AbstractObjectDefinition

RegisterObjectDefinition() protected method

Registers the supplied ObjectDefinitionHolder with the supplied IObjectDefinitionRegistry.
Subclasses can override this method to control whether or not the supplied ObjectDefinitionHolder is actually even registered, or to register even more objects.

The default implementation registers the supplied ObjectDefinitionHolder with the supplied ObjectDefinitionHolder only if the IsNested parameter is false, because one typically does not want inner objects to be registered as top level objects.

protected RegisterObjectDefinition ( Spring.Objects.Factory.Config.ObjectDefinitionHolder definition, IObjectDefinitionRegistry registry ) : void
definition Spring.Objects.Factory.Config.ObjectDefinitionHolder The object definition to be registered.
registry IObjectDefinitionRegistry The registry that the bean is to be registered with.
return void

ResolveId() protected method

Resolves the ID for the supplied IObjectDefinition.
When using ShouldGenerateId generation, a name is generated automatically. Otherwise, the ID is extracted from the "id" attribute, potentially with a ShouldGenerateIdAsFallback fallback to a generated id.
/// if no unique name could be generated for the given object definition ///
protected ResolveId ( XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext ) : string
element System.Xml.XmlElement The element that the object definition has been built from.
definition Spring.Objects.Factory.Support.AbstractObjectDefinition The object definition to be registered.
parserContext ParserContext The the object encapsulating the current state of the parsing process; /// provides access to a
return string

Property Details

ID_ATTRIBUTE public_oe static_oe property

Constant for the ID attribute
public static string ID_ATTRIBUTE
return string