protected Payload doSlice(final FSDataInputStream inputStream, final long offset, final long length) { return new InputStreamSupplierPayload(new InputSupplier<InputStream>() { public InputStream getInput() throws IOException { if (offset > 0) { try { inputStream.seek(offset); } catch (IOException e) { Closeables.closeQuietly(inputStream); throw e; } } return new LimitInputStream(inputStream, length); } }); } }
protected Payload doSlice(byte[] content, long offset, long length) { Payload returnVal; checkArgument(offset <= Integer.MAX_VALUE, "offset is too big for an array"); checkArgument(length <= Integer.MAX_VALUE, "length is too big for an array"); returnVal = new InputStreamSupplierPayload( ByteStreams.newInputStreamSupplier(content, (int) offset, (int) length)); return returnVal; }
protected Payload doSlice(byte[] content, long offset, long length) { Payload returnVal; checkArgument(offset <= Integer.MAX_VALUE, "offset is too big for an array"); checkArgument(length <= Integer.MAX_VALUE, "length is too big for an array"); returnVal = new InputStreamSupplierPayload( ByteStreams.newInputStreamSupplier(content, (int) offset, (int) length)); return returnVal; }
protected Payload doSlice(byte[] content, long offset, long length) { Payload returnVal; checkArgument(offset <= Integer.MAX_VALUE, "offset is too big for an array"); checkArgument(length <= Integer.MAX_VALUE, "length is too big for an array"); returnVal = new InputStreamSupplierPayload( ByteStreams.newInputStreamSupplier(content, (int) offset, (int) length)); return returnVal; }
protected Payload doSlice(Payload content, long offset, long length) { return new InputStreamSupplierPayload(ByteStreams.slice(content, offset, length)); }
protected Payload doSlice(Payload content, long offset, long length) { return new InputStreamSupplierPayload(ByteStreams.slice(content, offset, length)); }
protected Payload doSlice(InputSupplier<? extends InputStream> content, long offset, long length) { return new InputStreamSupplierPayload(ByteStreams.slice(content, offset, length)); }
protected Payload doSlice(File content, long offset, long length) { return new InputStreamSupplierPayload(ByteStreams.slice(Files.newInputStreamSupplier(content), offset, length)); }
protected Payload doSlice(File content, long offset, long length) { return new InputStreamSupplierPayload(ByteStreams.slice(Files.newInputStreamSupplier(content), offset, length)); }