Package | org.spicefactory.lib.xml.mapper |
Class | public class XmlObjectMappings |
Inheritance | XmlObjectMappings ![]() |
Example:
var mapper:XmlObjectMapper = XmlObjectMappings
.forNamespace("http://www.mynamespace.com")
.withRootElement(BookStore)
.mappedClasses(Book, Author, Price, DeliveryMethod)
.build();
Method | Defined By | ||
---|---|---|---|
Processes all specified mappings and returns the concrete mapper instance
for the root element. | XmlObjectMappings | ||
choiceId(id:String, ... mappedClasses):XmlObjectMappings
Specifies the classes that are allowed as an element in the choice with the specified id. | XmlObjectMappings | ||
Adds a custom mapper to the group of mappings. | XmlObjectMappings | ||
The naming strategy to use for transforming property names to XML attribute and element names. | XmlObjectMappings | ||
The mapping type to use for all simple types that do not have a metadata tag. | XmlObjectMappings | ||
forNamespace(uri:String):RootElementSetup [static]
Entry point for creating mappings for a particular XML namespace. | XmlObjectMappings | ||
[static]
Entry point for creating mappings for unqualified XML elements. | XmlObjectMappings | ||
mappedClasses(... types):XmlObjectMappings
Adds all specified classes to the group of mappings. | XmlObjectMappings | ||
Merges an existing group of mappings into this group. | XmlObjectMappings | ||
newMapperBuilder(mappedType:Class, elementName:QName = null):MetadataMapperBuilder
Creates a new builder for a custom mapper. | XmlObjectMappings |
Method | Defined By | ||
---|---|---|---|
postProcess(mappers:Array):void
Hook for subclasses that wish to postprocess some of the mappings. | XmlObjectMappings |
build | () | method |
public function build():XmlObjectMapper
Processes all specified mappings and returns the concrete mapper instance for the root element.
ReturnsXmlObjectMapper — the mapper for the root element
|
choiceId | () | method |
public function choiceId(id:String, ... mappedClasses):XmlObjectMappings
Specifies the classes that are allowed as an element in the choice with the specified id.
This call is necessary to tell the mapper which elements qualify to be used for properties
that have the [ChoiceId]
metadata. The list of classes can also contain
classes for which custom mappings have already been specified for this group.
For any type in the list where no mapping has been created yet, the framework
will create one automatically in the same way like with calling mappedClasses
.
Parameters
id:String — the id of the choice
| |
... mappedClasses — the classes that represent valid elements for the choice
|
XmlObjectMappings — this builder for method chaining
|
customMapper | () | method |
public function customMapper(mapper:XmlObjectMapper):XmlObjectMappings
Adds a custom mapper to the group of mappings.
If you want to combine metadata configuration with programmatic setup newMapperBuilder
should be used instead.
Parameters
mapper:XmlObjectMapper — the mapper to add to the group of mappings.
|
XmlObjectMappings — this builder for method chaining
|
defaultNamingStrategy | () | method |
public function defaultNamingStrategy(strategy:NamingStrategy):XmlObjectMappings
The naming strategy to use for transforming property names to XML attribute and element names. The default strategy transforms camel-case names to the dash notation most commonly used for XML names (e.g. changing 'serviceName' to 'service-name').
Parameters
strategy:NamingStrategy — the naming strategy to use for transforming property names to XML attribute and element names
|
XmlObjectMappings — this builder for method chaining
|
defaultSimpleMappingType | () | method |
public function defaultSimpleMappingType(type:SimpleMappingType):XmlObjectMappings
The mapping type to use for all simple types that do not have a metadata tag.
The default is SimpleMappingType.ATTRIBUTE
.
Simple types are Boolean, String, Number, int, uint, Class, ClassInfo and Date.
If you want to map any other AS3 type to simple XML types you have to configure
them explicitly with metadata tags on the property (or programmatically with a custom
XmlObjectMapper).
Parameters
type:SimpleMappingType — the mapping type to use for all simple types that do not have a metadata tag
|
XmlObjectMappings — this builder for method chaining
|
forNamespace | () | method |
public static function forNamespace(uri:String):RootElementSetup
Entry point for creating mappings for a particular XML namespace.
Parameters
uri:String — the URI of the XML namespace
|
RootElementSetup — an instance that allows to specify the root element mapping
|
forUnqualifiedElements | () | method |
public static function forUnqualifiedElements():RootElementSetup
Entry point for creating mappings for unqualified XML elements.
ReturnsRootElementSetup — an instance that allows to specify the root element mapping
|
mappedClasses | () | method |
public function mappedClasses(... types):XmlObjectMappings
Adds all specified classes to the group of mappings.
For all these types only metadata on the properties will be processed to determine
the type of mapping to apply. For properties without metadata the defaults will be applied
(mapping to attributes for simple types and to child element choices for complex types).
If you need to specify a mapping with custom, programmatic mapping setup, use one of the
other methods of this class like customMapper
or newMapperBuilder
.
Parameters
... types — the classes to add the the group of mappings
|
XmlObjectMappings — this builder for method chaining
|
mergedMappings | () | method |
public function mergedMappings(mappings:XmlObjectMappings):XmlObjectMappings
Merges an existing group of mappings into this group. Allows to mix multiple namespaces or simply reuse existing setups. The merge operation will add all mappings of the specified group to this group and also merges any choices with an id that also exists in this group.
Parameters
mappings:XmlObjectMappings |
XmlObjectMappings — this builder for method chaining
|
newMapperBuilder | () | method |
public function newMapperBuilder(mappedType:Class, elementName:QName = null):MetadataMapperBuilder
Creates a new builder for a custom mapper. This builder allows to combine metadata configuration
with programmatic setup. For any property where a mapping was specified programmatically through
the returned MetadataMapperBuilder
metadata tags on the property will be ignored.
Parameters
mappedType:Class — the type to create a new builder for
| |
elementName:QName (default = null ) — the (optional) name of the mapped element (if omitted the default NamingStrategy will determine the name)
|
MetadataMapperBuilder — a new builder for a custom mapper
|
postProcess | () | method |
protected function postProcess(mappers:Array):void
Hook for subclasses that wish to postprocess some of the mappings. The default implementation does nothing.
Parameters
mappers:Array — all mappers configured by this mappings group
|