com.kolibrifx.plovercrest.server.internal.streams.builtin.RawStreamAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
The newest version!
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.internal.streams.builtin;
import java.nio.ByteBuffer;
import com.kolibrifx.plovercrest.client.TableSerializer;
import com.kolibrifx.plovercrest.server.streams.Stream;
public class RawStreamAdapter extends AbstractTypeConvertingStreamAdapter {
private final TableSerializer serializer;
private final ByteBuffer buf = ByteBuffer.allocate(1024 * 8);
public RawStreamAdapter(final Stream typedStream, final TableSerializer serializer) {
super(typedStream, ByteBuffer.class);
this.serializer = serializer;
}
@Override
protected ByteBuffer convert(final long timestamp, final T element) {
buf.clear();
serializer.serialize(buf, element);
buf.flip();
return buf;
}
}