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.types.URI;
23  
24  import org.w3c.dom.Element;
25  
26  import org.apache.axis.message.addressing.util.TextExtractor;
27  
28  /***
29   * Class Address
30   * 
31   * @author Davanum Srinivas (dims@yahoo.com)
32   */
33  public class Address extends AttributedURI {
34  
35      /***
36       * Constructor Address
37       * 
38       * @param uri 
39       */
40      public Address(URI uri) {
41          super(uri);
42      }
43  
44      /***
45       * Constructor Address
46       * 
47       * @param uri 
48       * @throws MalformedURIException 
49       */
50      public Address(String uri) throws MalformedURIException {
51          this(new URI(uri));
52      }
53  
54      /***
55       * append DOM node to parent
56       * 
57       * @param parent 
58       */
59      public void append(Element parent) {
60          Element child = parent.getOwnerDocument().createElementNS(Constants.NS_URI_ADDRESSING_DEFAULT,
61                  Constants.ADDRESS);
62          child.appendChild(parent.getOwnerDocument().createTextNode(toString()));
63          parent.appendChild(child);
64      }
65  
66      public static Address fromSOAPElement(SOAPElement element) 
67          throws Exception {
68          String value = TextExtractor.getText(element);
69          return new Address(value);
70      }
71  
72      public static Address fromElement(Element element) 
73          throws Exception {
74          String value = TextExtractor.getText(element);
75          return new Address(value);
76      }
77  }
78  
79