All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.internal.streams.builtin.RawStreamAdapter Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy