Simple changes to eliminate pmd warnings
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Node.java
index 4c7f278209096e16c857f57c6f49d9da7ea94c9f..0ea04c32065e7746518504901abc454f4d5e6281 100644 (file)
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.opendaylight.controller.sal.utils.HexEncode;
@@ -197,7 +198,7 @@ public class Node implements Serializable {
      *
      * @return The node Type for this Node object
      */
-    @XmlAttribute(name = "type")
+    @XmlElement(name = "type")
     public String getType() {
         return this.nodeType;
     }
@@ -228,8 +229,13 @@ public class Node implements Serializable {
         } else if (typeStr.equals(NodeIDType.PRODUCTION)) {
             this.nodeID = IDStr;
         } else {
-            // We need to lookup via OSGi service registry for an
-            // handler for this
+            //Use plugin's method to get appropriate conversion from IDStr to nodeID
+            INodeFactory f = (INodeFactory) ServiceHelper
+                    .getGlobalInstance(INodeFactory.class, new Node(), "(protocolName="+typeStr+")");
+            if(f!=null){
+                Node n = f.fromString(typeStr, IDStr);
+                this.nodeID = n.nodeID;
+            }
         }
     }
 
@@ -261,7 +267,7 @@ public class Node implements Serializable {
      *
      * @return The nodeID in string format
      */
-    @XmlAttribute(name = "id")
+    @XmlElement(name = "id")
     public String getNodeIDString() {
         if (this.nodeType.equals(NodeIDType.OPENFLOW)) {
             return HexEncode.longToHexString((Long) this.nodeID);
@@ -317,10 +323,10 @@ public class Node implements Serializable {
     @Override
     public String toString() {
         if (this.nodeType.equals(NodeIDType.OPENFLOW)) {
-            return this.nodeType.toString() + "|"
+            return this.nodeType + "|"
                 + HexEncode.longToHexString((Long) this.nodeID);
         } else {
-            return this.nodeType.toString() + "|" + this.nodeID.toString();
+            return this.nodeType + "|" + this.nodeID.toString();
         }
     }
 
@@ -445,7 +451,7 @@ public class Node implements Serializable {
                     .getGlobalInstance(INodeFactory.class, new Node(), "(protocolName="+typeStr+")");
             if(f==null)
                 return null;
-            return f.fromString(IDStr, typeStr);
+            return f.fromString(typeStr, IDStr);
         }
     }
 }