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.soap.SOAPElement; 19 20 import org.apache.axis.message.addressing.util.TextExtractor; 21 import org.apache.axis.types.URI; 22 import org.w3c.dom.Element; 23 24 /** 25 * Class Address. 26 * 27 * @author Davanum Srinivas 28 * @author Rodrigo Ruiz 29 * @version $Revision: 14 $ 30 */ 31 public class Address extends AttributedURI { 32 33 /** 34 * <code>serialVersionUID</code> attribute. 35 */ 36 private static final long serialVersionUID = 1451978919179135145L; 37 38 /** 39 * Gets an Address instance from the specified DOM element. 40 * 41 * @param element Element to parse 42 * @return Address instance 43 * @throws MalformedURIException If the parsed URI is not valid 44 */ 45 public static Address fromElement(Element element) throws MalformedURIException { 46 String value = TextExtractor.getText(element); 47 return new Address(value); 48 } 49 50 /** 51 * Gets an Address instance from the specified SOAP element. 52 * 53 * @param element Element to parse 54 * @return Address instance 55 * @throws MalformedURIException If the parsed URI is not valid 56 */ 57 public static Address fromSOAPElement(SOAPElement element) 58 throws MalformedURIException { 59 String value = TextExtractor.getText(element); 60 return new Address(value); 61 } 62 63 /** 64 * Constructor Address. 65 * 66 * @param uri Address URI 67 * @throws MalformedURIException If the specified URI is not valid 68 */ 69 public Address(String uri) throws MalformedURIException { 70 this(new URI(uri)); 71 } 72 73 /** 74 * Creates an instance. 75 * 76 * @param uri Address URI 77 */ 78 public Address(URI uri) { 79 super(uri); 80 } 81 82 /** 83 * {@inheritDoc} 84 */ 85 public String getDefaultElementName() { 86 return Constants.ADDRESS; 87 } 88 }