KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > xml > binding > ObjectModelProvider


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.xml.binding;
8
9 /**
10  * The interface all object model providers must implement. Object model providers are used on marshalling
11  * providing data for XML content based on the object model and XML schema or DTD.
12  * <p/>
13  * Each object model provider must implement one method <code>getRoot</code> defined in ObjectModelProvider interface
14  * and a set of getChildren, getElementValue and getAttributeValue methods descovered by the framework at runtime
15  * with introspection.
16  * <p/>So, the following methods should be implemented:
17  * <ul>
18  * <li><code>getRoot</code> method
19  * <pre>
20  * java.lang.Object getRoot(java.lang.Object o, java.lang.String namespaceURI, java.lang.String localName)
21  * </pre>
22  * This method is called on the object model provider by the framework when a root XML element is marshalled.
23  * The method returns an object that represents the root of the XML content corresponding to the namespace URI and
24  * local name.
25  * </li>
26  * <li>a set of <code>getChildren</code> methods
27  * This method is called on the object model provider by the framework when marshalling of a new XML element started.
28  * Each <code>getChildren</code> method must have three arguments:
29  * <ol>
30  * <li>parent object of a concrete Java type (not java.lang.Object) that is "asked" for its children</li>
31  * <li>namespace URI of the child XML element as java.lang.String</li>
32  * <li>local name of the child element as java.lang.String</li>
33  * </ol>
34  * A <code>getChildren</code> method returns children that represent the namespace URI and local name in XML content.
35  * The method can return null if there are no children in this object graph corresponding to the namespace and local name.
36  * The method can return a single object if there is only one child object corresponding to the namespace and local name.
37  * If there are many children that match the namespace URI and local name, the method can return them as an array,
38  * java.util.List, java.util.Collection or java.util.Iterator.
39  * </li>
40  * <li>a set of <code>getElementValue</code> methods
41  * This method is called on the object model provider by the framework for objects that represent XML elements with
42  * simple content, i.e. elements that don't contain nested XML elements.
43  * The method must have three arguments:
44  * <ol>
45  * <li>an object of a concrete Java type (not java.lang.Object) that is "asked" to provide a value of the XML element
46  * being marshalled</li>
47  * <li>namespace URI as java.lang.String of the XML element being marshalled</li>
48  * <li>local name as java.lang.String of the XML element being marshalled</li>
49  * </ol>
50  * The method returns either null if the object model does not have any value corresponding to the namespace URI
51  * and local name (in this case the XML content will not contain this XML element) or the actual value of the XML element.
52  * </li>
53  * <li>a set of <code>getAttributeValue</code> methods
54  * This method is called on the object model provider by the framework for objects that represent XML elements with
55  * attributes.
56  * The method must have three arguments:
57  * <ol>
58  * <li>an object of a concrete Java type (not java.lang.Object) that is "asked" to provide a value for the XML attribute
59  * being marshalled</li>
60  * <li>namespace URI of the XML attribute being marshalled</li>
61  * <li>local name of the XML attribute being marshalled</li>
62  * </ol>
63  * The method returns either null if the object graph does not have any value corresponding to the namespace URI
64  * and local name (in this case the XML content will not contain this attribute) or the actual value of the XML attribute.
65  * </li>
66  * </ol>
67  *
68  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
69  * @version <tt>$Revision: 1.4.2.5 $</tt>
70  */

71 public interface ObjectModelProvider
72 {
73    /**
74     * Called by the framework when a root XML element is marshalled.
75     *
76     * @param o the root of the object graph
77     * @param namespaceURI namespace URI of the root XML element being marshalled
78     * @param localName local name of the root XML element being marshalled
79     * @return an object that represents the root XML element corresponding to the namespace URI and local name
80     */

81    Object JavaDoc getRoot(Object JavaDoc o, String JavaDoc namespaceURI, String JavaDoc localName);
82 }
83
Popular Tags