KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > xb > binding > GenericObjectModelFactory


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.xb.binding;
23
24 import org.xml.sax.Attributes JavaDoc;
25
26 /**
27  * Direct implementations of <code>ObjectModelFactory</code> interface can be thought of as "typed" factories
28  * in a sense that parameter types of <code>newChild</code>, <code>addChild</code> and <code>setValue</code> methods
29  * (discovered by the framework at runtime with introspection) are supposed to be of specific Java classes
30  * (other than <code>java.lang.Object</code>) from the target class hierarchy.
31  * <p/>In this interface, <code>newChild</code>, <code>addChild</code> and <code>setValue</code> methods are defined
32  * with arguments of type <code>java.lang.Object</code>.
33  * <br/>The framework won't introspect an implementation of this interface for "typed" implementations of
34  * <code>newChild</code>, <code>addChild</code> and <code>setValue</code> methods.
35  * Instead it will call the declared generic methods and it's the responsibility of the implementation
36  * of this interface to recognize the types and build the object graph appropriately.
37  *
38  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
39  * @version <tt>$Revision: 1958 $</tt>
40  */

41 public interface GenericObjectModelFactory
42    extends ObjectModelFactory
43 {
44    /**
45     * This method is called when parsing of a new not top-level XML element started.
46     * The method should either return an object that represents this XML element in the Java object model or
47     * null if this XML element is not represented in the Java object model.
48     *
49     * @param parent an object that represents the parent XML element in the object model
50     * @param ctx unmarshalling context
51     * @param namespaceURI namespace URI of the XML element
52     * @param localName local name of the XML element
53     * @param attrs attributes of the XML element
54     * @return an object that represents the XML element in the Java object model or null
55     */

56    Object JavaDoc newChild(Object JavaDoc parent, UnmarshallingContext ctx, String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs);
57
58    /**
59     * This method is called when parsing of a not top-level XML element completed.
60     * The object that represents this XML element in the Java model should now be completely initialized.
61     * An implementation of this method could validate the object that represents the XML element
62     * in the Java object model and add it to the parent.
63     *
64     * @param parent an object that represents the parent XML element in the object model
65     * @param child an object that was returned by the <code>newChild</code> method that
66     * was called when parsing of this XML element started
67     * @param ctx unmarshalling context
68     * @param namespaceURI namespace URI of the XML element
69     * @param localName local name of the XML element
70     */

71    void addChild(Object JavaDoc parent, Object JavaDoc child, UnmarshallingContext ctx, String JavaDoc namespaceURI, String JavaDoc localName);
72
73    /**
74     * This method is called when a new not top-level simple XML element (with text content) was parsed.
75     * Such elements are usually mapped to fields in Java classes. So, usually, an implementation of this method
76     * will set the field the XML element is bound to in the parent object to the parsed value possibly applying
77     * some unmarshalling rule for it.
78     *
79     * @param o an object that represents the parent XML element in the Java object model
80     * @param ctx unmarshalling context
81     * @param namespaceURI namespace URI of the XML element
82     * @param localName local name of the XML element
83     * @param value value of the XML element as it appears in the XML content
84     */

85    void setValue(Object JavaDoc o, UnmarshallingContext ctx, String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value);
86 }
87
Popular Tags