Module org.elasticsearch.server
Class ByteArrayStreamInput
java.lang.Object
java.io.InputStream
org.elasticsearch.common.io.stream.StreamInput
org.elasticsearch.common.io.stream.ByteArrayStreamInput
- All Implemented Interfaces:
Closeable,AutoCloseable
Resettable
StreamInput that wraps a byte array. It is heavily inspired in Lucene's
ByteArrayDataInput.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Closes the stream to further operations.protected voidensureCanReadBytes(int length) This method throws anEOFExceptionif the given number of bytes can not be read from the this stream.intintlength()intread()bytereadByte()Reads and returns a single byte.voidreadBytes(byte[] b, int offset, int len) Reads a specified number of bytes into an array at the specified offset.voidreset(byte[] bytes) voidreset(byte[] bytes, int offset, int len) voidsetPosition(int pos) voidskipBytes(long count) Methods inherited from class org.elasticsearch.common.io.stream.StreamInput
getVersion, namedWriteableRegistry, readArray, readArraySize, readBigInteger, readBoolean, readByteArray, readBytesRef, readBytesRef, readBytesReference, readBytesReference, readDouble, readDoubleArray, readEnum, readEnumSet, readException, readFloat, readFloatArray, readFully, readGenericValue, readGeoPoint, readImmutableList, readImmutableMap, readImmutableOpenMap, readInstant, readInt, readIntArray, readList, readLong, readLongArray, readMap, readMap, readMapOfLists, readMapValues, readNamedWriteable, readNamedWriteable, readNamedWriteableList, readOptionalArray, readOptionalBoolean, readOptionalBytesReference, readOptionalDouble, readOptionalEnum, readOptionalFloat, readOptionalInstant, readOptionalInt, readOptionalList, readOptionalLong, readOptionalNamedWriteable, readOptionalSecureString, readOptionalString, readOptionalStringArray, readOptionalStringList, readOptionalText, readOptionalTimeValue, readOptionalVInt, readOptionalVLong, readOptionalWriteable, readOptionalZoneId, readOrderedMap, readReleasableBytesReference, readSecureString, readSet, readShort, readString, readStringArray, readStringList, readText, readTimeValue, readVInt, readVIntArray, readVIntSlow, readVLong, readVLongArray, readVLongSlow, readZLong, readZoneId, setVersion, throwEOF, throwOnBrokenVInt, throwOnBrokenVLong, throwOnNullRead, wrap, wrapMethods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
ByteArrayStreamInput
public ByteArrayStreamInput() -
ByteArrayStreamInput
public ByteArrayStreamInput(byte[] bytes)
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
reset
public void reset(byte[] bytes) -
length
public int length() -
getPosition
public int getPosition() -
setPosition
public void setPosition(int pos) -
reset
public void reset(byte[] bytes, int offset, int len) -
skipBytes
public void skipBytes(long count) -
close
public void close()Description copied from class:StreamInputCloses the stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classStreamInput
-
available
public int available()- Specified by:
availablein classStreamInput
-
ensureCanReadBytes
Description copied from class:StreamInputThis method throws anEOFExceptionif the given number of bytes can not be read from the this stream. This method might be a no-op depending on the underlying implementation if the information of the remaining bytes is not present.- Specified by:
ensureCanReadBytesin classStreamInput- Throws:
EOFException
-
readByte
public byte readByte()Description copied from class:StreamInputReads and returns a single byte.- Specified by:
readBytein classStreamInput
-
readBytes
public void readBytes(byte[] b, int offset, int len) Description copied from class:StreamInputReads a specified number of bytes into an array at the specified offset.- Specified by:
readBytesin classStreamInput- Parameters:
b- the array to read bytes intooffset- the offset in the array to start storing byteslen- the number of bytes to read
-