|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ObjectModelFactory
All object model factories must implement this interface. Object model factories are used on unmarshalling to build an object graph that is a representation of the XML content unmarshalled.
Each object model factory must implement methodsnewRoot
and completeRoot
defined in this interface, plus a set of newChild
, addChild
and setValue
methods that will be descovered by the framework at runtime with introspection.
The contract for methods discovered at runtime with introspection:
newChild
methods
newChild
method must have five arguments:
java.lang.Object
) for this new childorg.jboss.xml.binding.UnmarshallingContext
java.lang.String
java.lang.String
org.xml.sax.Attributes
newChild()
method returns either a new instance of
the child object that represents the XML element with the namespace URI and local name
(in this case, the child XML element is said to be accepted, i.e. should be represented in the object graph)
or null
if this child XML element should be ignored, i.e. not be represented in the object graph.
addChild
methods
addChild()
method are:
java.lang.Object
) of the childnewChild
method that was called when parsing of this child XML element started)org.jboss.xml.binding.UnmarshallingContext
as java.lang.String
java.lang.String
addChild
method is called, the child object is supposed to be populated with all the data from
the corresponding XML element. The child object now can be validated and added to the parent.
setValue
methods
java.lang.Object
) which was returned earlier
by the newChild
method (that was called when parsing of the parent XML element started)
for which the value of an XML element was readorg.jboss.xml.binding.UnmarshallingContext
java.lang.String
java.lang.String
java.lang.String
setValue
method the object model factory is supposed to set the value on the field which represents
the parsed XML element possibly converting the parsed XML element value to the field's Java type.
Method Summary | |
---|---|
Object |
completeRoot(Object root,
UnmarshallingContext ctx,
String namespaceURI,
String localName)
This method is called by the framework when unmarshalling of the object graph completed. |
Object |
newRoot(Object root,
UnmarshallingContext ctx,
String namespaceURI,
String localName,
Attributes attrs)
This method is called by the framework and returns the root of the object graph. |
Method Detail |
---|
Object newRoot(Object root, UnmarshallingContext ctx, String namespaceURI, String localName, Attributes attrs)
root
argument is null, the factory is supposed to create and return a new one
that is going to be the real root object of the graph or an object that will represent the root object
during unmarshalling and which will be used to create the real root object when unmarshalling is complete
in completeRoot
if the real root object can't be created while its children are not available,
e.g. no no-arg constructor or other reasons.
If root
argument is not null (i.e. a user provided the root object through the
org.jboss.xml.binding.Unmarshaller
) then the factory could just return it as is or
extract the real root from the root
argument based on the namespace URI and local name
if root
argument wraps/contains the real root.
root
- an object that is the root or which contains the root of the object graphctx
- unmarshalling contextnamespaceURI
- namespace URI of the rootlocalName
- local name of the rootattrs
- attributes of the root object
Object completeRoot(Object root, UnmarshallingContext ctx, String namespaceURI, String localName)
newRoot
returned not the real root object but an
object that represented the root during unmarshalling, the real root object should be created
and returned.
root
- the object returned by newRoot
at the beginning of unmarshallingctx
- unmarshalling contextnamespaceURI
- namespace URI that corresponds to the rootlocalName
- local element name the root of the object graph is bound to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |