org.jboss.xb.binding
Interface GenericObjectModelFactory

All Superinterfaces:
ObjectModelFactory
All Known Implementing Classes:
DelegatingObjectModelFactory, MappingObjectModelFactory, MetadataDrivenObjectModelFactory, SchemalessObjectModelFactory

public interface GenericObjectModelFactory
extends ObjectModelFactory

Direct implementations of ObjectModelFactory interface can be thought of as "typed" factories in a sense that parameter types of newChild, addChild and setValue methods (discovered by the framework at runtime with introspection) are supposed to be of specific Java classes (other than java.lang.Object) from the target class hierarchy.

In this interface, newChild, addChild and setValue methods are defined with arguments of type java.lang.Object.
The framework won't introspect an implementation of this interface for "typed" implementations of newChild, addChild and setValue methods. Instead it will call the declared generic methods and it's the responsibility of the implementation of this interface to recognize the types and build the object graph appropriately.

Version:
$Revision: 1.1.2.3 $
Author:
Alexey Loubyansky

Method Summary
 void addChild(Object parent, Object child, UnmarshallingContext ctx, String namespaceURI, String localName)
          This method is called when parsing of a not top-level XML element completed.
 Object newChild(Object parent, UnmarshallingContext ctx, String namespaceURI, String localName, Attributes attrs)
          This method is called when parsing of a new not top-level XML element started.
 void setValue(Object o, UnmarshallingContext ctx, 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 interface org.jboss.xb.binding.ObjectModelFactory
completeRoot, newRoot
 

Method Detail

newChild

Object newChild(Object parent,
                UnmarshallingContext ctx,
                String namespaceURI,
                String localName,
                Attributes attrs)
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.

Parameters:
parent - an object that represents the parent XML element in the object model
ctx - 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

void addChild(Object parent,
              Object child,
              UnmarshallingContext ctx,
              String namespaceURI,
              String localName)
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.

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
ctx - unmarshalling context
namespaceURI - namespace URI of the XML element
localName - local name of the XML element

setValue

void setValue(Object o,
              UnmarshallingContext ctx,
              String namespaceURI,
              String localName,
              String value)
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.

Parameters:
o - an object that represents the parent XML element in the Java object model
ctx - 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


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