{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/34847379","id":34847379,"diff_hunk":"@@ -0,0 +1,166 @@\n+/*\n+ * Copyright 2015 The Netty Project\n+ *\n+ * The Netty Project licenses this file to you under the Apache License,\n+ * version 2.0 (the \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at:\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package io.netty.buffer;\n+\n+import io.netty.util.ReferenceCounted;\n+\n+import java.io.IOException;\n+import java.nio.channels.WritableByteChannel;\n+\n+/**\n+ * An object that contains a readable region. For simplicity, extends {@link ReferenceCounted}.\n+ */\n+public interface ReadableObject extends ReferenceCounted {\n+    /**\n+     * Returns current read position in the object.\n+     */\n+    long readerPosition();\n+\n+    /**\n+     * Sets the {@code readerPosition} of this object.\n+     *\n+     * @throws IndexOutOfBoundsException\n+     *         if the specified {@code readerPosition} is\n+     *            less than {@code 0} or\n+     *            greater than {@link #readerLimit()}.\n+     */\n+    ReadableObject readerPosition(long readerPosition);\n+\n+    /**\n+     * Gets the read position limit (exclusive). The value of {@code readerPosition} must always\n+     * be less than or equal to this limit.\n+     */\n+    long readerLimit();\n+\n+    /**\n+     * Returns {@code true} if and only if {@link #readableBytes()} > {@code 0}.\n+     */\n+    boolean isReadable();\n+\n+    /**\n+     * Returns {@code true} if and only if this buffer contains equal to or more than the specified number of elements.\n+     */\n+    boolean isReadable(int size);\n+\n+    /**\n+     * Returns the number of readable bytes in this object.\n+     */\n+    long readableBytes();\n+\n+    /**\n+     * Increases the current {@code readerPosition} by the specified\n+     * {@code length} in this buffer.\n+     *\n+     * @throws IndexOutOfBoundsException\n+     *         if {@code length} is greater than {@link #readableBytes()}\n+     */\n+    ReadableObject skipBytes(long length);\n+\n+    /**\n+     * Returns a slice of this object's readable region. This method is\n+     * identical to {@code r.slice(r.readerPosition(), r.readableBytes())}.\n+     * This method does not modify {@code readerPosition}.\n+     * <p>\n+     * Also be aware that this method will NOT call {@link #retain()} and so the\n+     * reference count will NOT be increased.\n+     */\n+    ReadableObject slice();\n+\n+    /**\n+     * Returns a slice of this object's sub-region. This method does not modify\n+     * {@code readerPosition}.\n+     * <p>\n+     * Also be aware that this method will NOT call {@link #retain()} and so the\n+     * reference count will NOT be increased.\n+     *\n+     * @param position the starting position for the slice.\n+     *\n+     * @param length the size of the new slice relative to {@code position}.","path":"buffer/src/main/java/io/netty/buffer/ReadableObject.java","position":92,"original_position":92,"commit_id":"1300d36e0336e79cfa7c6432a7cd323563178b73","original_commit_id":"1300d36e0336e79cfa7c6432a7cd323563178b73","user":{"login":"Scottmitch","id":7562868,"avatar_url":"https://avatars.githubusercontent.com/u/7562868?v=3","gravatar_id":"","url":"https://api.github.com/users/Scottmitch","html_url":"https://github.com/Scottmitch","followers_url":"https://api.github.com/users/Scottmitch/followers","following_url":"https://api.github.com/users/Scottmitch/following{/other_user}","gists_url":"https://api.github.com/users/Scottmitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Scottmitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scottmitch/subscriptions","organizations_url":"https://api.github.com/users/Scottmitch/orgs","repos_url":"https://api.github.com/users/Scottmitch/repos","events_url":"https://api.github.com/users/Scottmitch/events{/privacy}","received_events_url":"https://api.github.com/users/Scottmitch/received_events","type":"User","site_admin":false},"body":"`{@code position}` -> `{@link #readerPosition()}`?","created_at":"2015-07-16T22:56:35Z","updated_at":"2015-07-16T22:56:35Z","html_url":"https://github.com/netty/netty/pull/3969#discussion_r34847379","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/3969","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/34847379"},"html":{"href":"https://github.com/netty/netty/pull/3969#discussion_r34847379"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/3969"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/3969","id":39629074,"html_url":"https://github.com/netty/netty/pull/3969","diff_url":"https://github.com/netty/netty/pull/3969.diff","patch_url":"https://github.com/netty/netty/pull/3969.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/3969","number":3969,"state":"open","locked":false,"title":"(POC) Refactor FileRegion to implement new ReadableObject API","user":{"login":"nmittler","id":6493296,"avatar_url":"https://avatars.githubusercontent.com/u/6493296?v=3","gravatar_id":"","url":"https://api.github.com/users/nmittler","html_url":"https://github.com/nmittler","followers_url":"https://api.github.com/users/nmittler/followers","following_url":"https://api.github.com/users/nmittler/following{/other_user}","gists_url":"https://api.github.com/users/nmittler/gists{/gist_id}","starred_url":"https://api.github.com/users/nmittler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmittler/subscriptions","organizations_url":"https://api.github.com/users/nmittler/orgs","repos_url":"https://api.github.com/users/nmittler/repos","events_url":"https://api.github.com/users/nmittler/events{/privacy}","received_events_url":"https://api.github.com/users/nmittler/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nBased on #3965. As a first step of integrating the unified reading API, the low-hanging fruit is to refactor `FIleRegion` to use it.\r\n\r\nModifications:\r\n\r\nRefactored `FileRegion` to extend `ReadableObject` and implemented the new interface in `DefaultFileRegion`.\r\n\r\nResult:\r\n\r\n`FileRegion` implements the new `ReadableObject` interface.","created_at":"2015-07-09T21:14:54Z","updated_at":"2015-07-16T22:56:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56806e8b6313b9b4bea3b5522174abd50f128d90","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/3969/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/3969/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/3969/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/1300d36e0336e79cfa7c6432a7cd323563178b73","head":{"label":"nmittler:refactor_fileregion","ref":"refactor_fileregion","sha":"1300d36e0336e79cfa7c6432a7cd323563178b73","user":{"login":"nmittler","id":6493296,"avatar_url":"https://avatars.githubusercontent.com/u/6493296?v=3","gravatar_id":"","url":"https://api.github.com/users/nmittler","html_url":"https://github.com/nmittler","followers_url":"https://api.github.com/users/nmittler/followers","following_url":"https://api.github.com/users/nmittler/following{/other_user}","gists_url":"https://api.github.com/users/nmittler/gists{/gist_id}","starred_url":"https://api.github.com/users/nmittler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmittler/subscriptions","organizations_url":"https://api.github.com/users/nmittler/orgs","repos_url":"https://api.github.com/users/nmittler/repos","events_url":"https://api.github.com/users/nmittler/events{/privacy}","received_events_url":"https://api.github.com/users/nmittler/received_events","type":"User","site_admin":false},"repo":{"id":18468502,"name":"netty","full_name":"nmittler/netty","owner":{"login":"nmittler","id":6493296,"avatar_url":"https://avatars.githubusercontent.com/u/6493296?v=3","gravatar_id":"","url":"https://api.github.com/users/nmittler","html_url":"https://github.com/nmittler","followers_url":"https://api.github.com/users/nmittler/followers","following_url":"https://api.github.com/users/nmittler/following{/other_user}","gists_url":"https://api.github.com/users/nmittler/gists{/gist_id}","starred_url":"https://api.github.com/users/nmittler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmittler/subscriptions","organizations_url":"https://api.github.com/users/nmittler/orgs","repos_url":"https://api.github.com/users/nmittler/repos","events_url":"https://api.github.com/users/nmittler/events{/privacy}","received_events_url":"https://api.github.com/users/nmittler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nmittler/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/nmittler/netty","forks_url":"https://api.github.com/repos/nmittler/netty/forks","keys_url":"https://api.github.com/repos/nmittler/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nmittler/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nmittler/netty/teams","hooks_url":"https://api.github.com/repos/nmittler/netty/hooks","issue_events_url":"https://api.github.com/repos/nmittler/netty/issues/events{/number}","events_url":"https://api.github.com/repos/nmittler/netty/events","assignees_url":"https://api.github.com/repos/nmittler/netty/assignees{/user}","branches_url":"https://api.github.com/repos/nmittler/netty/branches{/branch}","tags_url":"https://api.github.com/repos/nmittler/netty/tags","blobs_url":"https://api.github.com/repos/nmittler/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nmittler/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nmittler/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/nmittler/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nmittler/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/nmittler/netty/languages","stargazers_url":"https://api.github.com/repos/nmittler/netty/stargazers","contributors_url":"https://api.github.com/repos/nmittler/netty/contributors","subscribers_url":"https://api.github.com/repos/nmittler/netty/subscribers","subscription_url":"https://api.github.com/repos/nmittler/netty/subscription","commits_url":"https://api.github.com/repos/nmittler/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/nmittler/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/nmittler/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/nmittler/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/nmittler/netty/contents/{+path}","compare_url":"https://api.github.com/repos/nmittler/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nmittler/netty/merges","archive_url":"https://api.github.com/repos/nmittler/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nmittler/netty/downloads","issues_url":"https://api.github.com/repos/nmittler/netty/issues{/number}","pulls_url":"https://api.github.com/repos/nmittler/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/nmittler/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/nmittler/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nmittler/netty/labels{/name}","releases_url":"https://api.github.com/repos/nmittler/netty/releases{/id}","created_at":"2014-04-05T14:33:03Z","updated_at":"2015-02-02T15:50:48Z","pushed_at":"2015-07-16T22:33:54Z","git_url":"git://github.com/nmittler/netty.git","ssh_url":"git@github.com:nmittler/netty.git","clone_url":"https://github.com/nmittler/netty.git","svn_url":"https://github.com/nmittler/netty","homepage":"http://netty.io/","size":42761,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"netty:master","ref":"master","sha":"0b12592acb2dd6032305f21364effcdcba8c4066","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","created_at":"2010-11-09T09:22:21Z","updated_at":"2015-07-16T15:02:26Z","pushed_at":"2015-07-16T22:42:34Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":129553,"stargazers_count":4925,"watchers_count":4925,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2452,"mirror_url":null,"open_issues_count":314,"forks":2452,"open_issues":314,"watchers":4925,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/3969"},"html":{"href":"https://github.com/netty/netty/pull/3969"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/3969"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/3969/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/3969/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/3969/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/1300d36e0336e79cfa7c6432a7cd323563178b73"}}}}