Fix a bug when creating FlowId and FlowBatchId from hex string:

 * Added static methods FlowId.valueOf(String) and FlowBatchId.valueOf(String)
   Implementation-wise, those methods are practically same as
   IntentId.valueOf(String)

 * Used the above methods as appropriate.

This fixes an exception that for some reason only occasionally shows-up
in logs of some of the unit tests, and also does not break those tests.

Also, make the change to accept hex strings starting with either 0x or 0X.

Change-Id: Iaaee529866deb1a89ccc3f306901672f25be6326
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/SharedFlowMapEventDispatcher.java b/src/main/java/net/onrc/onos/core/flowmanager/SharedFlowMapEventDispatcher.java
index cc41ce0..9368ac2 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/SharedFlowMapEventDispatcher.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/SharedFlowMapEventDispatcher.java
@@ -67,7 +67,7 @@
         } else if (value instanceof FlowState) {
             // Handles events from flowStateMap.
             final FlowState state = (FlowState) value;
-            final FlowId id = new FlowId(Long.parseLong(event.getKey()));
+            final FlowId id = FlowId.valueOf(event.getKey());
             log.trace("FlowState of FlowId {} was set to {}", id, state);
             for (FlowMapEventListener e : listeners) {
                 e.flowStateChanged(id, FlowState.SUBMITTED, state);
@@ -106,7 +106,7 @@
             Object oldValue = KryoFactory.deserialize(event.getOldValue());
             final FlowState state = (FlowState) value;
             final FlowState oldState = (FlowState) oldValue;
-            final FlowId id = new FlowId(Long.parseLong(event.getKey()));
+            final FlowId id = FlowId.valueOf(event.getKey());
             log.trace("FlowState of FlowId {} was updated from {} to {}",
                     id, oldState, state);
             for (FlowMapEventListener e : listeners) {