org.jboss.xb.binding
Class DelegatingObjectModelFactory

java.lang.Object
  extended by org.jboss.xb.binding.DelegatingObjectModelFactory
All Implemented Interfaces:
GenericObjectModelFactory, ObjectModelFactory

public class DelegatingObjectModelFactory
extends Object
implements GenericObjectModelFactory

todo come up with a nicer class name

Version:
$Revision: 1.1.2.3 $
Author:
Alexey Loubyansky

Constructor Summary
DelegatingObjectModelFactory(ObjectModelFactory typedFactory)
           
 
Method Summary
 void addChild(Object parent, Object child, UnmarshallingContext navigator, String namespaceURI, String localName)
          This method is called when parsing of a not top-level XML element completed.
 Object completeRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName)
          This method is called by the framework when unmarshalling of the object graph completed.
 Object newChild(Object parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
          This method is called when parsing of a new not top-level XML element started.
 Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
          This method is called by the framework and returns the root of the object graph.
 void setValue(Object o, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
          This method is called when a new not top-level simple XML element (with text content) was parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingObjectModelFactory

public DelegatingObjectModelFactory(ObjectModelFactory typedFactory)
Method Detail

newRoot

public Object newRoot(Object root,
                      UnmarshallingContext navigator,
                      String namespaceURI,
                      String localName,
                      Attributes attrs)
Description copied from interface: ObjectModelFactory
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.

Specified by:
newRoot in interface ObjectModelFactory
Parameters:
root - an object that is the root or which contains the root of the object graph
navigator - 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

newChild

public Object newChild(Object parent,
                       UnmarshallingContext navigator,
                       String namespaceURI,
                       String localName,
                       Attributes attrs)
Description copied from interface: GenericObjectModelFactory
This method is called when parsing of a new not top-level XML element started. The method should either return an object that represents this XML element in the Java object model or null if this XML element is not represented in the Java object model.

Specified by:
newChild in interface GenericObjectModelFactory
Parameters:
parent - an object that represents the parent XML element in the object model
navigator - unmarshalling context
namespaceURI - namespace URI of the XML element
localName - local name of the XML element
attrs - attributes of the XML element
Returns:
an object that represents the XML element in the Java object model or null

addChild

public void addChild(Object parent,
                     Object child,
                     UnmarshallingContext navigator,
                     String namespaceURI,
                     String localName)
Description copied from interface: GenericObjectModelFactory
This method is called when parsing of a not top-level XML element completed. The object that represents this XML element in the Java model should now be completely initialized. An implementation of this method could validate the object that represents the XML element in the Java object model and add it to the parent.

Specified by:
addChild in interface GenericObjectModelFactory
Parameters:
parent - an object that represents the parent XML element in the object model
child - an object that was returned by the newChild method that was called when parsing of this XML element started
navigator - unmarshalling context
namespaceURI - namespace URI of the XML element
localName - local name of the XML element

setValue

public void setValue(Object o,
                     UnmarshallingContext navigator,
                     String namespaceURI,
                     String localName,
                     String value)
Description copied from interface: GenericObjectModelFactory
This method is called when a new not top-level simple XML element (with text content) was parsed. Such elements are usually mapped to fields in Java classes. So, usually, an implementation of this method will set the field the XML element is bound to in the parent object to the parsed value possibly applying some unmarshalling rule for it.

Specified by:
setValue in interface GenericObjectModelFactory
Parameters:
o - an object that represents the parent XML element in the Java object model
navigator - unmarshalling context
namespaceURI - namespace URI of the XML element
localName - local name of the XML element
value - value of the XML element as it appears in the XML content

completeRoot

public Object completeRoot(Object root,
                           UnmarshallingContext navigator,
                           String namespaceURI,
                           String localName)
Description copied from interface: ObjectModelFactory
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.

Specified by:
completeRoot in interface ObjectModelFactory
Parameters:
root - the object returned by newRoot at the beginning of unmarshalling
navigator - 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.