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: Qname.java 4718 2004-05-10 12:06:09Z sauthieg $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_lib.deployment.xml;
026:
027: import javax.xml.namespace.QName;
028:
029: /**
030: * This class defines an implementation for a QName
031: * It is use by Soap-Header or Service-qname
032: * @author Florent Benoit
033: */
034: public class Qname extends AbsElement {
035:
036: /**
037: * Name of the element
038: */
039: private String name = null;
040:
041: /**
042: * Internal QName
043: */
044: private QName qName = null;
045:
046: /**
047: * Constructor : build a new object
048: */
049: public Qname() {
050: super ();
051: }
052:
053: // Setters
054:
055: /**
056: * Sets the QName of this object
057: * @param qName QName of this object
058: */
059: public void setQName(QName qName) {
060: this .qName = qName;
061: }
062:
063: /**
064: * Sets the Name of this object
065: * @param name name of this object
066: */
067: public void setName(String name) {
068: this .name = name;
069: }
070:
071: // Getters
072:
073: /**
074: * @return the QName of this object
075: */
076: public QName getQName() {
077: return qName;
078: }
079:
080: /**
081: * Represents this element by it's XML description.
082: * @param indent use this indent for prexifing XML representation.
083: * @return the XML description of this object.
084: */
085: public String toXML(int indent) {
086: StringBuffer sb = new StringBuffer();
087: sb.append(indent(indent));
088: //String prefix = qName.getPrefix();
089: String prefix = "pr";
090:
091: if (qName == null) {
092: return "";
093: }
094:
095: String namespaceURI = qName.getNamespaceURI();
096: String localPart = qName.getLocalPart();
097:
098: sb.append("<");
099: sb.append(name);
100: sb.append(" xmlns:");
101: sb.append(prefix);
102: sb.append("=\"");
103: sb.append(namespaceURI);
104: sb.append("\">");
105: sb.append(prefix);
106: sb.append(":");
107: sb.append(localPart);
108: sb.append("</");
109: sb.append(name);
110: sb.append(">\n");
111:
112: return sb.toString();
113: }
114:
115: }
|