This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new 54d42b5  No weird C-like names.
54d42b5 is described below

commit 54d42b58efa9dfac29424fec5c8049aa1e17c313
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Apr 13 10:40:38 2020 -0400

    No weird C-like names.
---
 .../io/input/buffer/CircularBufferInputStream.java |  31 +++---
 .../io/input/buffer/CircularByteBuffer.java        | 108 ++++++++++-----------
 .../io/input/buffer/PeekableInputStream.java       |  53 +++++-----
 3 files changed, 96 insertions(+), 96 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java
 
b/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java
index 557cef0..32f2141 100644
--- 
a/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java
+++ 
b/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java
@@ -41,11 +41,10 @@ public class CircularBufferInputStream extends InputStream {
      *                    used internally.
      */
     public CircularBufferInputStream(final InputStream inputStream, final int 
bufferSize) {
-        Objects.requireNonNull(inputStream, "InputStream");
         if (bufferSize <= 0) {
-            throw new IllegalArgumentException("Invalid buffer size: " + 
bufferSize);
+            throw new IllegalArgumentException("Invalid bufferSize: " + 
bufferSize);
         }
-        this.in = inputStream;
+        this.in = Objects.requireNonNull(inputStream, "inputStream");
         this.buffer = new CircularByteBuffer(bufferSize);
         this.bufferSize = bufferSize;
         this.eofSeen = false;
@@ -55,10 +54,10 @@ public class CircularBufferInputStream extends InputStream {
      * Creates a new instance, which filters the given input stream, and
      * uses a reasonable default buffer size (8192).
      *
-     * @param pIn The input stream, which is being buffered.
+     * @param inputStream The input stream, which is being buffered.
      */
-    public CircularBufferInputStream(final InputStream pIn) {
-        this(pIn, 8192);
+    public CircularBufferInputStream(final InputStream inputStream) {
+        this(inputStream, 8192);
     }
 
     /**
@@ -87,12 +86,12 @@ public class CircularBufferInputStream extends InputStream {
     /**
      * Fills the buffer from the input stream until the given number of bytes 
have been added to the buffer.
      *
-     * @param number number of byte to fill into the buffer
+     * @param count number of byte to fill into the buffer
      * @return true if the buffer has bytes
      * @throws IOException in case of an error while reading from the input 
stream.
      */
-    protected boolean haveBytes(final int number) throws IOException {
-        if (buffer.getCurrentNumberOfBytes() < number) {
+    protected boolean haveBytes(final int count) throws IOException {
+        if (buffer.getCurrentNumberOfBytes() < count) {
             fillBuffer();
         }
         return buffer.hasBytes();
@@ -112,20 +111,20 @@ public class CircularBufferInputStream extends 
InputStream {
     }
 
     @Override
-    public int read(final byte[] pBuffer, final int pOffset, final int 
pLength) throws IOException {
-        Objects.requireNonNull(pBuffer, "Buffer");
-        if (pOffset < 0) {
+    public int read(final byte[] targetBuffer, final int offset, final int 
length) throws IOException {
+        Objects.requireNonNull(targetBuffer, "Buffer");
+        if (offset < 0) {
             throw new IllegalArgumentException("Offset must not be negative");
         }
-        if (pLength < 0) {
+        if (length < 0) {
             throw new IllegalArgumentException("Length must not be negative");
         }
-        if (!haveBytes(pLength)) {
+        if (!haveBytes(length)) {
             return -1;
         }
-        final int result = Math.min(pLength, buffer.getCurrentNumberOfBytes());
+        final int result = Math.min(length, buffer.getCurrentNumberOfBytes());
         for (int i = 0; i < result; i++) {
-            pBuffer[pOffset + i] = buffer.read();
+            targetBuffer[offset + i] = buffer.read();
         }
         return result;
     }
diff --git 
a/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java 
b/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java
index b15a737..9b497d9 100644
--- a/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java
+++ b/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java
@@ -72,9 +72,9 @@ public class CircularByteBuffer {
      * Returns the given number of bytes from the buffer by storing them in
      * the given byte array at the given offset.
      *
-     * @param pBuffer The byte array, where to add bytes.
-     * @param pOffset The offset, where to store bytes in the byte array.
-     * @param pLength The number of bytes to return.
+     * @param targetBuffer The byte array, where to add bytes.
+     * @param targetOffset The offset, where to store bytes in the byte array.
+     * @param length The number of bytes to return.
      * @throws NullPointerException     The byte array {@code pBuffer} is null.
      * @throws IllegalArgumentException Either of {@code pOffset}, or {@code 
pLength} is negative,
      *                                  or the length of the byte array {@code 
pBuffer} is too small.
@@ -82,26 +82,26 @@ public class CircularByteBuffer {
      *                                  of bytes. Use {@link 
#getCurrentNumberOfBytes()} to prevent this
      *                                  exception.
      */
-    public void read(final byte[] pBuffer, final int pOffset, final int 
pLength) {
-        Objects.requireNonNull(pBuffer);
-        if (pOffset < 0 || pOffset >= pBuffer.length) {
-            throw new IllegalArgumentException("Invalid offset: " + pOffset);
+    public void read(final byte[] targetBuffer, final int targetOffset, final 
int length) {
+        Objects.requireNonNull(targetBuffer);
+        if (targetOffset < 0 || targetOffset >= targetBuffer.length) {
+            throw new IllegalArgumentException("Invalid offset: " + 
targetOffset);
         }
-        if (pLength < 0 || pLength > buffer.length) {
-            throw new IllegalArgumentException("Invalid length: " + pLength);
+        if (length < 0 || length > buffer.length) {
+            throw new IllegalArgumentException("Invalid length: " + length);
         }
-        if (pOffset + pLength > pBuffer.length) {
+        if (targetOffset + length > targetBuffer.length) {
             throw new IllegalArgumentException("The supplied byte array 
contains only "
-                    + pBuffer.length + " bytes, but offset, and length would 
require "
-                    + (pOffset + pLength - 1));
+                    + targetBuffer.length + " bytes, but offset, and length 
would require "
+                    + (targetOffset + length - 1));
         }
-        if (currentNumberOfBytes < pLength) {
+        if (currentNumberOfBytes < length) {
             throw new IllegalStateException("Currently, there are only " + 
currentNumberOfBytes
-                    + "in the buffer, not " + pLength);
+                    + "in the buffer, not " + length);
         }
-        int offset = pOffset;
-        for (int i = 0; i < pLength; i++) {
-            pBuffer[offset++] = buffer[startOffset];
+        int offset = targetOffset;
+        for (int i = 0; i < length; i++) {
+            targetBuffer[offset++] = buffer[startOffset];
             --currentNumberOfBytes;
             if (++startOffset == buffer.length) {
                 startOffset = 0;
@@ -113,15 +113,15 @@ public class CircularByteBuffer {
      * Adds a new byte to the buffer, which will eventually be returned by 
following
      * invocations of {@link #read()}.
      *
-     * @param pByte The byte, which is being added to the buffer.
+     * @param value The byte, which is being added to the buffer.
      * @throws IllegalStateException The buffer is full. Use {@link 
#hasSpace()},
      *                               or {@link #getSpace()}, to prevent this 
exception.
      */
-    public void add(final byte pByte) {
+    public void add(final byte value) {
         if (currentNumberOfBytes >= buffer.length) {
             throw new IllegalStateException("No space available");
         }
-        buffer[endOffset] = pByte;
+        buffer[endOffset] = value;
         ++currentNumberOfBytes;
         if (++endOffset == buffer.length) {
             endOffset = 0;
@@ -130,37 +130,37 @@ public class CircularByteBuffer {
 
     /**
      * Returns, whether the next bytes in the buffer are exactly those, given 
by
-     * {@code pBuffer}, {@code pOffset}, and {@code pLength}. No bytes are 
being
+     * {@code sourceBuffer}, {@code offset}, and {@code length}. No bytes are 
being
      * removed from the buffer. If the result is true, then the following 
invocations
      * of {@link #read()} are guaranteed to return exactly those bytes.
      *
-     * @param pBuffer the buffer to compare against
-     * @param pOffset start offset
-     * @param pLength length to compare
+     * @param sourceBuffer the buffer to compare against
+     * @param offset start offset
+     * @param length length to compare
      * @return True, if the next invocations of {@link #read()} will return the
      * bytes at offsets {@code pOffset}+0, {@code pOffset}+1, ...,
      * {@code pOffset}+{@code pLength}-1 of byte array {@code pBuffer}.
      * @throws IllegalArgumentException Either of {@code pOffset}, or {@code 
pLength} is negative.
      * @throws NullPointerException     The byte array {@code pBuffer} is null.
      */
-    public boolean peek(final byte[] pBuffer, final int pOffset, final int 
pLength) {
-        Objects.requireNonNull(pBuffer, "Buffer");
-        if (pOffset < 0 || pOffset >= pBuffer.length) {
-            throw new IllegalArgumentException("Invalid offset: " + pOffset);
+    public boolean peek(final byte[] sourceBuffer, final int offset, final int 
length) {
+        Objects.requireNonNull(sourceBuffer, "Buffer");
+        if (offset < 0 || offset >= sourceBuffer.length) {
+            throw new IllegalArgumentException("Invalid offset: " + offset);
         }
-        if (pLength < 0 || pLength > buffer.length) {
-            throw new IllegalArgumentException("Invalid length: " + pLength);
+        if (length < 0 || length > buffer.length) {
+            throw new IllegalArgumentException("Invalid length: " + length);
         }
-        if (pLength < currentNumberOfBytes) {
+        if (length < currentNumberOfBytes) {
             return false;
         }
-        int offset = startOffset;
-        for (int i = 0; i < pLength; i++) {
-            if (buffer[offset] != pBuffer[i + pOffset]) {
+        int localOffset = startOffset;
+        for (int i = 0; i < length; i++) {
+            if (buffer[localOffset] != sourceBuffer[i + offset]) {
                 return false;
             }
-            if (++offset == buffer.length) {
-                offset = 0;
+            if (++localOffset == buffer.length) {
+                localOffset = 0;
             }
         }
         return true;
@@ -168,35 +168,35 @@ public class CircularByteBuffer {
 
     /**
      * Adds the given bytes to the buffer. This is the same as invoking {@link 
#add(byte)}
-     * for the bytes at offsets {@code pOffset}+0, {@code pOffset}+1, ...,
-     * {@code pOffset}+{@code pLength}-1 of byte array {@code pBuffer}.
+     * for the bytes at offsets {@code offset+0}, {@code offset+1}, ...,
+     * {@code offset+length-1} of byte array {@code targetBuffer}.
      *
-     * @param pBuffer the buffer to copy
-     * @param pOffset start offset
-     * @param pLength length to copy
+     * @param targetBuffer the buffer to copy
+     * @param offset start offset
+     * @param length length to copy
      * @throws IllegalStateException    The buffer doesn't have sufficient 
space. Use
      *                                  {@link #getSpace()} to prevent this 
exception.
      * @throws IllegalArgumentException Either of {@code pOffset}, or {@code 
pLength} is negative.
      * @throws NullPointerException     The byte array {@code pBuffer} is null.
      */
-    public void add(final byte[] pBuffer, final int pOffset, final int 
pLength) {
-        Objects.requireNonNull(pBuffer, "Buffer");
-        if (pOffset < 0 || pOffset >= pBuffer.length) {
-            throw new IllegalArgumentException("Invalid offset: " + pOffset);
+    public void add(final byte[] targetBuffer, final int offset, final int 
length) {
+        Objects.requireNonNull(targetBuffer, "Buffer");
+        if (offset < 0 || offset >= targetBuffer.length) {
+            throw new IllegalArgumentException("Invalid offset: " + offset);
         }
-        if (pLength < 0) {
-            throw new IllegalArgumentException("Invalid length: " + pLength);
+        if (length < 0) {
+            throw new IllegalArgumentException("Invalid length: " + length);
         }
-        if (currentNumberOfBytes + pLength > buffer.length) {
+        if (currentNumberOfBytes + length > buffer.length) {
             throw new IllegalStateException("No space available");
         }
-        for (int i = 0; i < pLength; i++) {
-            buffer[endOffset] = pBuffer[pOffset + i];
+        for (int i = 0; i < length; i++) {
+            buffer[endOffset] = targetBuffer[offset + i];
             if (++endOffset == buffer.length) {
                 endOffset = 0;
             }
         }
-        currentNumberOfBytes += pLength;
+        currentNumberOfBytes += length;
     }
 
     /**
@@ -214,13 +214,13 @@ public class CircularByteBuffer {
     /**
      * Returns, whether there is currently room for the given number of bytes 
in the buffer.
      *
-     * @param pBytes the byte count
+     * @param count the byte count
      * @return true if there is space for the given number of bytes
      * @see #hasSpace()
      * @see #getSpace()
      */
-    public boolean hasSpace(final int pBytes) {
-        return currentNumberOfBytes + pBytes <= buffer.length;
+    public boolean hasSpace(final int count) {
+        return currentNumberOfBytes + count <= buffer.length;
     }
 
     /**
diff --git 
a/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java 
b/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java
index 891f138..0cffdc2 100644
--- a/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java
@@ -27,68 +27,69 @@ import java.util.Objects;
  * scanners, lexers, parsers, or the like.
  */
 public class PeekableInputStream extends CircularBufferInputStream {
+
     /**
      * Creates a new instance, which filters the given input stream, and
      * uses the given buffer size.
      *
-     * @param pIn         The input stream, which is being buffered.
-     * @param pBufferSize The size of the {@link CircularByteBuffer}, which is
+     * @param inputStream         The input stream, which is being buffered.
+     * @param bufferSize The size of the {@link CircularByteBuffer}, which is
      *                    used internally.
      */
-    public PeekableInputStream(final InputStream pIn, final int pBufferSize) {
-        super(pIn, pBufferSize);
+    public PeekableInputStream(final InputStream inputStream, final int 
bufferSize) {
+        super(inputStream, bufferSize);
     }
 
     /**
      * Creates a new instance, which filters the given input stream, and
      * uses a reasonable default buffer size (8192).
      *
-     * @param pIn The input stream, which is being buffered.
+     * @param inputStream The input stream, which is being buffered.
      */
-    public PeekableInputStream(final InputStream pIn) {
-        super(pIn);
+    public PeekableInputStream(final InputStream inputStream) {
+        super(inputStream);
     }
 
     /**
      * Returns, whether the next bytes in the buffer are as given by
-     * {@code pBuffer}. This is equivalent to {@link #peek(byte[], int, int)}
-     * with {@code pOffset} == 0, and {@code pLength} == {@code pBuffer.length}
+     * {@code sourceBuffer}. This is equivalent to {@link #peek(byte[], int, 
int)}
+     * with {@code offset} == 0, and {@code length} == {@code 
sourceBuffer.length}
      *
-     * @param pBuffer the buffer to compare against
+     * @param sourceBuffer the buffer to compare against
      * @return true if the next bytes are as given
      * @throws IOException Refilling the buffer failed.
      */
-    public boolean peek(final byte[] pBuffer) throws IOException {
-        Objects.requireNonNull(pBuffer, "Buffer");
-        if (pBuffer.length > bufferSize) {
-            throw new IllegalArgumentException("Peek request size of " + 
pBuffer.length
+    public boolean peek(final byte[] sourceBuffer) throws IOException {
+        Objects.requireNonNull(sourceBuffer, "Buffer");
+        if (sourceBuffer.length > bufferSize) {
+            throw new IllegalArgumentException("Peek request size of " + 
sourceBuffer.length
                     + " bytes exceeds buffer size of " + bufferSize + " 
bytes");
         }
-        if (buffer.getCurrentNumberOfBytes() < pBuffer.length) {
+        if (buffer.getCurrentNumberOfBytes() < sourceBuffer.length) {
             fillBuffer();
         }
-        return buffer.peek(pBuffer, 0, pBuffer.length);
+        return buffer.peek(sourceBuffer, 0, sourceBuffer.length);
     }
 
     /**
      * Returns, whether the next bytes in the buffer are as given by
-     * {@code pBuffer}, {code pOffset}, and {@code pLength}.
+     * {@code sourceBuffer}, {code offset}, and {@code length}.
      *
-     * @param pBuffer the buffer to compare against
-     * @param pOffset the start offset
-     * @param pLength the length to compare
+     * @param sourceBuffer the buffer to compare against
+     * @param offset the start offset
+     * @param length the length to compare
      * @return true if the next bytes in the buffer are as given
      * @throws IOException if there is a problem calling fillBuffer()
      */
-    public boolean peek(final byte[] pBuffer, final int pOffset, final int 
pLength) throws IOException {
-        Objects.requireNonNull(pBuffer, "Buffer");
-        if (pBuffer.length > bufferSize) {
-            throw new IllegalArgumentException("Peek request size of " + 
pBuffer.length
+    public boolean peek(final byte[] sourceBuffer, final int offset, final int 
length) throws IOException {
+        Objects.requireNonNull(sourceBuffer, "Buffer");
+        if (sourceBuffer.length > bufferSize) {
+            throw new IllegalArgumentException("Peek request size of " + 
sourceBuffer.length
                     + " bytes exceeds buffer size of " + bufferSize + " 
bytes");
         }
-        if (buffer.getCurrentNumberOfBytes() < pBuffer.length) {
+        if (buffer.getCurrentNumberOfBytes() < sourceBuffer.length) {
             fillBuffer();
         }
-        return buffer.peek(pBuffer, pOffset, pLength);
+        return buffer.peek(sourceBuffer, offset, length);
     }
 }

Reply via email to