mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user