KickJava   Java API By Example, From Geeks To Geeks.

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


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: EjbRelation.java,v 1.6 2004/05/28 13:43:14 durieuxp Exp $
25  * --------------------------------------------------------------------------
26  */

27
28 package org.objectweb.jonas_ejb.deployment.xml;
29
30 import java.util.Iterator JavaDoc;
31 import org.objectweb.jonas_lib.deployment.xml.AbsElement;
32 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
33
34 /**
35  * This class defines the implementation of the element ejb-relation
36  * @author JOnAS team
37  */

38
39 public class EjbRelation extends AbsElement {
40
41     /**
42      * description
43      */

44     private String JavaDoc description = null;
45
46     /**
47      * ejb-relation-name
48      */

49     private String JavaDoc ejbRelationName = null;
50
51
52     /**
53      * ejb-relationship-role list
54      */

55     private JLinkedList ejbRelationshipRoleList = null;
56
57
58     /**
59      * Constructor
60      */

61     public EjbRelation() {
62         super();
63         ejbRelationshipRoleList = new JLinkedList("ejb-relationship-role");
64     }
65
66     /**
67      * Gets the description
68      * @return the description
69      */

70     public String JavaDoc getDescription() {
71         return description;
72     }
73
74     /**
75      * Set the description
76      * @param description description
77      */

78     public void setDescription(String JavaDoc description) {
79         this.description = description;
80     }
81
82     /**
83      * Gets the ejb-relation-name
84      * @return the ejb-relation-name
85      */

86     public String JavaDoc getEjbRelationName() {
87         return ejbRelationName;
88     }
89
90     /**
91      * Set the ejb-relation-name
92      * @param ejbRelationName ejbRelationName
93      */

94     public void setEjbRelationName(String JavaDoc ejbRelationName) {
95         this.ejbRelationName = ejbRelationName;
96     }
97
98     /**
99      * Add a new ejb-relationship-role element to this object
100      * @param ejbRelationshipRole the ejb-relationship-role object
101      */

102     public void addEjbRelationshipRole(EjbRelationshipRole ejbRelationshipRole) {
103         ejbRelationshipRoleList.add(ejbRelationshipRole);
104     }
105
106     /**
107      * Gets the ejb-relationship-role list
108      * @return the ejb-relationship-role list
109      */

110     public JLinkedList getEjbRelationshipRoleList() {
111         return ejbRelationshipRoleList;
112     }
113
114     /**
115      * Gets the first ejb-relationship-role
116      * @return the ejb-relationship-role
117      */

118     public EjbRelationshipRole getEjbRelationshipRole() {
119         Iterator JavaDoc i = ejbRelationshipRoleList.iterator();
120         EjbRelationshipRole ejbRelationshipRole1 = (EjbRelationshipRole) i.next();
121         return ejbRelationshipRole1;
122     }
123
124
125     /**
126      * Gets the second ejb-relationship-role
127      * @return the ejb-relationship-role
128      */

129     public EjbRelationshipRole getEjbRelationshipRole2() {
130         Iterator JavaDoc i = ejbRelationshipRoleList.iterator();
131         EjbRelationshipRole ejbRelationshipRole2 = (EjbRelationshipRole) i.next();
132         ejbRelationshipRole2 = (EjbRelationshipRole) i.next();
133         return ejbRelationshipRole2;
134     }
135
136
137
138     /**
139      * Represents this element by it's XML description.
140      * @param indent use this indent for prexifing XML representation.
141      * @return the XML description of this object.
142      */

143     public String JavaDoc toXML(int indent) {
144         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
145         sb.append(indent(indent));
146         sb.append("<ejb-relation>\n");
147
148         indent += 2;
149
150         // description
151
sb.append(xmlElement(description, "description", indent));
152         // ejb-relation-name
153
sb.append(xmlElement(ejbRelationName, "ejb-relation-name", indent));
154         // ejb-relationship-role
155
if (ejbRelationshipRoleList != null) {
156             for (Iterator JavaDoc i = ejbRelationshipRoleList.iterator(); i.hasNext();) {
157                 sb.append(((EjbRelationshipRole) i.next()).toXML(indent));
158             }
159         }
160
161         indent -= 2;
162         sb.append(indent(indent));
163         sb.append("</ejb-relation>\n");
164
165         return sb.toString();
166     }
167 }
168
Popular Tags