View Javadoc

1   /*
2    *  Copyright (c) 2008 Rodrigo Ruiz
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.apache.axis.message.addressing;
17  
18  import javax.xml.namespace.QName;
19  
20  import org.apache.axis.message.addressing.util.AddressingUtils;
21  import org.apache.axis.utils.XMLUtils;
22  import org.w3c.dom.Document;
23  import org.w3c.dom.Element;
24  
25  /**
26   * Java content class for AttributedQName complex type.
27   * <p>
28   * The following schema fragment specifies the expected content contained within
29   * this java content object. (defined at
30   * http://schemas.xmlsoap.org/ws/2004/08/addressing line 98)
31   *
32   * <pre>
33   * &lt;complexType name=&quot;AttributedQName&quot;&gt;
34   *   &lt;simpleContent&gt;
35   *     &lt;extension base=&quot;&lt;http://www.w3.org/2001/XMLSchema&gt;QName&quot;&gt;
36   *     &lt;/extension&gt;
37   *   &lt;/simpleContent&gt;
38   * &lt;/complexType&gt;
39   * </pre>
40   *
41   * @author Davanum Srinivas
42   * @author Rodrigo Ruiz
43   * @version $Revision: 14 $
44   */
45  public class AttributedQName extends QName implements DOMAppendable {
46  
47    /**
48     * <code>serialVersionUID</code> attribute.
49     */
50    private static final long serialVersionUID = 4575840707201336233L;
51  
52    /**
53     * Constructor AttributedQName.
54     *
55     * @param qname Qualified name
56     */
57    public AttributedQName(QName qname) {
58      super(qname.getNamespaceURI(), qname.getLocalPart(), qname.getPrefix());
59    }
60  
61    /**
62     * Constructor AttributedQName.
63     *
64     * @param namespace name space
65     * @param localPart local name
66     */
67    public AttributedQName(String namespace, String localPart) {
68      super(namespace, localPart);
69    }
70  
71    /**
72     * {@inheritDoc}
73     */
74    public final void append(Element parent, String elementName) {
75      append(AddressingUtils.getAddressingVersion(), parent, elementName);
76    }
77  
78    /**
79     * {@inheritDoc}
80     */
81    public void append(AddressingVersion version, Element parent, String elementName) {
82      Document doc = parent.getOwnerDocument();
83      Element pt = doc.createElementNS(version.getNamespace(), elementName);
84      String value = XMLUtils.getStringForQName(this, pt);
85      pt.appendChild(doc.createTextNode(value));
86      parent.appendChild(pt);
87    }
88  
89    /**
90     * {@inheritDoc}
91     */
92    public void append(Element parent) {
93      append(parent, "qname");
94    }
95  }