001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: *
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or 1any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: * Initial developer: JOnAS team
023: * --------------------------------------------------------------------------
024: * $Id: EjbRelation.java 4837 2004-05-28 13:43:14Z durieuxp $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_ejb.deployment.xml;
027:
028: import java.util.Iterator;
029: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
030: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
031:
032: /**
033: * This class defines the implementation of the element ejb-relation
034: * @author JOnAS team
035: */
036:
037: public class EjbRelation extends AbsElement {
038:
039: /**
040: * description
041: */
042: private String description = null;
043:
044: /**
045: * ejb-relation-name
046: */
047: private String ejbRelationName = null;
048:
049: /**
050: * ejb-relationship-role list
051: */
052: private JLinkedList ejbRelationshipRoleList = null;
053:
054: /**
055: * Constructor
056: */
057: public EjbRelation() {
058: super ();
059: ejbRelationshipRoleList = new JLinkedList(
060: "ejb-relationship-role");
061: }
062:
063: /**
064: * Gets the description
065: * @return the description
066: */
067: public String getDescription() {
068: return description;
069: }
070:
071: /**
072: * Set the description
073: * @param description description
074: */
075: public void setDescription(String description) {
076: this .description = description;
077: }
078:
079: /**
080: * Gets the ejb-relation-name
081: * @return the ejb-relation-name
082: */
083: public String getEjbRelationName() {
084: return ejbRelationName;
085: }
086:
087: /**
088: * Set the ejb-relation-name
089: * @param ejbRelationName ejbRelationName
090: */
091: public void setEjbRelationName(String ejbRelationName) {
092: this .ejbRelationName = ejbRelationName;
093: }
094:
095: /**
096: * Add a new ejb-relationship-role element to this object
097: * @param ejbRelationshipRole the ejb-relationship-role object
098: */
099: public void addEjbRelationshipRole(
100: EjbRelationshipRole ejbRelationshipRole) {
101: ejbRelationshipRoleList.add(ejbRelationshipRole);
102: }
103:
104: /**
105: * Gets the ejb-relationship-role list
106: * @return the ejb-relationship-role list
107: */
108: public JLinkedList getEjbRelationshipRoleList() {
109: return ejbRelationshipRoleList;
110: }
111:
112: /**
113: * Gets the first ejb-relationship-role
114: * @return the ejb-relationship-role
115: */
116: public EjbRelationshipRole getEjbRelationshipRole() {
117: Iterator i = ejbRelationshipRoleList.iterator();
118: EjbRelationshipRole ejbRelationshipRole1 = (EjbRelationshipRole) i
119: .next();
120: return ejbRelationshipRole1;
121: }
122:
123: /**
124: * Gets the second ejb-relationship-role
125: * @return the ejb-relationship-role
126: */
127: public EjbRelationshipRole getEjbRelationshipRole2() {
128: Iterator i = ejbRelationshipRoleList.iterator();
129: EjbRelationshipRole ejbRelationshipRole2 = (EjbRelationshipRole) i
130: .next();
131: ejbRelationshipRole2 = (EjbRelationshipRole) i.next();
132: return ejbRelationshipRole2;
133: }
134:
135: /**
136: * Represents this element by it's XML description.
137: * @param indent use this indent for prexifing XML representation.
138: * @return the XML description of this object.
139: */
140: public String toXML(int indent) {
141: StringBuffer sb = new StringBuffer();
142: sb.append(indent(indent));
143: sb.append("<ejb-relation>\n");
144:
145: indent += 2;
146:
147: // description
148: sb.append(xmlElement(description, "description", indent));
149: // ejb-relation-name
150: sb.append(xmlElement(ejbRelationName, "ejb-relation-name",
151: indent));
152: // ejb-relationship-role
153: if (ejbRelationshipRoleList != null) {
154: for (Iterator i = ejbRelationshipRoleList.iterator(); i
155: .hasNext();) {
156: sb.append(((EjbRelationshipRole) i.next())
157: .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: }
|