home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class BufferedReader extends Reader {
- // $FF: renamed from: in java.io.Reader
- private Reader field_0;
- // $FF: renamed from: cb char[]
- private char[] field_1;
- private int nChars;
- private int nextChar;
- private static final int INVALIDATED = -2;
- private static final int UNMARKED = -1;
- private int markedChar;
- private int readAheadLimit;
- private boolean skipLF;
- private boolean markedSkipLF;
- private static int defaultCharBufferSize = 8192;
- private static int defaultExpectedLineLength = 80;
-
- public BufferedReader(Reader var1, int var2) {
- super(var1);
- this.markedChar = -1;
- this.readAheadLimit = 0;
- this.skipLF = false;
- this.markedSkipLF = false;
- if (var2 <= 0) {
- throw new IllegalArgumentException("Buffer size <= 0");
- } else {
- this.field_0 = var1;
- this.field_1 = new char[var2];
- this.nextChar = this.nChars = 0;
- }
- }
-
- public BufferedReader(Reader var1) {
- this(var1, defaultCharBufferSize);
- }
-
- private void ensureOpen() throws IOException {
- if (this.field_0 == null) {
- throw new IOException("Stream closed");
- }
- }
-
- private void fill() throws IOException {
- int var1;
- if (this.markedChar <= -1) {
- var1 = 0;
- } else {
- int var2 = this.nextChar - this.markedChar;
- if (var2 >= this.readAheadLimit) {
- this.markedChar = -2;
- this.readAheadLimit = 0;
- var1 = 0;
- } else {
- if (this.readAheadLimit <= this.field_1.length) {
- System.arraycopy(this.field_1, this.markedChar, this.field_1, 0, var2);
- this.markedChar = 0;
- var1 = var2;
- } else {
- char[] var3 = new char[this.readAheadLimit];
- System.arraycopy(this.field_1, this.markedChar, var3, 0, var2);
- this.field_1 = var3;
- this.markedChar = 0;
- var1 = var2;
- }
-
- this.nextChar = this.nChars = var2;
- }
- }
-
- int var4;
- do {
- var4 = this.field_0.read(this.field_1, var1, this.field_1.length - var1);
- } while(var4 == 0);
-
- if (var4 > 0) {
- this.nChars = var1 + var4;
- this.nextChar = var1;
- }
-
- }
-
- public int read() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
-
- while(true) {
- if (this.nextChar >= this.nChars) {
- this.fill();
- if (this.nextChar >= this.nChars) {
- byte var5 = -1;
- return var5;
- }
- }
-
- if (!this.skipLF) {
- break;
- }
-
- this.skipLF = false;
- if (this.field_1[this.nextChar] != '\n') {
- break;
- }
-
- ++this.nextChar;
- }
-
- char var2 = this.field_1[this.nextChar++];
- return var2;
- }
- }
-
- private int read1(char[] var1, int var2, int var3) throws IOException {
- if (this.nextChar >= this.nChars) {
- if (var3 >= this.field_1.length && this.markedChar <= -1 && !this.skipLF) {
- return this.field_0.read(var1, var2, var3);
- }
-
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- return -1;
- } else {
- if (this.skipLF) {
- this.skipLF = false;
- if (this.field_1[this.nextChar] == '\n') {
- ++this.nextChar;
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- return -1;
- }
- }
- }
-
- int var4 = Math.min(var3, this.nChars - this.nextChar);
- System.arraycopy(this.field_1, this.nextChar, var1, var2, var4);
- this.nextChar += var4;
- return var4;
- }
- }
-
- public int read(char[] var1, int var2, int var3) throws IOException {
- Object var4 = super.lock;
- synchronized(var4) {
- this.ensureOpen();
- if (var2 >= 0 && var2 <= var1.length && var3 >= 0 && var2 + var3 <= var1.length && var2 + var3 >= 0) {
- if (var3 == 0) {
- byte var10 = 0;
- return var10;
- } else {
- int var5 = this.read1(var1, var2, var3);
- if (var5 <= 0) {
- return var5;
- } else {
- while(var5 < var3 && this.field_0.ready()) {
- int var7 = this.read1(var1, var2 + var5, var3 - var5);
- if (var7 <= 0) {
- break;
- }
-
- var5 += var7;
- }
-
- return var5;
- }
- }
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
- }
-
- String readLine(boolean var1) throws IOException {
- StringBuffer var2 = null;
- boolean var4 = var1 || this.skipLF;
- Object var5 = super.lock;
- synchronized(var5) {
- this.ensureOpen();
-
- while(true) {
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- if (var2 != null && var2.length() > 0) {
- String var13 = var2.toString();
- return var13;
- }
-
- Object var14 = null;
- return (String)var14;
- }
-
- boolean var6 = false;
- char var7 = 0;
- if (var4 && this.field_1[this.nextChar] == '\n') {
- ++this.nextChar;
- }
-
- this.skipLF = false;
- var4 = false;
-
- int var8;
- for(var8 = this.nextChar; var8 < this.nChars; ++var8) {
- var7 = this.field_1[var8];
- if (var7 == '\n' || var7 == '\r') {
- var6 = true;
- break;
- }
- }
-
- int var3 = this.nextChar;
- this.nextChar = var8;
- if (var6) {
- String var9;
- if (var2 == null) {
- var9 = new String(this.field_1, var3, var8 - var3);
- } else {
- var2.append(this.field_1, var3, var8 - var3);
- var9 = var2.toString();
- }
-
- ++this.nextChar;
- if (var7 == '\r') {
- this.skipLF = true;
- }
-
- return var9;
- }
-
- if (var2 == null) {
- var2 = new StringBuffer(defaultExpectedLineLength);
- }
-
- var2.append(this.field_1, var3, var8 - var3);
- }
- }
- }
-
- public String readLine() throws IOException {
- return this.readLine(false);
- }
-
- public long skip(long var1) throws IOException {
- if (var1 < 0L) {
- throw new IllegalArgumentException("skip value is negative");
- } else {
- Object var3 = super.lock;
- synchronized(var3) {
- this.ensureOpen();
-
- long var4;
- for(var4 = var1; var4 > 0L; this.nextChar = this.nChars) {
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- break;
- }
-
- if (this.skipLF) {
- this.skipLF = false;
- if (this.field_1[this.nextChar] == '\n') {
- ++this.nextChar;
- }
- }
-
- long var6 = (long)(this.nChars - this.nextChar);
- if (var4 <= var6) {
- this.nextChar = (int)((long)this.nextChar + var4);
- var4 = 0L;
- break;
- }
-
- var4 -= var6;
- }
-
- long var10 = var1 - var4;
- return var10;
- }
- }
- }
-
- public boolean ready() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- boolean var2 = this.nextChar < this.nChars || this.field_0.ready();
- return var2;
- }
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public void mark(int var1) throws IOException {
- if (var1 < 0) {
- throw new IllegalArgumentException("Read-ahead limit < 0");
- } else {
- Object var2 = super.lock;
- synchronized(var2) {
- this.ensureOpen();
- this.readAheadLimit = var1;
- this.markedChar = this.nextChar;
- this.markedSkipLF = this.skipLF;
- }
- }
- }
-
- public void reset() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- if (this.markedChar < 0) {
- throw new IOException(this.markedChar == -2 ? "Mark invalid" : "Stream not marked");
- } else {
- this.nextChar = this.markedChar;
- this.skipLF = this.markedSkipLF;
- }
- }
- }
-
- public void close() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- if (this.field_0 != null) {
- this.field_0.close();
- this.field_0 = null;
- this.field_1 = null;
- }
- }
- }
- }
-