class ByteBufferStreamInput extends StreamInput {

    private final ByteBuffer buffer;

    public ByteBufferStreamInput(ByteBuffer buffer) {
        this.buffer = buffer;
    }

    @Override
    public int read() throws IOException {
        if (!buffer.hasRemaining()) {
            return -1;
        }
        return buffer.get() & 0xFF;
    }

    @Override
    public byte readByte() throws IOException {
        if (!buffer.hasRemaining()) {
            throw new EOFException();
        }
        return buffer.get();
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        if (!buffer.hasRemaining()) {
            return -1;
        }

        len = Math.min(len, buffer.remaining());
        buffer.get(b, off, len);
        return len;
    }

    @Override
    public long skip(long n) throws IOException {
        if (n > buffer.remaining()) {
            int ret = buffer.position();
            buffer.position(buffer.limit());
            return ret;
        }
        buffer.position((int) (buffer.position() + n));
        return n;
    }

    @Override
    public void readBytes(byte[] b, int offset, int len) throws IOException {
        if (buffer.remaining() < len) {
            throw new EOFException();
        }
        buffer.get(b, offset, len);
    }

    @Override
    public short readShort() throws IOException {<FILL_FUNCTION_BODY>}

    @Override
    public int readInt() throws IOException {
        try {
            return buffer.getInt();
        } catch (BufferUnderflowException ex) {
            EOFException eofException = new EOFException();
            eofException.initCause(ex);
            throw eofException;
        }
    }

    @Override
    public long readLong() throws IOException {
        try {
            return buffer.getLong();
        } catch (BufferUnderflowException ex) {
            EOFException eofException = new EOFException();
            eofException.initCause(ex);
            throw eofException;
        }
    }

    @Override
    public void reset() throws IOException {
        buffer.reset();
    }

    @Override
    public int available() throws IOException {
        return buffer.remaining();
    }

    @Override
    protected void ensureCanReadBytes(int length) throws EOFException {
        if (buffer.remaining() < length) {
            throw new EOFException("tried to read: " + length + " bytes but only " + buffer.remaining() + " remaining");
        }
    }

    @Override
    @SuppressWarnings("sync-override")
    public void mark(int readlimit) {
        buffer.mark();
    }

    @Override
    public boolean markSupported() {
        return true;
    }

    @Override
    public void close() throws IOException {
    }
}

        try {
            return buffer.getShort();
        } catch (BufferUnderflowException ex) {
            EOFException eofException = new EOFException();
            eofException.initCause(ex);
            throw eofException;
        }
    
<methods>public non-sealed void <init>() ,public abstract int available() throws java.io.IOException,public abstract void close() throws java.io.IOException,public org.elasticsearch.Version getVersion() ,public T[] readArray(Reader<T>, IntFunction<T[]>) throws java.io.IOException,public final boolean readBoolean() throws java.io.IOException,public abstract byte readByte() throws java.io.IOException,public byte[] readByteArray() throws java.io.IOException,public abstract void readBytes(byte[], int, int) throws java.io.IOException,public BytesRef readBytesRef() throws java.io.IOException,public BytesRef readBytesRef(int) throws java.io.IOException,public org.elasticsearch.common.bytes.BytesReference readBytesReference() throws java.io.IOException,public org.elasticsearch.common.bytes.BytesReference readBytesReference(int) throws java.io.IOException,public final double readDouble() throws java.io.IOException,public double[] readDoubleArray() throws java.io.IOException,public E readEnum(Class<E>) throws java.io.IOException,public EnumSet<E> readEnumSet(Class<E>) throws java.io.IOException,public T readException() throws java.io.IOException,public final float readFloat() throws java.io.IOException,public float[] readFloatArray() throws java.io.IOException,public void readFully(byte[]) throws java.io.IOException,public java.lang.Object readGenericValue() throws java.io.IOException,public org.elasticsearch.common.geo.GeoPoint readGeoPoint() throws java.io.IOException,public ImmutableOpenMap<K,V> readImmutableMap(Reader<K>, Reader<V>) throws java.io.IOException,public int readInt() throws java.io.IOException,public int[] readIntArray() throws java.io.IOException,public List<T> readList(Reader<T>) throws java.io.IOException,public long readLong() throws java.io.IOException,public long[] readLongArray() throws java.io.IOException,public Map<K,V> readMap(Supplier<Map<K,V>>, Reader<K>, Reader<V>) throws java.io.IOException,public Map<K,V> readMap(Reader<K>, Reader<V>) throws java.io.IOException,public Map<java.lang.String,java.lang.Object> readMap() throws java.io.IOException,public Map<K,List<V>> readMapOfLists(Reader<K>, Reader<V>) throws java.io.IOException,public C readNamedWriteable(Class<C>) throws java.io.IOException,public C readNamedWriteable(Class<C>, java.lang.String) throws java.io.IOException,public List<T> readNamedWriteableList(Class<T>) throws java.io.IOException,public T[] readOptionalArray(Reader<T>, IntFunction<T[]>) throws java.io.IOException,public final java.lang.Boolean readOptionalBoolean() throws java.io.IOException,public org.elasticsearch.common.bytes.BytesReference readOptionalBytesReference() throws java.io.IOException,public final java.lang.Double readOptionalDouble() throws java.io.IOException,public java.lang.Float readOptionalFloat() throws java.io.IOException,public java.lang.Long readOptionalLong() throws java.io.IOException,public C readOptionalNamedWriteable(Class<C>) throws java.io.IOException,public java.lang.String readOptionalString() throws java.io.IOException,public java.lang.String[] readOptionalStringArray() throws java.io.IOException,public io.crate.common.unit.TimeValue readOptionalTimeValue() throws java.io.IOException,public DateTimeZone readOptionalTimeZone() throws java.io.IOException,public java.lang.Integer readOptionalVInt() throws java.io.IOException,public T readOptionalWriteable(Reader<T>) throws java.io.IOException,public Set<T> readSet(Reader<T>) throws java.io.IOException,public short readShort() throws java.io.IOException,public java.lang.String readString() throws java.io.IOException,public java.lang.String[] readStringArray() throws java.io.IOException,public List<java.lang.String> readStringList() throws java.io.IOException,public io.crate.common.unit.TimeValue readTimeValue() throws java.io.IOException,public DateTimeZone readTimeZone() throws java.io.IOException,public int readVInt() throws java.io.IOException,public int[] readVIntArray() throws java.io.IOException,public long readVLong() throws java.io.IOException,public long[] readVLongArray() throws java.io.IOException,public long readZLong() throws java.io.IOException,public void setVersion(org.elasticsearch.Version) ,public static org.elasticsearch.common.io.stream.StreamInput wrap(byte[]) ,public static org.elasticsearch.common.io.stream.StreamInput wrap(byte[], int, int) <variables>private static final non-sealed Map<java.lang.Byte,java.util.concurrent.TimeUnit> BYTE_TIME_UNIT_MAP,private static final ThreadLocal<CharsRef> SMALL_SPARE,private static final int SMALL_STRING_LIMIT,private static final ThreadLocal<byte[]> STRING_READ_BUFFER,private CharsRef largeSpare,private org.elasticsearch.Version version