Merge "add basic lib - plugin communication"
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / ByteBufUtils.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 \r
3 package org.opendaylight.openflowjava.protocol.impl.util;\r
4 \r
5 import io.netty.buffer.ByteBuf;\r
6 \r
7 /** Class for common operations on ByteBuf\r
8  *\r
9  * @author michal.polkorab\r
10  */\r
11 public abstract class ByteBufUtils {\r
12 \r
13     /**\r
14      * Converts ByteBuf into String\r
15      * @param bb input ByteBuf\r
16      * @return String\r
17      */\r
18     public static String byteBufToHexString(ByteBuf bb) {\r
19         StringBuffer sb = new StringBuffer();\r
20         for (int i = 0; i < bb.readableBytes(); i++) {\r
21             short b = bb.getUnsignedByte(i);\r
22             sb.append(String.format("%02x ", b));\r
23         }\r
24         return sb.toString();\r
25     }\r
26 }\r