public void serialize(ByteBuffer buf) { buf.putInt(nChans); buf.putInt(nSamples); buf.putInt(nEvents); buf.putFloat(fSample); buf.putInt(dataType); if (channelNameSize <= nChans) { // channel names are all empty or array length does not match buf.putInt(0); } else { buf.putInt(8 + channelNameSize); // 8 bytes for chunk def buf.putInt(CHUNK_CHANNEL_NAMES); buf.putInt(channelNameSize); for (int i = 0; i < nChans; i++) { if (labels[i] != null) { buf.putString(labels[i]); } buf.putByte((byte)0); } } }
public void serialize(ByteBuffer buf) { switch (type) { case DataType.CHAR: buf.putString(array.ToString()); break; case DataType.UINT8: case DataType.INT8: buf.put((byte[])array); break; case DataType.UINT16: case DataType.INT16: buf.asShortBuffer().put((short[])array); break; case DataType.UINT32: case DataType.INT32: buf.asIntBuffer().put((int[])array); break; case DataType.UINT64: case DataType.INT64: buf.asLongBuffer().put((long[])array); break; case DataType.FLOAT32: buf.asFloatBuffer().put((float[])array); break; case DataType.FLOAT64: buf.asDoubleBuffer().put((double[])array); break; } }
public void serialize(ByteBuffer buf) { switch(type) { case DataType.CHAR: buf.putString(array.ToString()); break; case DataType.UINT8: case DataType.INT8: buf.put((byte[]) array); break; case DataType.UINT16: case DataType.INT16: buf.asShortBuffer().put((short[]) array); break; case DataType.UINT32: case DataType.INT32: buf.asIntBuffer().put((int[]) array); break; case DataType.UINT64: case DataType.INT64: buf.asLongBuffer().put((long[]) array); break; case DataType.FLOAT32: buf.asFloatBuffer().put((float[]) array); break; case DataType.FLOAT64: buf.asDoubleBuffer().put((double[]) array); break; } }
public void serialize(ByteBuffer buf) { buf.putInt(nChans); buf.putInt(nSamples); buf.putInt(nEvents); buf.putFloat(fSample); buf.putInt(dataType); if (channelNameSize <= nChans) { // channel names are all empty or array length does not match buf.putInt(0); } else { buf.putInt(8 + channelNameSize); // 8 bytes for chunk def buf.putInt(CHUNK_CHANNEL_NAMES); buf.putInt(channelNameSize); for (int i=0;i<nChans;i++) { if (labels[i] != null) buf.putString( labels[i]); buf.putByte((byte) 0); } } }