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: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or 1any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer: Florent BENOIT
022: * --------------------------------------------------------------------------
023: * $Id: ServletMapping.java 4799 2004-05-25 14:26:36Z sauthieg $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_web.deployment.xml;
026:
027: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
028:
029: /**
030: * This class defines the implementation of the element servlet-mapping
031: * @author Florent Benoit
032: */
033: public class ServletMapping extends AbsElement {
034:
035: /**
036: * Name of the servlet
037: */
038: private String servletName = null;
039:
040: /**
041: * URL pattern of the servlet
042: */
043: private String urlPattern = null;
044:
045: // Setters
046:
047: /**
048: * Sets the name of the servlet
049: * @param servletName name of the servlet
050: */
051: public void setServletName(String servletName) {
052: this .servletName = servletName;
053: }
054:
055: /**
056: * Sets the url-pattern of the servlet
057: * @param urlPattern url-pattern of the servlet
058: */
059: public void setUrlPattern(String urlPattern) {
060: this .urlPattern = urlPattern;
061: }
062:
063: // Getters
064:
065: /**
066: * @return the name of the servlet of the servlet-mapping
067: */
068: public String getServletName() {
069: return servletName;
070: }
071:
072: /**
073: * @return the url of the servlet of the servlet-mapping
074: */
075: public String getUrlPattern() {
076: return urlPattern;
077: }
078:
079: /**
080: * Represents this element by it's XML description.
081: * @param indent use this indent for prexifing XML representation.
082: * @return the XML description of this object.
083: */
084: public String toXML(int indent) {
085: StringBuffer sb = new StringBuffer();
086: sb.append(indent(indent));
087: sb.append("<servlet-mapping>\n");
088:
089: indent += 2;
090:
091: // servlet-name
092: sb.append(xmlElement(servletName, "servlet-name", indent));
093:
094: // url-pattern
095: sb.append(xmlElement(urlPattern, "url-pattern", indent));
096:
097: indent -= 2;
098: sb.append(indent(indent));
099: sb.append("</servlet-mapping>\n");
100:
101: return sb.toString();
102: }
103:
104: }
|