View Javadoc

1   /*
2    * Jbi4CorbaPartnerLinkDeserializer.java
3    * 
4    * Created on 12-set-2007, 17.45.50
5    * 
6    * To change this template, choose Tools | Templates
7    * and open the template in the editor.
8    */
9   
10  package it.imolinfo.jbi4corba.utils.plugin.wsdl;
11  
12  import javax.wsdl.Definition;
13  import javax.wsdl.WSDLException;
14  import javax.wsdl.extensions.ExtensibilityElement;
15  import javax.wsdl.extensions.ExtensionDeserializer;
16  import javax.wsdl.extensions.ExtensionRegistry;
17  import javax.xml.namespace.QName;
18  import org.w3c.dom.Element;
19  import org.w3c.dom.Node;
20  import org.w3c.dom.NodeList;
21  
22  /**
23   *
24   * @author mcastaldi
25   */
26  public class Jbi4CorbaPartnerLinkDeserializer implements ExtensionDeserializer {
27  
28      /**
29      * Not used ... so not tested :-)
30      */
31      public ExtensibilityElement unmarshall(
32          Class parentType, 
33          QName elementType, 
34          Element element, 
35          Definition definition, 
36          ExtensionRegistry registry) 
37      throws WSDLException
38      {
39          // create the object
40          Jbi4CorbaPartnerLink ptlnk = (Jbi4CorbaPartnerLink)
41              registry.createExtension(parentType, elementType);
42  
43          ptlnk.setName(
44              element.getAttribute(Jbi4CorbaPartnerLinkExtension.PRTLNK_NAME_ATTRIBUTE));
45  
46          ptlnk.setPrefix(elementType.getPrefix());
47  
48          NodeList nodeList = element.getChildNodes();
49          Node node = null;
50          Role role = null;
51          int nodeNumber = nodeList.getLength();
52          if (nodeNumber < 1 | nodeNumber > 2) {
53              // parsing error! 
54              return null;
55          }
56          for (int i = 0; i < nodeList.getLength(); i++) {
57              node = nodeList.item(i);
58              role = Role.parse(node);
59              if (role == null) {
60                  break;
61              }
62              ptlnk.addRole(role);
63          }
64          return ptlnk;
65      }
66  
67  }