public abstract class MarkupExtension extends Object
Generally, the serialization process first tries to serialize an object to a string attribute
using a ValueSerializer
. If the ValueSerializer
cannot handle the object or the serialization
process enforces the output to be a complete XML element, the object is written as an XML element instead. This is
done either using a MarkupExtension
if present or by the default serialization mechanism.
In general, the serialization process can convert objects to XML elements on its own without having to provide a markup extension if certain requirements are met:
If the class has no setter method for a property, the property of that class is not written and thus cannot be deserialized.
If the class has no default constructor, the object cannot be serialized at all.
In the case where the default serialization process cannot handle an object properly, a MarkupExtension of
the class of the object is required. The MarkupExtension is supposed to adapt the class of the object
to a serializable form, i.e. a default constructor and getter and setter methods for the properties that are
supposed to be serialized. In addition to this, subclasses of MarkupExtension have to implement the method
provideValue(ILookup)
which is needed for the deserialization of such an XML element and constructs
the object from the given properties.
Note that getter and setter methods for properties of implementations of this class are not supposed to be called by client code. They usually mirror the properties that are contained in the objects they are supposed to provide means to be (de)serialized for. But the filling of these properties are not meant to be done via calling the respective setters, but are either filled by the extension itself or by the serialization process via reflection.
Constructor and Description |
---|
MarkupExtension() |
Modifier and Type | Method and Description |
---|---|
abstract Object |
provideValue(ILookup serviceProvider)
Returns an object that is set as the value of the target property for this markup extension.
|
public abstract Object provideValue(ILookup serviceProvider)
serviceProvider
- Object that can provide services for the markup extension.