001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005: *
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common Development
009: * and Distribution License("CDDL") (collectively, the "License"). You
010: * may not use this file except in compliance with the License. You can obtain
011: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
013: * language governing permissions and limitations under the License.
014: *
015: * When distributing the software, include this License Header Notice in each
016: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017: * Sun designates this particular file as subject to the "Classpath" exception
018: * as provided by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the License
020: * Header, with the fields enclosed by brackets [] replaced by your own
021: * identifying information: "Portions Copyrighted [year]
022: * [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * If you wish your version of this file to be governed by only the CDDL or
027: * only the GPL Version 2, indicate your decision by adding "[Contributor]
028: * elects to include this software in this distribution under the [CDDL or GPL
029: * Version 2] license." If you don't indicate a single choice of license, a
030: * recipient has the option to distribute your version of this file under
031: * either the CDDL, the GPL Version 2 or to extend the choice of license to
032: * its licensees as provided above. However, if you add GPL Version 2 code
033: * and therefore, elected the GPL Version 2 license, then the option applies
034: * only if the new code is made subject to such option by the copyright
035: * holder.
036: */
037: package oracle.toplink.essentials.internal.ejb.cmp3.xml.queries;
038:
039: import java.util.List;
040: import java.util.ArrayList;
041:
042: import org.w3c.dom.Node;
043: import org.w3c.dom.NodeList;
044:
045: import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper;
046: import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants;
047:
048: import oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataFieldResult;
049: import oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataEntityResult;
050:
051: /**
052: * Object to hold onto an xml entity result metadata.
053: *
054: * @author Guy Pelletier
055: * @since TopLink EJB 3.0 Reference Implementation
056: */
057: public class XMLEntityResult extends MetadataEntityResult {
058: protected Node m_node;
059: protected XMLHelper m_helper;
060:
061: /**
062: * INTERNAL:
063: */
064: public XMLEntityResult(Node node, XMLHelper helper) {
065: m_node = node;
066: m_helper = helper;
067: }
068:
069: /**
070: * INTERNAL:
071: */
072: public String getDiscriminatorColumn() {
073: return m_helper.getNodeValue(m_node,
074: XMLConstants.ATT_DISCRIMINATOR_COLUMN, "");
075: }
076:
077: /**
078: * INTERNAL:
079: * Note this attribute is required but we send in the default void.class
080: * object to ensure we go through the correct class loading.
081: */
082: public Class getEntityClass() {
083: return m_helper.getNodeValue(m_node,
084: XMLConstants.ATT_ENTITY_CLASS, void.class);
085: }
086:
087: /**
088: * INTERNAL:
089: */
090: public List<MetadataFieldResult> getFieldResults() {
091: if (m_fieldResults == null) {
092: m_fieldResults = new ArrayList<MetadataFieldResult>();
093: NodeList fieldResultNodes = m_helper.getNodes(m_node,
094: XMLConstants.FIELD_RESULT);
095:
096: if (fieldResultNodes != null) {
097: for (int i = 0; i < fieldResultNodes.getLength(); i++) {
098: m_fieldResults.add(new XMLFieldResult(
099: fieldResultNodes.item(i), m_helper));
100: }
101: }
102: }
103:
104: return m_fieldResults;
105: }
106: }
|