KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > xml > queries > XMLEntityResult


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.queries;
23
24 import java.util.List JavaDoc;
25 import java.util.ArrayList JavaDoc;
26
27 import org.w3c.dom.Node JavaDoc;
28 import org.w3c.dom.NodeList JavaDoc;
29
30 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper;
31 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants;
32
33 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataFieldResult;
34 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataEntityResult;
35
36 /**
37  * Object to hold onto an xml entity result metadata.
38  *
39  * @author Guy Pelletier
40  * @since TopLink EJB 3.0 Reference Implementation
41  */

42 public class XMLEntityResult extends MetadataEntityResult {
43     protected Node JavaDoc m_node;
44     protected XMLHelper m_helper;
45
46     /**
47      * INTERNAL:
48      */

49     public XMLEntityResult(Node JavaDoc node, XMLHelper helper) {
50         m_node = node;
51         m_helper = helper;
52     }
53     
54     /**
55      * INTERNAL:
56      */

57     public String JavaDoc getDiscriminatorColumn() {
58         return m_helper.getNodeValue(m_node, XMLConstants.ATT_DISCRIMINATOR_COLUMN, "");
59     }
60     
61     /**
62      * INTERNAL:
63      * Note this attribute is required but we send in the default void.class
64      * object to ensure we go through the correct class loading.
65      */

66     public Class JavaDoc getEntityClass() {
67         return m_helper.getNodeValue(m_node, XMLConstants.ATT_ENTITY_CLASS, void.class);
68     }
69     
70     /**
71      * INTERNAL:
72      */

73     public List JavaDoc<MetadataFieldResult> getFieldResults() {
74         if (m_fieldResults == null) {
75             m_fieldResults = new ArrayList JavaDoc<MetadataFieldResult>();
76             NodeList JavaDoc fieldResultNodes = m_helper.getNodes(m_node, XMLConstants.FIELD_RESULT);
77             
78             if (fieldResultNodes != null) {
79                 for (int i = 0; i < fieldResultNodes.getLength(); i++) {
80                     m_fieldResults.add(new XMLFieldResult(fieldResultNodes.item(i), m_helper));
81                 }
82             }
83         }
84         
85         return m_fieldResults;
86     }
87 }
88
Popular Tags