KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > xml > JdbcMapping


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  *
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or 1any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  *
22  * Initial developer: JOnAS team
23  * --------------------------------------------------------------------------
24  * $Id: JdbcMapping.java,v 1.9 2004/05/10 11:45:44 sauthieg Exp $
25  * --------------------------------------------------------------------------
26  */

27 package org.objectweb.jonas_ejb.deployment.xml;
28
29 import org.objectweb.jonas_lib.deployment.xml.AbsElement;
30 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
31 /**
32  * This class defines the implementation of the element jdbc-mapping
33  *
34  * @author JOnAS team
35  */

36
37 public class JdbcMapping extends AbsElement {
38
39     /**
40      * jndi-name
41      */

42     private String JavaDoc jndiName = null;
43
44     /**
45      * jdbc-table-name
46      */

47     private String JavaDoc jdbcTableName = null;
48
49     /**
50      * automatic-pk
51      */

52     private String JavaDoc automaticPk = null;
53
54     /**
55      * jdbcAutomaticPkFieldName
56      */

57     private String JavaDoc jdbcAutomaticPkFieldName = null;
58
59     /**
60      * cmp-field-jdbc-mapping
61      */

62     private JLinkedList cmpFieldJdbcMappingList = null;
63
64     /**
65      * finder-method-jdbc-mapping
66      */

67     private JLinkedList finderMethodJdbcMappingList = null;
68
69
70     /**
71      * Constructor
72      */

73     public JdbcMapping() {
74         super();
75         cmpFieldJdbcMappingList = new JLinkedList("cmp-field-jdbc-mapping");
76         finderMethodJdbcMappingList = new JLinkedList("finder-method-jdbc-mapping");
77     }
78
79     /**
80      * Gets the jndi-name
81      * @return the jndi-name
82      */

83     public String JavaDoc getJndiName() {
84         return jndiName;
85     }
86
87     /**
88      * Set the jndi-name
89      * @param jndiName jndiName
90      */

91     public void setJndiName(String JavaDoc jndiName) {
92         this.jndiName = jndiName;
93     }
94
95     /**
96      * Gets the jdbc-table-name
97      * @return the jdbc-table-name
98      */

99     public String JavaDoc getJdbcTableName() {
100         return jdbcTableName;
101     }
102
103     /**
104      * Set the jdbc-table-name
105      * @param jdbcTableName jdbcTableName
106      */

107     public void setJdbcTableName(String JavaDoc jdbcTableName) {
108         this.jdbcTableName = jdbcTableName;
109     }
110
111     /**
112      * Set the jdbcAutomaticPkFieldName
113      * @param jdbcAutomaticPkFieldName jdbcAutomaticPkFieldName
114      */

115     public void setJdbcAutomaticPkFieldName(String JavaDoc jdbcAutomaticPkFieldName) {
116         this.jdbcAutomaticPkFieldName = jdbcAutomaticPkFieldName;
117     }
118
119     /**
120      * Gets the jdbcAutomaticPkFieldName
121      * @return the jdbcAutomaticPkFieldName
122      */

123     public String JavaDoc getJdbcAutomaticPkFieldName() {
124         return jdbcAutomaticPkFieldName;
125     }
126
127     /**
128      * Gets the cmp-field-jdbc-mapping
129      * @return the cmp-field-jdbc-mapping
130      */

131     public JLinkedList getCmpFieldJdbcMappingList() {
132         return cmpFieldJdbcMappingList;
133     }
134
135     /**
136      * Get the automatic-pk
137      * @return automaticPk String Value
138      */

139     public String JavaDoc getAutomaticPk() {
140         return automaticPk;
141     }
142
143     /**
144      * Set the automatic-pk
145      * @param automaticPk automaticPk
146      */

147     public void setAutomaticPk(String JavaDoc automaticPk) {
148         this.automaticPk = automaticPk;
149     }
150
151     /**
152      * Set the cmp-field-jdbc-mapping
153      * @param cmpFieldJdbcMappingList cmpFieldJdbcMapping
154      */

155     public void setCmpFieldJdbcMappingList(JLinkedList cmpFieldJdbcMappingList) {
156         this.cmpFieldJdbcMappingList = cmpFieldJdbcMappingList;
157     }
158
159     /**
160      * Add a new cmp-field-jdbc-mapping element to this object
161      * @param cmpFieldJdbcMapping the cmpFieldJdbcMappingobject
162      */

163     public void addCmpFieldJdbcMapping(CmpFieldJdbcMapping cmpFieldJdbcMapping) {
164         cmpFieldJdbcMappingList.add(cmpFieldJdbcMapping);
165     }
166
167     /**
168      * Gets the finder-method-jdbc-mapping
169      * @return the finder-method-jdbc-mapping
170      */

171     public JLinkedList getFinderMethodJdbcMappingList() {
172         return finderMethodJdbcMappingList;
173     }
174
175     /**
176      * Set the finder-method-jdbc-mapping
177      * @param finderMethodJdbcMappingList finderMethodJdbcMapping
178      */

179     public void setFinderMethodJdbcMappingList(JLinkedList finderMethodJdbcMappingList) {
180         this.finderMethodJdbcMappingList = finderMethodJdbcMappingList;
181     }
182
183     /**
184      * Add a new finder-method-jdbc-mapping element to this object
185      * @param finderMethodJdbcMapping the finderMethodJdbcMappingobject
186      */

187     public void addFinderMethodJdbcMapping(FinderMethodJdbcMapping finderMethodJdbcMapping) {
188         finderMethodJdbcMappingList.add(finderMethodJdbcMapping);
189     }
190
191     /**
192      * Represents this element by it's XML description.
193      * @param indent use this indent for prexifing XML representation.
194      * @return the XML description of this object.
195      */

196     public String JavaDoc toXML(int indent) {
197         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
198         sb.append(indent(indent));
199         sb.append("<jdbc-mapping>\n");
200
201         indent += 2;
202
203         // jndi-name
204
sb.append(xmlElement(jndiName, "jndi-name", indent));
205         // jdbc-table-name
206
sb.append(xmlElement(jdbcTableName, "jdbc-table-name", indent));
207         // automatic-pk
208
sb.append(xmlElement(automaticPk, "automatic-pk", indent));
209         // jdbcAutomaticPkFieldName
210
sb.append(xmlElement(jdbcAutomaticPkFieldName, "jdbcAutomaticPkFieldName", indent));
211         // cmp-field-jdbc-mapping
212
sb.append(cmpFieldJdbcMappingList.toXML(indent));
213         // finder-method-jdbc-mapping
214
sb.append(finderMethodJdbcMappingList.toXML(indent));
215         indent -= 2;
216         sb.append(indent(indent));
217         sb.append("</jdbc-mapping>\n");
218
219         return sb.toString();
220     }
221 }
222
Popular Tags