| 1098 | /// |
| 1099 | /// - `IOException`: thrown by the stream |
| 1100 | public static Object readObject(DataInputStream input) throws IOException { |
| 1101 | try { |
| 1102 | if (!input.readBoolean()) { |
| 1103 | return null; |
| 1104 | } |
| 1105 | String type = input.readUTF(); |
| 1106 | if ("int".equals(type)) { |
| 1107 | return input.readInt(); |
| 1108 | } |
| 1109 | if ("byte".equals(type)) { |
| 1110 | return input.readByte(); |
| 1111 | } |
| 1112 | if ("short".equals(type)) { |
| 1113 | return input.readShort(); |
| 1114 | } |
| 1115 | if ("long".equals(type)) { |
| 1116 | return input.readLong(); |
| 1117 | } |
| 1118 | if ("float".equals(type)) { |
| 1119 | return input.readFloat(); |
| 1120 | } |
| 1121 | if ("double".equals(type)) { |
| 1122 | return input.readDouble(); |
| 1123 | } |
| 1124 | if ("bool".equals(type)) { |
| 1125 | return input.readBoolean(); |
| 1126 | } |
| 1127 | if ("String".equals(type)) { |
| 1128 | return input.readUTF(); |
| 1129 | } |
| 1130 | if ("Date".equals(type)) { |
| 1131 | return new Date(input.readLong()); |
| 1132 | } |
| 1133 | |
| 1134 | if ("ObjectArray".equals(type)) { |
| 1135 | Object[] v = new Object[input.readInt()]; |
| 1136 | int vlen = v.length; |
| 1137 | for (int iter = 0; iter < vlen; iter++) { |
| 1138 | v[iter] = readObject(input); |
| 1139 | } |
| 1140 | return v; |
| 1141 | } |
| 1142 | if ("ByteArray".equals(type)) { |
| 1143 | byte[] v = new byte[input.readInt()]; |
| 1144 | input.readFully(v); |
| 1145 | return v; |
| 1146 | } |
| 1147 | if ("LongArray".equals(type)) { |
| 1148 | long[] v = new long[input.readInt()]; |
| 1149 | int vlen = v.length; |
| 1150 | for (int iter = 0; iter < vlen; iter++) { |
| 1151 | v[iter] = input.readLong(); |
| 1152 | } |
| 1153 | return v; |
| 1154 | } |
| 1155 | if ("ShortArray".equals(type)) { |
| 1156 | short[] v = new short[input.readInt()]; |
| 1157 | int vlen = v.length; |