Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

docs: update javadocs for ReadChannel to be more clear about the behavior #1050

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions google-cloud-core/src/main/java/com/google/cloud/ReadChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public interface ReadChannel extends ReadableByteChannel, Closeable, Restorable<
@Override
void close();

/** Set the offset to read from. */
void seek(long position) throws IOException;

/**
Expand All @@ -62,6 +63,23 @@ public interface ReadChannel extends ReadableByteChannel, Closeable, Restorable<
* <p>If used in conjunction with {@link #seek(long)} the total number of returned bytes from this
* channel will be reduced by the number of bytes specified to seek.
*
* <p>The value provided as {@code limit} will define a <a target="_blank" rel="noopener
* noreferrer"
* href="https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals">left-closed,
* right-open</a> interval along with either {@code 0} or any value provided to {@link
* #seek(long)}, i.e. {@code [}{@link #seek(long)}{@code , }{@link #limit(long)}{@code )}.
BenWhitehead marked this conversation as resolved.
Show resolved Hide resolved
*
* <h3>An example to help illustrate the relationship</h3>
*
* Imagine some data {@code [A, B, C, D, E, F, G, H, I, J]}, 10 bytes total.
*
* <ol>
* <li>{@code limit(5)} would produce {@code [A, B, C, D, E]}
* <li>{@code seek(8)} would produce {@code [I, J]}
* <li>{@code seek(2)} {@code limit(5)} would produce {@code [C, D, E]}
* <li>{@code seek(3)} {@code limit(3)} would produce {@code []}
* </ol>
*
* <p><i>NOTE:</i>Implementers are not required to return a new instance from this method, however
* they are allowed to. Users of this method should always use the instance returned from this
* method.
Expand Down