1 16 package org.apache.juddi.handler; 17 18 import java.util.Vector ; 19 20 import javax.xml.soap.SOAPElement ; 21 import javax.xml.soap.SOAPException ; 22 23 import org.apache.juddi.datatype.RegistryObject; 24 import org.apache.juddi.datatype.response.KeysOwned; 25 import org.apache.juddi.util.xml.XMLUtils; 26 import org.w3c.dom.Element ; 27 28 31 public class KeysOwnedHandler extends AbstractHandler 32 { 33 public static final String TAG_NAME = "keysOwned"; 34 private static final String FROM_KEY_TAG_NAME = "fromKey"; 35 private static final String TO_KEY_TAG_NAME = "toKey"; 36 37 private HandlerMaker maker = null; 38 39 protected KeysOwnedHandler(HandlerMaker maker) 40 { 41 this.maker = maker; 42 } 43 44 public RegistryObject unmarshal(Element element) 45 { 46 KeysOwned obj = new KeysOwned(); 47 Vector nodeList = null; 48 AbstractHandler handler = null; 49 50 53 56 nodeList = XMLUtils.getChildElementsByTagName(element,FROM_KEY_TAG_NAME); 58 if (nodeList.size() > 0) 59 { 60 Element keyElement = (Element )nodeList.elementAt(0); 61 obj.setFromKey(XMLUtils.getText(keyElement)); 62 } 63 64 nodeList = XMLUtils.getChildElementsByTagName(element,TO_KEY_TAG_NAME); 65 if (nodeList.size() > 0) 66 { 67 Element keyElement = (Element )nodeList.elementAt(0); 68 obj.setToKey(XMLUtils.getText(keyElement)); 69 } 70 71 return obj; 72 } 73 74 public void marshal(RegistryObject object,Element parent) 75 { 76 KeysOwned keysOwned = (KeysOwned)object; 77 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 78 AbstractHandler handler = null; 79 80 String fromKey = keysOwned.getFromKey(); 81 if ((fromKey != null) && (fromKey.length() > 0)) 82 { 83 Element keyElement = parent.getOwnerDocument().createElement(FROM_KEY_TAG_NAME); 84 keyElement.appendChild(parent.getOwnerDocument().createTextNode(fromKey)); 85 element.appendChild(keyElement); 86 } 87 88 String toKey = keysOwned.getToKey(); 89 if ((toKey != null) && (toKey.length() > 0)) 90 { 91 Element keyElement = parent.getOwnerDocument().createElement(TO_KEY_TAG_NAME); 92 keyElement.appendChild(parent.getOwnerDocument().createTextNode(toKey)); 93 element.appendChild(keyElement); 94 } 95 96 parent.appendChild(element); 97 } 98 99 public RegistryObject unmarshal(SOAPElement element) 100 { 101 return null; 102 } 103 104 public void marshal(RegistryObject object,SOAPElement parent) 105 throws SOAPException 106 { 107 } 108 109 110 111 112 113 114 115 public static void main(String args[]) 116 throws Exception 117 { 118 } 119 } 120 | Popular Tags |