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.Phone;
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 Phone objects.
25 * Returns Phone."
26 *
27 * @author Steve Viens (sviens@apache.org)
28 */
29 public class PhoneHandler extends AbstractHandler
30 {
31 public static final String TAG_NAME = "phone";
32
33 protected PhoneHandler(HandlerMaker maker)
34 {
35 }
36
37 public RegistryObject unmarshal(Element element)
38 {
39 Phone obj = new Phone();
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 Phone phone = (Phone)object;
58 String generic = getGeneric(null);
59 String namespace = getUDDINamespace(generic);
60 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
61
62 String useType = phone.getUseType();
63 if ((useType != null) && (useType.trim().length() > 0))
64 element.setAttribute("useType",useType);
65
66 String phoneValue = phone.getValue();
67 if (phoneValue != null)
68 element.appendChild(parent.getOwnerDocument().createTextNode(phoneValue));
69
70 parent.appendChild(element);
71 }
72 }