From 6f9b36e064a4e353566db56b64db40e12bb63be8 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 8 May 2013 12:26:00 +0400 Subject: [PATCH] cleanup --- .../util/io/UnsyncByteArrayInputStream.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java b/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java index 41af61ef256e..830a7e0a0eab 100644 --- a/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java +++ b/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java @@ -15,32 +15,34 @@ */ package com.intellij.util.io; +import org.jetbrains.annotations.NotNull; + import java.io.InputStream; public class UnsyncByteArrayInputStream extends InputStream { protected byte[] myBuffer; private int myPosition; - private int myCount; + private final int myCount; private int myMarkedPosition; - public UnsyncByteArrayInputStream(byte buf[]) { + public UnsyncByteArrayInputStream(@NotNull byte[] buf) { this(buf, 0, buf.length); } - public UnsyncByteArrayInputStream(byte buf[], int offset, int length) { - this.myBuffer = buf; - this.myPosition = offset; - this.myCount = length; + public UnsyncByteArrayInputStream(byte[] buf, int offset, int length) { + myBuffer = buf; + myPosition = offset; + myCount = length; } + @Override public int read() { - return (myPosition < myCount) ? (myBuffer[myPosition++] & 0xff) : -1; + return myPosition < myCount ? myBuffer[myPosition++] & 0xff : -1; } - public int read(byte b[], int off, int len) { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || len < 0 || len > b.length - off) { + @Override + public int read(@NotNull byte[] b, int off, int len) { + if (off < 0 || len < 0 || len > b.length - off) { throw new IndexOutOfBoundsException(); } if (myPosition >= myCount) { @@ -57,6 +59,7 @@ public class UnsyncByteArrayInputStream extends InputStream { return len; } + @Override public long skip(long n) { if (myPosition + n > myCount) { n = myCount - myPosition; @@ -68,6 +71,7 @@ public class UnsyncByteArrayInputStream extends InputStream { return n; } + @Override public int available() { return myCount - myPosition; } @@ -82,6 +86,7 @@ public class UnsyncByteArrayInputStream extends InputStream { myMarkedPosition = myPosition; } + @Override public void reset() { myPosition = myMarkedPosition; }