(DataInput in)
| 148 | } |
| 149 | |
| 150 | public final void readFields(DataInput in) throws IOException { |
| 151 | metadata.clear(); |
| 152 | int sizeOrVersion = in.readInt(); |
| 153 | if (sizeOrVersion < 0) { // version |
| 154 | version = sizeOrVersion; |
| 155 | switch (version) { |
| 156 | case VERSION: |
| 157 | url = Text.readString(in); |
| 158 | base = Text.readString(in); |
| 159 | |
| 160 | content = new byte[in.readInt()]; |
| 161 | in.readFully(content); |
| 162 | |
| 163 | contentType = Text.readString(in); |
| 164 | metadata.readFields(in); |
| 165 | break; |
| 166 | default: |
| 167 | throw new VersionMismatchException((byte) VERSION, (byte) version); |
| 168 | } |
| 169 | } else { // size |
| 170 | byte[] compressed = new byte[sizeOrVersion]; |
| 171 | in.readFully(compressed, 0, compressed.length); |
| 172 | ByteArrayInputStream deflated = new ByteArrayInputStream(compressed); |
| 173 | DataInput inflater = new DataInputStream( |
| 174 | new InflaterInputStream(deflated)); |
| 175 | readFieldsCompressed(inflater); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | public final void write(DataOutput out) throws IOException { |
| 180 | out.writeInt(VERSION); |
no test coverage detected