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: Application.java 7467 2005-10-04 12:53:14Z sauthieg $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_ear.deployment.xml;
027:
028: import org.objectweb.jonas_lib.deployment.xml.AbsDescriptionElement;
029: import org.objectweb.jonas_lib.deployment.xml.DescriptionGroupXml;
030: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
031: import org.objectweb.jonas_lib.deployment.xml.TopLevelElement;
032:
033: /**
034: * This class defines the implementation of the element application
035: *
036: * @author JOnAS team
037: */
038:
039: public class Application extends AbsDescriptionElement implements
040: TopLevelElement, DescriptionGroupXml {
041:
042: /**
043: * module
044: */
045: private JLinkedList moduleList = null;
046:
047: /**
048: * security-role
049: */
050: private JLinkedList securityRoleList = null;
051:
052: /**
053: * Constructor
054: */
055: public Application() {
056: super ();
057: moduleList = new JLinkedList("module");
058: securityRoleList = new JLinkedList("security-role");
059: }
060:
061: /**
062: * Gets the module
063: * @return the module
064: */
065: public JLinkedList getModuleList() {
066: return moduleList;
067: }
068:
069: /**
070: * Set the module
071: * @param moduleList module
072: */
073: public void setModuleList(JLinkedList moduleList) {
074: this .moduleList = moduleList;
075: }
076:
077: /**
078: * Add a new module element to this object
079: * @param module the moduleobject
080: */
081: public void addModule(Module module) {
082: moduleList.add(module);
083: }
084:
085: /**
086: * Gets the security-role
087: * @return the security-role
088: */
089: public JLinkedList getSecurityRoleList() {
090: return securityRoleList;
091: }
092:
093: /**
094: * Set the security-role
095: * @param securityRoleList securityRole
096: */
097: public void setSecurityRoleList(JLinkedList securityRoleList) {
098: this .securityRoleList = securityRoleList;
099: }
100:
101: /**
102: * Add a new security-role element to this object
103: * @param securityRole the securityRoleobject
104: */
105: public void addSecurityRole(SecurityRole securityRole) {
106: securityRoleList.add(securityRole);
107: }
108:
109: /**
110: * Represents this element by it's XML description.
111: * @param indent use this indent for prexifing XML representation.
112: * @return the XML description of this object.
113: */
114: public String toXML(int indent) {
115: StringBuffer sb = new StringBuffer();
116: sb.append(indent(indent));
117: sb.append("<application>\n");
118: indent += 2;
119:
120: // icon
121: if (getIcon() != null) {
122: sb.append(getIcon().toXML(indent));
123: }
124: // display-name
125: if (getDisplayName() != null) {
126: sb.append(xmlElement(getDisplayName(), "display-name",
127: indent));
128: }
129: // description
130: if (getDescription() != null) {
131: sb.append(xmlElement(getDescription(), "description",
132: indent));
133: }
134: // module
135: sb.append(getModuleList().toXML(indent));
136: // security-role
137: sb.append(getSecurityRoleList().toXML(indent));
138:
139: indent -= 2;
140: sb.append(indent(indent));
141: sb.append("</application>\n");
142:
143: return sb.toString();
144: }
145: }
|