org.jboss.xb.binding
Interface ObjectModelFactory

All Known Subinterfaces:
GenericObjectModelFactory
All Known Implementing Classes:
DelegatingObjectModelFactory, MappingObjectModelFactory, MetadataDrivenObjectModelFactory, SchemalessObjectModelFactory

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 methods newRoot 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:

Version:
$Revision: 1.1.2.3 $
Author:
Alexey Loubyansky

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

newRoot

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.

If 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.

Parameters:
root - an object that is the root or which contains the root of the object graph
ctx - unmarshalling context
namespaceURI - namespace URI of the root
localName - local name of the root
attrs - attributes of the root object
Returns:
the root of the object graph

completeRoot

Object completeRoot(Object root,
                    UnmarshallingContext ctx,
                    String namespaceURI,
                    String localName)
This method is called by the framework when unmarshalling of the object graph completed. The method returns the root object of the object graph. If at the beginning of unmarshalling 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.

Parameters:
root - the object returned by newRoot at the beginning of unmarshalling
ctx - unmarshalling context
namespaceURI - namespace URI that corresponds to the root
localName - local element name the root of the object graph is bound to
Returns:
the root of the object graph


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.