KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.w3c.dom.Node JavaDoc;
25 import org.w3c.dom.NodeList JavaDoc;
26
27 import java.util.List JavaDoc;
28 import java.util.ArrayList 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.MetadataNamedQuery;
35
36 /**
37  * Object to hold onto a named query metadata that came from either XML or an
38  * annotation.
39  *
40  * @author Guy Pelletier
41  * @since TopLink EJB 3.0 Reference Implementation
42  */

43 public class XMLNamedQuery extends MetadataNamedQuery {
44     protected Node JavaDoc m_node;
45     protected XMLHelper m_helper;
46     
47     /**
48      * INTERNAL:
49      */

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

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

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

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

91     public boolean loadedFromAnnotations() {
92         return false;
93     }
94     
95     /**
96      * INTERNAL:
97      */

98     public boolean loadedFromXML() {
99         return true;
100     }
101 }
102
Popular Tags