1 package org.apache.sandesha.ws.rm; 2 3 4 import org.apache.axis.message.MessageElement; 5 import org.apache.axis.types.URI; 6 import org.apache.sandesha.Constants; 7 8 import javax.xml.soap.SOAPException ; 9 import java.util.Iterator ; 10 11 18 public class Identifier extends URI { 19 20 23 private MessageElement identifierElement; 24 25 28 private String identifier = null; 29 30 33 public Identifier() { 34 identifierElement = new MessageElement(); 35 identifierElement.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.IDENTIFIER); 36 } 37 38 44 public void setUri(String uri) throws SOAPException { 45 identifierElement.addTextNode(uri); 46 } 47 48 54 public Identifier fromSOAPEnvelope(MessageElement element) { 55 56 identifier = element.getValue(); 57 return this; 58 } 59 60 67 public MessageElement toSOAPEnvelope(MessageElement msgElement) throws SOAPException { 68 removeIdentifierElementIfAny(msgElement); 69 msgElement.addChildElement(Constants.WSRM.IDENTIFIER, Constants.WSRM.NS_PREFIX_RM) 70 .addTextNode(identifier); 71 return msgElement; 72 } 73 74 80 public MessageElement getSoapElement() throws SOAPException { 81 82 identifierElement.addTextNode(identifier); 84 85 return identifierElement; 86 } 87 88 93 public String getIdentifier() { 94 return identifier; 95 } 96 97 100 public void setIdentifier(String string) { 101 identifier = string; 102 } 103 104 110 public boolean equals(Object obj) { 111 112 if (obj instanceof org.apache.sandesha.ws.rm.Identifier) { 113 if (this.identifier == 114 ((String ) (((org.apache.sandesha.ws.rm.Identifier) obj).getIdentifier()))) { 115 return true; 116 } else { 117 return false; 118 } 119 } else { 120 return false; 121 } 122 } 123 124 129 public int hashCode() { 130 return identifier.hashCode(); 131 } 132 133 138 public String toString() { 139 return identifier; 140 } 141 142 private void removeIdentifierElementIfAny(MessageElement msgElement) { 143 144 Iterator ite = msgElement.getChildElements(); 145 while (ite.hasNext()) { 146 MessageElement childElement = (MessageElement) ite.next(); 147 if (Constants.WSRM.IDENTIFIER.equals(childElement.getName()) && 148 (Constants.WSRM.NS_URI_RM.equals(childElement.getNamespaceURI()))) { 149 childElement.detachNode(); 150 } 151 } 152 } 153 } | Popular Tags |