1 2 3 package cz.cuni.sofa.lib.Impl; 4 import java.io.IOException ; 5 6 8 public class ByteArrayInputStream extends cz.cuni.sofa.lib.InputStream { 9 private java.io.ObjectInputStream in; 10 private java.io.ByteArrayInputStream internal; 11 12 public ByteArrayInputStream(byte[] buff) throws IOException { 13 internal = new java.io.ByteArrayInputStream (buff); 14 in = new java.io.ObjectInputStream (internal); 15 } 16 17 public ByteArrayInputStream(String buff) throws IOException { 18 internal = new java.io.ByteArrayInputStream (buff.getBytes()); 19 in = new java.io.ObjectInputStream (internal); 20 } 21 22 public int read() throws IOException { 23 return in.read(); 24 } 25 26 public boolean read_boolean() throws IOException { 27 return in.readBoolean(); 28 } 29 30 public char read_char() throws IOException { 31 return in.readChar(); 32 } 33 34 public char read_wchar() throws IOException { 35 return in.readChar(); 36 } 37 public byte read_octet() throws IOException { 38 return in.readByte(); 39 } 40 41 public short read_short() throws IOException { 42 return in.readShort(); 43 } 44 45 public short read_ushort() throws IOException { 46 return in.readShort(); 47 } 48 49 public int read_long() throws IOException { 50 return in.readInt(); 51 } 52 53 public int read_ulong() throws IOException { 54 return in.readInt(); 55 } 56 57 public long read_longlong() throws IOException { 58 return in.readLong(); 59 } 60 61 public long read_ulonglong() throws IOException { 62 return in.readLong(); 63 } 64 65 public float read_float() throws IOException { 66 return in.readFloat(); 67 } 68 69 public double read_double() throws IOException { 70 return in.readDouble(); 71 } 72 73 public String read_string() throws IOException { 74 return in.readUTF(); 75 } 76 77 public String read_wstring() throws IOException { 78 return in.readUTF(); 79 } 80 81 public void read_boolean_array(boolean[] value, int offset, int length) throws IOException { 82 for(int i=0; i<length; i++) { 83 value[offset+i] = in.readBoolean(); 84 } 85 } 86 87 public void read_char_array(char[] value, int offset, int length) throws IOException { 88 for(int i=0; i<length; i++) { 89 value[offset+i] = in.readChar(); 90 } 91 } 92 93 public void read_wchar_array(char[] value, int offset, int length) throws IOException { 94 for(int i=0; i<length; i++) { 95 value[offset+i] = in.readChar(); 96 } 97 } 98 99 public void read_octet_array(byte[] value, int offset, int length) throws IOException { 100 for(int i=0; i<length; i++) { 101 value[offset+i] = in.readByte(); 102 } 103 } 104 105 public void read_short_array(short[] value, int offset, int length) throws IOException { 106 for(int i=0; i<length; i++) { 107 value[offset+i] = in.readShort(); 108 } 109 } 110 public void read_ushort_array(short[] value, int offset, int length) throws IOException { 111 for(int i=0; i<length; i++) { 112 value[offset+i] = in.readShort(); 113 } 114 } 115 116 public void read_long_array(int[] value, int offset, int length) throws IOException { 117 for(int i=0; i<length; i++) { 118 value[offset+i] = in.readInt(); 119 } 120 } 121 122 public void read_ulong_array(int[] value, int offset, int length) throws IOException { 123 for(int i=0; i<length; i++) { 124 value[offset+i] = in.readInt(); 125 } 126 } 127 128 public void read_longlong_array(long[] value, int offset, int length) throws IOException { 129 for(int i=0; i<length; i++) { 130 value[offset+i] = in.readLong(); 131 } 132 } 133 134 public void read_ulonglong_array(long[] value, int offset, int length) throws IOException { 135 for(int i=0; i<length; i++) { 136 value[offset+i] = in.readLong(); 137 } 138 } 139 140 public void read_float_array(float[] value, int offset, int length) throws IOException { 141 for(int i=0; i<length; i++) { 142 value[offset+i] = in.readFloat(); 143 } 144 } 145 146 public void read_double_array(double[] value, int offset, int length) throws IOException { 147 for(int i=0; i<length; i++) { 148 value[offset+i] = in.readDouble(); 149 } 150 } 151 152 public cz.cuni.sofa.lib.Object read_Object() throws IOException { 153 try { 154 return (cz.cuni.sofa.lib.Object) in.readObject(); 155 } catch (ClassNotFoundException e) { 156 throw new IOException (e.getMessage()); 157 } 158 } 159 } 160 | Popular Tags |