1 24 25 package com.mckoi.database; 26 27 import java.io.*; 28 29 34 35 final class CellInputStream implements CellInput { 36 37 40 private InputStream parent_stream; 41 42 45 CellInputStream(InputStream parent_stream) { 46 setParentStream(parent_stream); 47 } 48 49 53 public void setParentStream(InputStream parent_stream) { 54 this.parent_stream = parent_stream; 55 } 56 57 public int read() throws IOException { 58 return parent_stream.read(); 59 } 60 61 public int read(byte b[], int off, int len) throws IOException { 62 return parent_stream.read(b, off, len); 63 } 64 65 public long skip(long n) throws IOException { 66 return parent_stream.skip(n); 67 } 68 69 public int available() throws IOException { 70 return parent_stream.available(); 71 } 72 73 public void mark(int readAheadLimit) throws IOException { 74 parent_stream.mark(readAheadLimit); 75 } 76 77 public void reset() throws IOException { 78 parent_stream.reset(); 79 } 80 81 public void close() throws IOException { 82 parent_stream.close(); 83 } 84 85 86 88 public void readFully(byte[] b) throws IOException { 89 read(b, 0, b.length); 90 } 91 92 public void readFully(byte b[], int off, int len) throws IOException { 93 read(b, off, len); 94 } 95 96 public int skipBytes(int n) throws IOException { 97 return (int) skip(n); 98 } 99 100 public boolean readBoolean() throws IOException { 101 return (read() != 0); 102 } 103 104 public byte readByte() throws IOException { 105 return (byte) read(); 106 } 107 108 public int readUnsignedByte() throws IOException { 109 return read(); 110 } 111 112 public short readShort() throws IOException { 113 int ch1 = read(); 114 int ch2 = read(); 115 return (short)((ch1 << 8) + (ch2 << 0)); 116 } 117 118 public int readUnsignedShort() throws IOException { 119 int ch1 = read(); 120 int ch2 = read(); 121 return (ch1 << 8) + (ch2 << 0); 122 } 123 124 public char readChar() throws IOException { 125 int ch1 = read(); 126 int ch2 = read(); 127 return (char)((ch1 << 8) + (ch2 << 0)); 128 } 129 130 private char[] char_buffer; 131 132 public String readChars(int length) throws IOException { 133 if (length <= 8192) { 134 if (char_buffer == null) { 135 char_buffer = new char[8192]; 136 } 137 for (int i = 0; i < length; ++i) { 138 char_buffer[i] = readChar(); 139 } 140 return new String (char_buffer, 0, length); 141 } 142 else { 143 StringBuffer chrs = new StringBuffer (length); 144 for (int i = length; i > 0; --i) { 145 chrs.append(readChar()); 146 } 147 return new String (chrs); 148 } 149 } 150 151 public int readInt() throws IOException { 152 int ch1 = read(); 153 int ch2 = read(); 154 int ch3 = read(); 155 int ch4 = read(); 156 return (int)((ch1 << 24) + (ch2 << 16) + 157 (ch3 << 8) + (ch4 << 0)); 158 } 159 160 public long readLong() throws IOException { 161 return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL); 162 } 163 164 public float readFloat() throws IOException { 165 return Float.intBitsToFloat(readInt()); 166 } 167 168 public double readDouble() throws IOException { 169 return Double.longBitsToDouble(readLong()); 170 } 171 172 public String readLine() throws IOException { 173 throw new Error ("Not implemented."); 174 } 175 176 public String readUTF() throws IOException { 177 throw new Error ("Not implemented."); 178 } 179 180 } 181 | Popular Tags |