KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > xml > sequencing > XMLTableGenerator


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.sequencing;
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.XMLConstants;
31
32 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLAccessor;
33
34 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataTableGenerator;
35
36 /**
37  * Object to hold onto an xml table generator metadata.
38  *
39  * @author Guy Pelletier
40  * @since TopLink EJB 3.0 Reference Implementation
41  */

42 public class XMLTableGenerator extends MetadataTableGenerator {
43     protected Node JavaDoc m_node;
44     protected XMLAccessor m_accessor;
45     
46     /**
47      * INTERNAL:
48      */

49     public XMLTableGenerator(Node JavaDoc node, XMLAccessor accessor) {
50         super(accessor.getDocumentName());
51         
52         m_node = node;
53         m_accessor = accessor;
54     }
55     
56     /**
57      * INTERNAL:
58      */

59     public int getAllocationSize() {
60         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_ALLOCATION_SIZE, 50);
61     }
62     
63     /**
64      * INTERNAL:
65      */

66     public String JavaDoc getCatalog() {
67         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_CATALOG, m_accessor.getCatalog());
68     }
69     
70     /**
71      * INTERNAL:
72      */

73     public int getInitialValue() {
74         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_INITIAL_VALUE, 0);
75     }
76     
77     /**
78      * INTERNAL:
79      */

80     public String JavaDoc getName() {
81         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_NAME);
82     }
83     
84     /**
85      * INTERNAL:
86      */

87     public String JavaDoc getPkColumnName() {
88         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_NAME);
89     }
90     
91     /**
92      * INTERNAL:
93      */

94     public String JavaDoc getPkColumnValue() {
95         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_VALUE);
96     }
97     
98     /**
99      * INTERNAL:
100      */

101     public String JavaDoc getSchema() {
102         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_SCHEMA, m_accessor.getSchema());
103     }
104     
105     /**
106      * INTERNAL:
107      */

108     public String JavaDoc getTable() {
109         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_TABLE);
110     }
111     
112     /**
113      * INTERNAL:
114      */

115     public List JavaDoc<String JavaDoc> getUniqueConstraints() {
116         if (m_uniqueConstraints == null) {
117             m_uniqueConstraints = new ArrayList JavaDoc<String JavaDoc>();
118             NodeList JavaDoc uniqueConstraintNodes = m_accessor.getHelper().getNodes(m_node, XMLConstants.UNIQUE_CONSTRAINTS);
119         
120             if (uniqueConstraintNodes != null) {
121                 for (int i = 0; i < uniqueConstraintNodes.getLength(); i++) {
122                     NodeList JavaDoc columnNameNodes = m_accessor.getHelper().getTextColumnNodes(uniqueConstraintNodes.item(i));
123                 
124                     if (columnNameNodes != null) {
125                         for (int k = 0; k < columnNameNodes.getLength(); k++) {
126                             String JavaDoc columnName = columnNameNodes.item(k).getNodeValue();
127                         
128                             if (columnName != null && !columnName.equals("")) {
129                                 m_uniqueConstraints.add(columnName);
130                             }
131                         }
132                     }
133                 }
134             }
135         }
136         
137         return m_uniqueConstraints;
138     }
139     
140     /**
141      * INTERNAL:
142      */

143     public String JavaDoc getValueColumnName() {
144         return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_VALUE_COLUMN_NAME);
145     }
146     
147     /**
148      * INTERNAL:
149      */

150     public boolean loadedFromAnnotations() {
151        return false;
152     }
153     
154     /**
155      * INTERNAL:
156      */

157     public boolean loadedFromXML() {
158        return true;
159     }
160 }
161
Popular Tags