KickJava   Java API By Example, From Geeks To Geeks.

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


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.MetadataQueryHint;
34 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedNativeQuery;
35
36 /**
37  * Object to hold onto an XML named native query metadata.
38  *
39  * @author Guy Pelletier
40  * @since TopLink EJB 3.0 Reference Implementation
41  */

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

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

57     public String JavaDoc getEJBQLString() {
58         return m_helper.getNodeTextValue(m_node, XMLConstants.QUERY);
59     }
60     
61     /**
62      * INTERNAL:
63      */

64     public List JavaDoc<MetadataQueryHint> getHints() {
65         if (m_hints == null) {
66             m_hints = new ArrayList JavaDoc<MetadataQueryHint>();
67             
68             NodeList JavaDoc hints = m_helper.getNodes(m_node, XMLConstants.QUERY_HINT);
69         
70             if (hints != null) {
71                 for (int i = 0; i < hints.getLength(); i++) {
72                     m_hints.add(new XMLQueryHint(hints.item(i), m_helper));
73                 }
74             }
75         }
76         
77         return m_hints;
78     }
79     
80     /**
81      * INTERNAL:
82      */

83     public String JavaDoc getName() {
84         return m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
85     }
86     
87     /**
88      * INTERNAL:
89      */

90     public Class JavaDoc getResultClass() {
91         return m_helper.getNodeValue(m_node, XMLConstants.ATT_RESULT_CLASS, void.class);
92     }
93     
94     /**
95      * INTERNAL:
96      */

97     public String JavaDoc getResultSetMapping() {
98         return m_helper.getNodeValue(m_node, XMLConstants.ATT_RESULT_SET_MAPPING, "");
99     }
100     
101     /**
102      * INTERNAL:
103      */

104     public boolean loadedFromAnnotations() {
105         return false;
106     }
107     
108     /**
109      * INTERNAL:
110      */

111     public boolean loadedFromXML() {
112         return true;
113     }
114 }
115
Popular Tags