@@ -0,0 +1,3428 @@
+/*%0A *  Copyright 2014 - 2016 Real Logic Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.agrona.io;%0A%0Aimport org.agrona.MutableDirectBuffer;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.util.Objects;%0A%0A/**%0A * %7B@link OutputStream%7D that wraps an underlying expandable version of a %7B@link MutableDirectBuffer%7D.%0A */%0Apublic class ExpandableMutableDirectBufferOutputStream extends OutputStream%0A%7B%0A    private MutableDirectBuffer buffer;%0A    private int offset;%0A    private int position;%0A%0A    public ExpandableMutableDirectBufferOutputStream()%0A    %7B%0A    %7D%0A%0A    public ExpandableMutableDirectBufferOutputStream(final MutableDirectBuffer buffer)%0A    %7B%0A        wrap(buffer, 0);%0A    %7D%0A%0A    public ExpandableMutableDirectBufferOutputStream(final MutableDirectBuffer buffer, final int offset)%0A    %7B%0A        wrap(buffer, offset);%0A    %7D%0A%0A    /**%0A     * Wrap a given buffer beginning with an offset of 0.%0A     *%0A     * @param buffer to wrap%0A     */%0A    public void wrap(final MutableDirectBuffer buffer)%0A    %7B%0A        wrap(buffer, 0);%0A    %7D%0A%0A    /**%0A     * Wrap a given buffer beginning at an offset.%0A     *%0A     * @param buffer to wrap%0A     * @param offset at which the puts will occur.%0A     */%0A    public void wrap(final MutableDirectBuffer buffer, final int offset)%0A    %7B%0A        Objects.requireNonNull(buffer, %22Buffer must not be null%22);%0A        if (!buffer.isExpandable())%0A        %7B%0A            throw new IllegalStateException(%22buffer must be expandable.%22);%0A        %7D%0A%0A        this.buffer = buffer;%0A        this.offset = offset;%0A        this.position = 0;%0A    %7D%0A%0A    /**%0A     * The position in the buffer from the offset up to which has been written.%0A     *%0A     * @return the position in the buffer from the offset up to which has been written.%0A     */%0A    public int position()%0A    %7B%0A        return position;%0A    %7D%0A%0A    /**%0A     * The offset within the underlying buffer at which to start.%0A     *%0A     * @return offset within the underlying buffer at which to start.%0A     */%0A    public int offset()%0A    %7B%0A        return offset;%0A    %7D%0A%0A    /**%0A     * The underlying buffer being wrapped.%0A     *%0A     * @return the underlying buffer being wrapped.%0A     */%0A    public MutableDirectBuffer buffer()%0A    %7B%0A        return buffer;%0A    %7D%0A%0A    /**%0A     * Write a byte to buffer.%0A     *%0A     * @param b to be written.%0A     */%0A    public void write(final int b) throws IOException%0A    %7B%0A        buffer.putByte(offset + position, (byte)b);%0A        ++position;%0A    %7D%0A%0A    /**%0A     * Write a byte%5B%5D to the buffer.%0A     *%0A     * @param srcBytes  to write%0A     * @param srcOffset at which to begin reading bytes from the srcBytes.%0A     * @param length    of the srcBytes to read.%0A     */%0A    public void write(final byte%5B%5D srcBytes, final int srcOffset, final int length) throws IOException%0A    %7B%0A        buffer.putBytes(offset + position, srcBytes, srcOffset, length);%0A        position += length;%0A    %7D%0A%7D%0A

Add ExpandableMutableDirectBufferOutputStream.