com.limegroup.gnutella.util
Class COBSUtil

java.lang.Object
  extended bycom.limegroup.gnutella.util.COBSUtil

public class COBSUtil
extends java.lang.Object

For implementation details, please see: http://www.acm.org/sigcomm/sigcomm97/papers/p062.pdf


Constructor Summary
COBSUtil()
           
 
Method Summary
static byte[] cobsDecode(byte[] src)
          Decode a COBS-encoded byte array.
static byte[] cobsEncode(byte[] src)
          Encode a byte array with COBS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

COBSUtil

public COBSUtil()
Method Detail

cobsEncode

public static byte[] cobsEncode(byte[] src)
                         throws java.io.IOException
Encode a byte array with COBS. The non-allowable byte value is 0. PRE: src is not null. POST: the return array will be a cobs encoded version of src. namely, cobsDecode(cobsEncode(src)) == src.

Returns:
a COBS encoded version of src.
Throws:
java.io.IOException

cobsDecode

public static byte[] cobsDecode(byte[] src)
                         throws java.io.IOException
Decode a COBS-encoded byte array. The non-allowable byte value is 0. PRE: src is not null. POST: the return array will be a cobs decoded version of src. namely, cobsDecode(cobsEncode(src)) == src.

Returns:
the original COBS decoded string with a extra trailing 0 at the end - feel free to discard it.
Throws:
java.io.IOException