home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class CharArrayReader extends Reader {
- protected char[] buf;
- protected int pos;
- protected int markedPos = 0;
- protected int count;
-
- public CharArrayReader(char[] var1) {
- this.buf = var1;
- this.pos = 0;
- this.count = var1.length;
- }
-
- public CharArrayReader(char[] var1, int var2, int var3) {
- if (var2 >= 0 && var2 <= var1.length && var3 >= 0 && var2 + var3 >= 0) {
- this.buf = var1;
- this.pos = var2;
- this.count = Math.min(var2 + var3, var1.length);
- this.markedPos = var2;
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- 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.count) {
- byte var2 = -1;
- return var2;
- } else {
- char var3 = this.buf[this.pos++];
- return var3;
- }
- }
- }
-
- 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 var9 = 0;
- return var9;
- } else if (this.pos >= this.count) {
- byte var8 = -1;
- return var8;
- } else {
- if (this.pos + var3 > this.count) {
- var3 = this.count - this.pos;
- }
-
- if (var3 <= 0) {
- byte var5 = 0;
- return var5;
- } else {
- System.arraycopy(this.buf, this.pos, var1, var2, var3);
- this.pos += var3;
- return var3;
- }
- }
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
- }
-
- public long skip(long var1) throws IOException {
- Object var3 = super.lock;
- synchronized(var3) {
- this.ensureOpen();
- if ((long)this.pos + var1 > (long)this.count) {
- var1 = (long)(this.count - this.pos);
- }
-
- if (var1 < 0L) {
- long var4 = 0L;
- return var4;
- } else {
- this.pos = (int)((long)this.pos + var1);
- return var1;
- }
- }
- }
-
- public boolean ready() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- boolean var2 = this.count - this.pos > 0;
- return var2;
- }
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public void mark(int var1) throws IOException {
- Object var2 = super.lock;
- synchronized(var2) {
- this.ensureOpen();
- this.markedPos = this.pos;
- }
- }
-
- public void reset() throws IOException {
- Object var1 = super.lock;
- synchronized(var1) {
- this.ensureOpen();
- this.pos = this.markedPos;
- }
- }
-
- public void close() {
- this.buf = null;
- }
- }
-