View Javadoc

1   /*
2    * Role.java
3    * 
4    * Created on 12-set-2007, 17.29.28
5    * 
6    * This class represents the Role element
7    */
8   
9   package it.imolinfo.jbi4corba.utils.plugin.wsdl;
10  
11  import java.io.Serializable;
12  import org.w3c.dom.NamedNodeMap;
13  import org.w3c.dom.Node;
14  
15  /**
16   *
17   * @author mcastaldi
18   */
19  public class Role implements Serializable {
20      
21      private String name = null;
22      private String portType = null;
23  
24      public Role() {
25      }
26  
27      public Role(String name, String portType) {
28          this.name = name;
29          this.portType = portType;
30      }
31  
32      public String getName() {
33          return name;
34      }
35  
36      public void setName(String name) {
37          this.name = name;
38      }
39  
40      public String getPortType() {
41          return portType;
42      }
43  
44      public void setPortType(String portType) {
45          this.portType = portType;
46      }
47  
48      /**
49      * Not used ... so not tested :-)
50      */
51      public static Role parse(Node roleElement) {
52          Role role = null;
53          // check if this is a correct element
54          if (Jbi4CorbaPartnerLinkExtension.ROLE_ELEMENT.equals(roleElement.getNodeName())) 
55          {
56              // the provided element is correct
57              role = new Role();
58              NamedNodeMap attributes = roleElement.getAttributes();
59              Node node = attributes.getNamedItem(Jbi4CorbaPartnerLinkExtension.ROLE_ATTRIBUTE_NAME);
60              role.setName(node.getNodeValue());
61              node = attributes.getNamedItem(Jbi4CorbaPartnerLinkExtension.ROLE_ATTRIBUTE_PORT);
62              role.setPortType(node.getNodeValue());
63          }
64          return role;
65      }
66  
67      /**
68      * Not used ... so not tested :-)
69      */
70      public String toString() {
71          StringBuffer buffer = new StringBuffer("Role: \n");
72          buffer.append("name: ").append(this.getName()).append("\n");
73          buffer.append("portType: ").append(this.getPortType()).append("\n");
74          return buffer.toString();
75      }
76      
77  }