if (input.position() - SIZE_OF_INT >= end) { close(); return -1;
@Override public int read(byte[] destination, int destinationIndex, int length) { if (length == 0) { return 0; } if (globalLength - position() == 0) { return -1; } // limit read to stream size length = (int) min(length, globalLength - position()); // do a full read of the available data readBytes(destination, destinationIndex, length); return length; }
@Override public int read(byte[] destination, int destinationIndex, int length) { if (length == 0) { return 0; } if (globalLength - position() == 0) { return -1; } // limit read to stream size length = (int) min(length, globalLength - position()); // do a full read of the available data readBytes(destination, destinationIndex, length); return length; }
@Override public int read() { if (position() >= globalLength) { return -1; } ensureAvailable(SIZE_OF_BYTE); int result = buffer.getByte(bufferPosition) & 0xFF; bufferPosition++; return result; }
@Override public int read() { if (position() >= globalLength) { return -1; } ensureAvailable(SIZE_OF_BYTE); int result = buffer.getByte(bufferPosition) & 0xFF; bufferPosition++; return result; }
@Override public void readBytes(Slice destination, int destinationIndex, int length) { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, destination, destinationIndex, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; destinationIndex += bytesToRead; ensureAvailable(min(length, buffer.length())); } }
@Override public void readBytes(Slice destination, int destinationIndex, int length) { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, destination, destinationIndex, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; destinationIndex += bytesToRead; ensureAvailable(min(length, buffer.length())); } }
@Override public void readBytes(byte[] destination, int destinationIndex, int length) { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, destination, destinationIndex, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; destinationIndex += bytesToRead; ensureAvailable(min(length, buffer.length())); } }
@Override public void readBytes(OutputStream out, int length) throws IOException { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, out, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; ensureAvailable(min(length, buffer.length())); } }
@Override public void readBytes(byte[] destination, int destinationIndex, int length) { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, destination, destinationIndex, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; destinationIndex += bytesToRead; ensureAvailable(min(length, buffer.length())); } }
@Override public void readBytes(OutputStream out, int length) throws IOException { checkBound(position() + length, globalLength, "End of stream"); while (length > 0) { int bytesToRead = min(available(), length); buffer.getBytes(bufferPosition, out, bytesToRead); bufferPosition += bytesToRead; length -= bytesToRead; ensureAvailable(min(length, buffer.length())); } }
public void ensureAvailable(int size) { if (available() >= size) { return; } checkArgument(size <= buffer.length(), "Size is larger than buffer"); checkBound(position() + size, globalLength, "End of stream"); // advance position globalPosition += bufferPosition; bufferPosition = 0; // this will reread unused data in the buffer long readSize = min(buffer.length(), globalLength - globalPosition); if (readSize > Integer.MAX_VALUE) { readSize = Integer.MAX_VALUE; } bufferLength = (int) readSize; loader.load(globalPosition, bufferLength); }
public void ensureAvailable(int size) { if (available() >= size) { return; } checkArgument(size <= buffer.length(), "Size is larger than buffer"); checkBound(position() + size, globalLength, "End of stream"); // advance position globalPosition += bufferPosition; bufferPosition = 0; // this will reread unused data in the buffer long readSize = min(buffer.length(), globalLength - globalPosition); if (readSize > Integer.MAX_VALUE) { readSize = Integer.MAX_VALUE; } bufferLength = (int) readSize; loader.load(globalPosition, bufferLength); }
if (input.position() - SIZE_OF_INT >= end) { close(); return -1;
if (input.position() - SIZE_OF_INT >= end) { close(); return -1;