@Test public void getIntTest() { byte[] buffer = new byte[] { 0, 0, 0, 0 }; Assert.assertEquals(0, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 0, 1 }; Assert.assertEquals(1, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 0, 127 }; Assert.assertEquals(127, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 0, -128 }; Assert.assertEquals(128, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 0, -127 }; Assert.assertEquals(129, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 0, -1 }; Assert.assertEquals(255, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 1, 0 }; Assert.assertEquals(256, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 0, 1, 1 }; Assert.assertEquals(257, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 1, 0, 0 }; Assert.assertEquals(65536, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 0, 1, 0, 1 }; Assert.assertEquals(65537, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 1, 0, 0, 0 }; Assert.assertEquals(16777216, Deserializer.getInt(buffer, 0)); buffer = new byte[] { 1, 0, 0, 1 }; Assert.assertEquals(16777217, Deserializer.getInt(buffer, 0)); }
static int getInt(byte[] buffer, int offset) { return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8 | (buffer[offset + 3] & 0xff); }
Deserializer { static int getInt(byte[] buffer, int offset) { return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8 | (buffer[offset + 3] & 0xff); } }
Deserializer { static int getInt(byte[] buffer, int offset) { return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8 | (buffer[offset + 3] & 0xff); } private  Deserializer(); }
Deserializer { static int getInt(byte[] buffer, int offset) { return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8 | (buffer[offset + 3] & 0xff); } private  Deserializer();  }
Deserializer { static int getInt(byte[] buffer, int offset) { return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8 | (buffer[offset + 3] & 0xff); } private  Deserializer();   }