@Override public String readUTF() throws IOException { byte b = in.readByte(); if (b == 0) { // full string with handle int handle = in.readVInt(); String s = in.readUTF(); handles.put(handle, s); return s; } else if (b == 1) { return handles.get(in.readVInt()); } else if (b == 2) { // full string with handle int handle = in.readVInt(); String s = in.readUTF(); identityHandles.put(handle, s); return s; } else if (b == 3) { return identityHandles.get(in.readVInt()); } else { throw new IOException("Expected handle header"); } }
@Override public void reset() throws IOException { in.reset(); handles.clear(); }
@Override public void readBytes(byte[] b, int offset, int len) throws IOException { in.readBytes(b, offset, len); }
@Override public byte readByte() throws IOException { return in.readByte(); }
@Override public void close() throws IOException { in.close(); }