@Test public void testEncode() { BeatsFrame frame = new BeatsFrame.Builder() .version((byte) 0x31) .frameType((byte) 0x41) .payload(ByteBuffer.allocate(4).putInt(123).array()) .build(); byte[] encoded = encoder.encode(frame); Assert.assertArrayEquals(DatatypeConverter.parseHexBinary("31410000007B"), encoded); }
public byte[] encode(final BeatsFrame frame) { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(frame.getVersion()); buffer.write(frame.getFrameType()); try { buffer.write(frame.getPayload()); } catch (IOException e) { throw new BeatsFrameException("Error decoding Beats frame: " + e.getMessage(), e); } return buffer.toByteArray(); }
BeatsEncoder { public byte[] encode(final BeatsFrame frame) { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(frame.getVersion()); buffer.write(frame.getFrameType()); try { buffer.write(frame.getPayload()); } catch (IOException e) { throw new BeatsFrameException("Error decoding Beats frame: " + e.getMessage(), e); } return buffer.toByteArray(); } }
BeatsEncoder { public byte[] encode(final BeatsFrame frame) { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(frame.getVersion()); buffer.write(frame.getFrameType()); try { buffer.write(frame.getPayload()); } catch (IOException e) { throw new BeatsFrameException("Error decoding Beats frame: " + e.getMessage(), e); } return buffer.toByteArray(); }  }
BeatsEncoder { public byte[] encode(final BeatsFrame frame) { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(frame.getVersion()); buffer.write(frame.getFrameType()); try { buffer.write(frame.getPayload()); } catch (IOException e) { throw new BeatsFrameException("Error decoding Beats frame: " + e.getMessage(), e); } return buffer.toByteArray(); }  byte[] encode(final BeatsFrame frame); }
BeatsEncoder { public byte[] encode(final BeatsFrame frame) { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); buffer.write(frame.getVersion()); buffer.write(frame.getFrameType()); try { buffer.write(frame.getPayload()); } catch (IOException e) { throw new BeatsFrameException("Error decoding Beats frame: " + e.getMessage(), e); } return buffer.toByteArray(); }  byte[] encode(final BeatsFrame frame);  }