This project has retired. For details please refer to its
Attic page.
Printer xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout;
18
19 import java.util.Collection;
20 import java.util.Iterator;
21
22 import javax.xml.registry.JAXRException;
23 import javax.xml.registry.infomodel.Classification;
24 import javax.xml.registry.infomodel.Concept;
25 import javax.xml.registry.infomodel.EmailAddress;
26 import javax.xml.registry.infomodel.ExternalLink;
27 import javax.xml.registry.infomodel.Organization;
28 import javax.xml.registry.infomodel.PersonName;
29 import javax.xml.registry.infomodel.RegistryObject;
30 import javax.xml.registry.infomodel.Service;
31 import javax.xml.registry.infomodel.ServiceBinding;
32 import javax.xml.registry.infomodel.TelephoneNumber;
33 import javax.xml.registry.infomodel.User;
34
35
36
37
38
39 public class Printer
40 {
41
42 public void printOrganisation(Organization org) throws JAXRException
43 {
44 System.out.println("Org name: " + getName(org));
45 System.out.println("Org description: " + getDescription(org));
46 System.out.println("Org key id: " + getKey(org));
47 printUser(org);
48 printServices(org);
49 printClassifications(org);
50 }
51
52 public void printServices(Organization org)
53 throws JAXRException
54 {
55
56 Collection services = org.getServices();
57 for (Iterator svcIter = services.iterator(); svcIter.hasNext();)
58 {
59 Service svc = (Service) svcIter.next();
60 System.out.println(" Service name: " + getName(svc));
61 System.out.println(" Service description: " + getDescription(svc));
62 Collection serviceBindings = svc.getServiceBindings();
63 for (Iterator sbIter = serviceBindings.iterator(); sbIter.hasNext();)
64 {
65 ServiceBinding sb = (ServiceBinding) sbIter.next();
66 System.out.println(" Binding Description: " + getDescription(sb));
67 System.out.println(" Access URI: " + sb.getAccessURI());
68 }
69 }
70 }
71
72 public void printUser(Organization org)
73 throws JAXRException
74 {
75
76 User pc = org.getPrimaryContact();
77 if (pc != null)
78 {
79 PersonName pcName = pc.getPersonName();
80 System.out.println(" Contact name: " + pcName.getFullName());
81 Collection phNums = pc.getTelephoneNumbers(pc.getType());
82 for (Iterator phIter = phNums.iterator(); phIter.hasNext();)
83 {
84 TelephoneNumber num = (TelephoneNumber) phIter.next();
85 System.out.println(" Phone number: " + num.getNumber());
86 }
87 Collection eAddrs = pc.getEmailAddresses();
88 for (Iterator eaIter = eAddrs.iterator(); eaIter.hasNext();)
89 {
90 System.out.println(" Email Address: " + (EmailAddress) eaIter.next());
91 }
92 }
93 }
94
95 public void printExternalLinks(Concept concept)
96 throws JAXRException
97 {
98 Collection links = concept.getExternalLinks();
99 for (Iterator lnkIter = links.iterator(); lnkIter.hasNext();)
100 {
101 System.out.println("Link: " + ((ExternalLink) lnkIter.next()).getExternalURI().charAt(0));
102 }
103 }
104
105 public String getName(RegistryObject ro) throws JAXRException
106 {
107 if (ro != null && ro.getName() != null)
108 {
109 return ro.getName().getValue();
110 }
111 return "";
112 }
113
114 public String getDescription(RegistryObject ro) throws JAXRException
115 {
116 if (ro != null && ro.getDescription() != null)
117 {
118 return ro.getDescription().getValue();
119 }
120 return "";
121 }
122
123 public String getKey(RegistryObject ro) throws JAXRException
124 {
125 if (ro != null && ro.getKey() != null)
126 {
127 return ro.getKey().getId();
128 }
129 return "";
130 }
131
132 public void printClassifications(Organization ro) throws JAXRException
133 {
134 Collection c = ro.getClassifications();
135 Iterator i = c.iterator();
136
137 System.out.println("Classification: " + ro.getClassifications());
138 while (i.hasNext()) {
139 Classification cl = (Classification)i.next();
140 System.out.println("Classification: " + cl.getName());
141 }
142 }
143
144 }