TlvDecoder { public static ObjectLink decodeObjlnk(byte[] value) throws TlvException { ByteBuffer bff = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN); bff.put(value); int val1 = bff.getShort(0) & 0xFFFF; int val2 = bff.getShort(2) & 0xFFFF; return new ObjectLink(val1, val2); }  static Tlv[] decode(ByteBuffer input); static String decodeString(byte[] value); static boolean decodeBoolean(byte[] value); static Date decodeDate(byte[] value); static ObjectLink decodeObjlnk(byte[] value); static Number decodeInteger(byte[] value); static Number decodeFloat(byte[] value);  }
@Test public void decode_object_link() throws TlvException { String dataStr = "12345678"; byte[] bytes = Hex.decodeHex(dataStr.toCharArray()); ObjectLink objlnk = TlvDecoder.decodeObjlnk(bytes); assertEquals(0x1234, objlnk.getObjectId()); assertEquals(0x5678, objlnk.getObjectInstanceId()); dataStr = "ffffffff"; bytes = Hex.decodeHex(dataStr.toCharArray()); objlnk = TlvDecoder.decodeObjlnk(bytes); assertEquals(0xffff, objlnk.getObjectId()); assertEquals(0xffff, objlnk.getObjectInstanceId()); }