Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.xml.binding
Interface ObjectModelFactory

All Known Subinterfaces:
  GenericObjectModelFactory

All Known Implementing Classes:
  DelegatingObjectModelFactory, MappingObjectModelFactory, SchemalessObjectModelFactory

public interface ObjectModelFactory

The interface all object model factories must implement. Object model factories are used on unmarshalling to build the object graph.

Each object model factory must implement one method `newRoot` defined in the ObjectModelFactory interface and a set of newChild, addChild and setValue methods descovered by the framework at runtime with introspection. So the following methods should be implemented:

- `newRoot` method

       public Object newRoot(java.lang.Object root,
                             org.jboss.xml.binding.ContentNavigator navigator,
                             java.lang.String namespaceURI,
                             java.lang.String localName,
                             org.xml.sax.Attributes attrs)

  This method is called on the object model factory by the framework and returns the root of the object model. If the `root` argument is null the factory is supposed to create and return a new one. If the `root` argument is not null (i.e. the user provided the root object through the org.jboss.xml.binding.Unmarshaller) the factory should either just return it as is or extract the real root from the `root` argument corresponding to the namespace URI and local name.
- a set of `newChild` methods. This method is called by the framework on the object model factory when parsing of a new XML element started. Each `newChild` method must have five arguments:
  1. parent object of a concrete Java type (not java.lang.Object) for this new child
  2. instance of org.jboss.xml.binding.ContentNavigator
  3. namespace URI of the child XML element as java.lang.String
  4. local name of the child XML element as java.lang.String
  5. attributes of the child XML element as org.xml.sax.Attributes
  Each `newChild()` method returns either a new instance of a child object that represents the XML element with the namespace URI and local name (in this case, the child XML element is 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.
- a set of `addChild` methods This method is called on the object model factory by the framework when parsing of a child XML element is complete. The arguments of the `addChild()` method are:
  1. parent object of a conrete Java type (not java.lang.Object) of the child
  2. child object of a concrete Java type (returned earlier by the `newChild`)
  3. instance of org.jboss.xml.binding.ContentNavigator
  4. namespace URI for the child XML element as java.lang.String
  5. local name for the child XML element as java.lang.String
  When `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.
- a set of `setValue` methods This method is called on the object model factory by the framework when a new XML element with text content was parsed. The method must have four arguments:
  1. an object of a concrete Java type (not java.lang.Object) which was returned earlier by a `newChild` for which the value of an XML element was read
  2. instance of org.jboss.xml.binding.ContentNavigator
  3. namespace URI of the child XML element as java.lang.String
  4. local name of the child XML element as java.lang.String
  5. the value of the child XML element as java.lang.String
  In `setValue` method the object model factory is supposed to set a value on the field which represents the parsed XML element possibly converting the parsed XML element value to the field's Java type.

Version:
  `$Revision: 1.9.2.1 $`
Author:
  Alexey Loubyansky

Method Summary
`Object` | `newRoot(Object root, ContentNavigator navigator, String namespaceURI, String localName, Attributes attrs)` This method is called by the object model factory and returns the root of the object graph.

Method Detail

### newRoot

    public Object newRoot(Object root,
                          ContentNavigator navigator,
                          String namespaceURI,
                          String localName,
                          Attributes attrs)

  This method is called by the object model factory and returns the root of the object graph. If the `root` argument is null the factory is supposed to create and return a new one. If the `root` argument is not null (i.e. the user provided the root object through the org.jboss.xml.binding.Unmarshaller) then the factory should either just return it as is or extract the real root from the `root` argument based on the namespace URI and local name.

  Parameters:
    `root` - an object that is the root or which contains the root object
    `navigator` - content navigator
    `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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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