View Javadoc

1   /*
2    * Copyright  1999-2004 The Apache Software Foundation.
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   */
17  
18  package org.apache.axis.message.addressing;
19  
20  import javax.xml.soap.SOAPElement;
21  
22  import org.apache.axis.utils.XMLUtils;
23  
24  import org.apache.axis.message.addressing.util.TextExtractor;
25  
26  import org.w3c.dom.Element;
27  
28  import javax.xml.namespace.QName;
29  
30  /***
31   * Class PortType
32   * 
33   * @author Davanum Srinivas (dims@yahoo.com)
34   */
35  public class PortType extends AttributedQName {
36      /***
37       * Constructor PortType
38       * 
39       * @param qname 
40       */
41      public PortType(QName qname) {
42          super(qname);
43      }
44  
45      /***
46       * Constructor PortType
47       * 
48       * @param namespace
49       * @param localName
50       */
51      public PortType(String namespace, 
52                      String localName) {
53          super(namespace, localName);
54      }
55  
56      /***
57       * append DOM node to parent
58       * 
59       * @param parent 
60       */
61      public void append(Element parent) {
62          Element pt = parent.getOwnerDocument().createElementNS(
63                           Constants.NS_URI_ADDRESSING_DEFAULT,
64                           Constants.PORT_TYPE
65                       );
66          String value = XMLUtils.getStringForQName(this, pt);
67          pt.appendChild(parent.getOwnerDocument().createTextNode(value));
68          parent.appendChild(pt);
69      }
70  
71      public static PortType fromSOAPElement(SOAPElement element) 
72          throws Exception {
73          String value = TextExtractor.getText(element);
74          QName qname = TextExtractor.getQName(value, element);
75          return new PortType(qname);
76      }
77  
78      public static PortType fromElement(Element element) 
79          throws Exception {
80          String value = TextExtractor.getText(element);
81          QName qname = XMLUtils.getQNameFromString(value, element);
82          return new PortType(qname);
83      }
84      
85  }
86  
87