1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.handler;
17
18 import org.apache.juddi.datatype.Email;
19 import org.apache.juddi.datatype.RegistryObject;
20 import org.apache.juddi.util.xml.XMLUtils;
21 import org.w3c.dom.Element;
22
23 /***
24 * "Knows about the creation and populating of Email objects.
25 * Returns Email."
26 *
27 * @author Steve Viens (sviens@apache.org)
28 */
29 public class EmailHandler extends AbstractHandler
30 {
31 public static final String TAG_NAME = "email";
32
33 protected EmailHandler(HandlerMaker maker)
34 {
35 }
36
37 public RegistryObject unmarshal(Element element)
38 {
39 Email obj = new Email();
40
41
42 String useType = element.getAttribute("useType");
43 if ((useType != null) && (useType.trim().length() > 0))
44 obj.setUseType(useType);
45
46
47 obj.setValue(XMLUtils.getText(element));
48
49
50
51
52 return obj;
53 }
54
55 public void marshal(RegistryObject object,Element parent)
56 {
57 Email email = (Email)object;
58 String generic = getGeneric(null);
59 String namespace = getUDDINamespace(generic);
60 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
61
62 String useType = email.getUseType();
63 if ((useType != null) && (useType.trim().length() > 0))
64 element.setAttribute("useType",useType);
65
66 String emailValue = email.getValue();
67 if (emailValue != null)
68 element.appendChild(parent.getOwnerDocument().createTextNode(emailValue));
69
70 parent.appendChild(element);
71 }
72 }