RLP { public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[] { (byte) OFFSET_SHORT_ITEM }; } else if ((singleByte & 0xFF) < 0x7F) { return new byte[] { singleByte }; } else { return new byte[] { (byte) (OFFSET_SHORT_ITEM + 1), singleByte }; } }  static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(byte[] payload, int pos); static int getNextElementIndex(byte[] payload, int pos); static void fullTraverse(byte[] msgData, int level, int startPos,
			int endPos, int levelToIndex, Queue<Integer> index); static byte getCommandCode(byte[] data); static RLPList decode2(byte[] msgData); static DecodeResult decode(byte[] data, int pos); static byte[] encode(Object input); static byte[] encodeLength(int length, int offset); static byte[] encodeByte(byte singleByte); static byte[] encodeShort(short singleShort); static byte[] encodeInt(int singleInt); static byte[] encodeString(String srcString); static byte[] encodeBigInteger(BigInteger srcBigInteger); static byte[] encodeElement(byte[] srcData); static byte[] encodeList(byte[]... elements);  }
@Test public void test4() { byte[] expected = {(byte)0x80}; byte[] data = RLP.encodeByte((byte)0); assertArrayEquals(expected, data); byte[] expected2 = {(byte)0x78}; data = RLP.encodeByte((byte)120); assertArrayEquals(expected2, data); byte[] expected3 = {(byte)0x81, (byte)0x7F}; data = RLP.encodeByte((byte)127); assertArrayEquals(expected3, data); }