Frame { @Override public Frame clone() { Frame frame = Memory.allocate(data.length); System.arraycopy(data, offset, frame.data, offset, length); frame.offset = offset; frame.length = length; frame.duration = duration; frame.sn = sn; frame.eom = eom; frame.format = format; frame.timestamp = timestamp; frame.header = header; return frame; } protected  Frame(Partition partition, byte[] data); String getHeader(); void setHeader(String header); int getOffset(); void setOffset(int offset); int getLength(); void setLength(int length); byte[] getData(); long getTimestamp(); void setTimestamp(long timestamp); long getDuration(); void setDuration(long duration); long getSequenceNumber(); void setSequenceNumber(long sn); boolean isEOM(); void setEOM(boolean value); Format getFormat(); void setFormat(Format format); void recycle(); @Override Frame clone();  }
@Test public void testClone() { Frame frame1 = Memory.allocate(3); frame1.getData()[0] = 1; frame1.getData()[1] = 2; frame1.getData()[2] = 3; frame1.setDuration(20); frame1.setOffset(0); frame1.setLength(3); frame1.setTimestamp(123); frame1.setFormat(FormatFactory.createAudioFormat("LINEAR", 8000)); Frame frame2 = frame1.clone(); assertEquals(frame2.getDuration(), frame1.getDuration()); assertEquals(frame2.getOffset(), frame1.getOffset()); assertEquals(frame2.getLength(), frame1.getLength()); assertEquals(frame2.getTimestamp(), frame1.getTimestamp()); assertEquals("LINEAR", frame2.getFormat().getName().toString()); assertEquals(frame1.getData()[0], frame2.getData()[0]); assertEquals(frame1.getData()[1], frame2.getData()[1]); assertEquals(frame1.getData()[2], frame2.getData()[2]); frame2.getData()[1] = 100; assertEquals(2, (int)(frame1.getData()[1])); }