Renamed datagrid and datastore packages

net.onrc.onos.datagrid.* => net.onrc.onos.core.datagrid.*
net.onrc.onos.datastore.* => net.onrc.onos.core.datastore.*

Change-Id: Ibe1894a6fabae08ea7cfcbf6595f0c91b05ef497
diff --git a/src/main/java/net/onrc/onos/core/datastore/utils/ByteArrayUtil.java b/src/main/java/net/onrc/onos/core/datastore/utils/ByteArrayUtil.java
new file mode 100644
index 0000000..14cd419
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/datastore/utils/ByteArrayUtil.java
@@ -0,0 +1,53 @@
+package net.onrc.onos.core.datastore.utils;
+
+import java.nio.ByteBuffer;
+
+public class ByteArrayUtil {
+
+    // Suppresses default constructor, ensuring non-instantiability.
+    private ByteArrayUtil() {}
+
+    /**
+     * Returns a StringBuffer with each byte in {@code bytes}
+     * converted to a String with {@link Integer#toHexString(int)},
+     * separated by {@code sep}.
+     *
+     * @param bytes byte array to convert
+     * @param sep separator between each bytes
+     * @return {@code bytes} converted to a StringBuffer
+     */
+    public static StringBuffer toHexStringBuffer(final byte[] bytes,
+            final String sep) {
+        return toHexStringBuffer(bytes, sep, new StringBuffer());
+    }
+
+    /**
+     * Returns a StringBuffer with each byte in {@code bytes}
+     * converted to a String with {@link Integer#toHexString(int)},
+     * separated by {@code sep}.
+     *
+     * @param bytes byte array to convert
+     * @param sep separator between each bytes
+     * @param buf StringBuffer to append to.
+     * @return {@code buf}
+     */
+    public static StringBuffer toHexStringBuffer(final byte[] bytes,
+            final String sep, final StringBuffer buf) {
+        if (bytes == null) {
+            return buf;
+        }
+
+        ByteBuffer wrap = ByteBuffer.wrap(bytes);
+
+        boolean hasWritten = false;
+        while (wrap.hasRemaining()) {
+            if (hasWritten) {
+                buf.append(sep);
+            }
+            buf.append(Integer.toHexString(wrap.get()));
+            hasWritten = true;
+        }
+
+        return buf;
+    }
+}