home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class PushbackReader extends FilterReader {
- private char[] buf;
- private int pos;
-
- public PushbackReader(Reader var1, int var2) {
- super(var1);
- if (var2 <= 0) {
- throw new IllegalArgumentException("size <= 0");
- } else {
- this.buf = new char[var2];
- this.pos = var2;
- }
- }
-
- public PushbackReader(Reader var1) {
- this(var1, 1);
- }
-
- private void ensureOpen() throws IOException {
- if (this.buf == null) {
- throw new IOException("Stream closed");
- }
- }
-
- public int read() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- if (this.pos < this.buf.length) {
- char var2 = this.buf[this.pos++];
- return var2;
- } else {
- int var3 = super.read();
- return var3;
- }
- }
- }
-
- public int read(char[] var1, int var2, int var3) throws IOException {
- Object var4 = super.lock;
- synchronized(var4) {
- this.ensureOpen();
-
- try {
- if (var3 <= 0) {
- if (var3 < 0) {
- throw new IndexOutOfBoundsException();
- } else if (var2 >= 0 && var2 <= var1.length) {
- byte var11 = 0;
- return var11;
- } else {
- throw new IndexOutOfBoundsException();
- }
- } else {
- int var5 = this.buf.length - this.pos;
- if (var5 > 0) {
- if (var3 < var5) {
- var5 = var3;
- }
-
- System.arraycopy(this.buf, this.pos, var1, var2, var5);
- this.pos += var5;
- var2 += var5;
- var3 -= var5;
- }
-
- if (var3 > 0) {
- var3 = super.read(var1, var2, var3);
- if (var3 == -1) {
- int var12 = var5 == 0 ? -1 : var5;
- return var12;
- } else {
- int var6 = var5 + var3;
- return var6;
- }
- } else {
- return var5;
- }
- }
- } catch (ArrayIndexOutOfBoundsException var8) {
- throw new IndexOutOfBoundsException();
- }
- }
- }
-
- public void unread(int var1) throws IOException {
- Object var2 = super.lock;
- synchronized(var2) {
- this.ensureOpen();
- if (this.pos == 0) {
- throw new IOException("Pushback buffer overflow");
- } else {
- this.buf[--this.pos] = (char)var1;
- }
- }
- }
-
- public void unread(char[] var1, int var2, int var3) throws IOException {
- Object var4 = super.lock;
- synchronized(var4) {
- this.ensureOpen();
- if (var3 > this.pos) {
- throw new IOException("Pushback buffer overflow");
- } else {
- this.pos -= var3;
- System.arraycopy(var1, var2, this.buf, this.pos, var3);
- }
- }
- }
-
- public void unread(char[] var1) throws IOException {
- this.unread(var1, 0, var1.length);
- }
-
- public boolean ready() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- boolean var2 = this.pos < this.buf.length || super.ready();
- return var2;
- }
- }
-
- public void mark(int var1) throws IOException {
- throw new IOException("mark/reset not supported");
- }
-
- public void reset() throws IOException {
- throw new IOException("mark/reset not supported");
- }
-
- public boolean markSupported() {
- return false;
- }
-
- public void close() throws IOException {
- super.close();
- this.buf = null;
- }
- }
-