KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > xml > accessors > XMLEmbeddedAccessor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors;
23
24 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor;
25 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.EmbeddedAccessor;
26
27 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataAccessibleObject;
28 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataClass;
29
30 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor;
31
32 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLColumn;
33
34 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants;
35 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper;
36
37 import oracle.toplink.essentials.mappings.AggregateObjectMapping;
38
39 import org.w3c.dom.Node JavaDoc;
40 import org.w3c.dom.NodeList JavaDoc;
41
42 /**
43  * An XML extended embedded relationship accessor.
44  *
45  * @author Guy Pelletier
46  * @since TopLink EJB 3.0 Reference Implementation
47  */

48 public class XMLEmbeddedAccessor extends EmbeddedAccessor {
49     protected Node JavaDoc m_node;
50     protected XMLHelper m_helper;
51     
52     /**
53      * INTERNAL:
54      */

55     public XMLEmbeddedAccessor(MetadataAccessibleObject accessibleObject, Node JavaDoc node, XMLClassAccessor classAccessor, boolean isEmbeddedId) {
56         super(accessibleObject, classAccessor, isEmbeddedId);
57         m_node = node;
58         m_helper = classAccessor.getHelper();
59     }
60     
61     /**
62      * INTERNAL: (OVERRIDE)
63      */

64     protected void processAttributeOverrides(AggregateObjectMapping mapping) {
65         NodeList JavaDoc nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTE_OVERRIDE);
66         
67         if (nodes != null) {
68             for (int i = 0; i < nodes.getLength(); i++) {
69                 processAttributeOverride(mapping, new XMLColumn(nodes.item(i), m_helper, getAnnotatedElement()));
70             }
71         }
72         
73         // WIP should we look on the class or not?
74
}
75     
76     /**
77      * INTERNAL: (OVERRIDE)
78      * Fast track processing a ClassAccessor for the given descriptor.
79      * Inheritance root classes and embeddables may be fast tracked.
80      *
81      * NOTE: The class passed in may not have any XML representation. If so,
82      * pass up to the parent.
83      *
84      * WIP ... shared code ... move to XMLAccessorHelper.
85      */

86     protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
87         Node JavaDoc node = m_helper.locateEntityNode(descriptor.getJavaClass());
88         
89         if (node != null) {
90             XMLClassAccessor accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), node, m_helper, m_processor, descriptor);
91             descriptor.setClassAccessor(accessor);
92             accessor.process();
93             accessor.setIsProcessed();
94             return accessor;
95         } else {
96             return super.processAccessor(descriptor);
97         }
98     }
99 }
100
Popular Tags