1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.Name; 19 import org.apache.juddi.datatype.RegistryObject; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 24 30 public class NameHandler extends AbstractHandler 31 { 32 public static final String TAG_NAME = "name"; 33 34 private HandlerMaker maker = null; 35 36 protected NameHandler(HandlerMaker maker) 37 { 38 this.maker = maker; 39 } 40 41 public RegistryObject unmarshal(Element element) 42 { 43 String langCode = element.getAttribute("xml:lang"); 45 46 String nameValue = XMLUtils.getText(element); 48 49 52 Name obj = null; 54 if ((nameValue != null) && (nameValue.trim().length() > 0)) 55 obj = new Name(nameValue,langCode); 56 57 return obj; 58 } 59 60 public void marshal(RegistryObject object,Element parent) 61 { 62 Name name = (Name)object; 63 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 64 65 String langCode = name.getLanguageCode(); 66 if ((langCode != null) && (langCode.trim().length() > 0)) 67 element.setAttribute("xml:lang",langCode); 68 69 String nameValue = name.getValue(); 70 if (nameValue != null) 71 element.appendChild(parent.getOwnerDocument().createTextNode(nameValue)); 72 73 parent.appendChild(element); 74 } 75 76 77 78 79 80 81 82 public static void main(String args[]) 83 throws Exception 84 { 85 } 86 } | Popular Tags |